class Octofacts::Backends::YamlFile

Attributes

filename[R]
options[R]

Public Class Methods

new(filename, options = {}) click to toggle source
# File lib/octofacts/backends/yaml_file.rb, line 8
def initialize(filename, options = {})
  raise(Errno::ENOENT, "The file #{filename} does not exist") unless File.file?(filename)

  @filename = filename
  @options  = options
  @facts    = nil
end

Public Instance Methods

facts() click to toggle source
# File lib/octofacts/backends/yaml_file.rb, line 16
def facts
  @facts ||= begin
    f = YAML.safe_load(File.read(filename))
    Octofacts::Util::Keys.symbolize_keys!(f)
    f
  end
end
prefer(conditions) click to toggle source
# File lib/octofacts/backends/yaml_file.rb, line 34
def prefer(conditions)
  # noop
end
reject(conditions) click to toggle source
# File lib/octofacts/backends/yaml_file.rb, line 29
def reject(conditions)
  Octofacts::Util::Keys.symbolize_keys!(conditions)
  raise Octofacts::Errors::NoFactsError if (conditions.to_a - facts.to_a).empty?
end
select(conditions) click to toggle source
# File lib/octofacts/backends/yaml_file.rb, line 24
def select(conditions)
  Octofacts::Util::Keys.symbolize_keys!(conditions)
  raise Octofacts::Errors::NoFactsError unless (conditions.to_a - facts.to_a).empty?
end