class Retrospec::Puppet::Generators::Facter
Public Class Methods
add(name, options={}, &block)
click to toggle source
every fact will have a Facter.add
functionality this is the startign point to collect all data
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 86 def self.add(name, options={}, &block) # calls the facter.add block # this may call separate confine statements # for each Facter.add block that gets called we need to reset a few things @confines = {} @used_facts = {} @exec_calls = {} begin block.call rescue Exception => e rescue NameError => e end @model.facts[name] = OpenStruct.new(:fact_name => name) @model.facts[name].used_facts = used_facts @model.facts[name].confines = @confines @model.defined_methods = methods_defined @model.facts[name].exec_calls = exec_calls @model end
confine(fact, *values)
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 65 def self.confine(fact, *values) @confines << fact end
exec_calls()
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 28 def self.exec_calls @exec_calls ||= {} end
fact(name)
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 44 def self.fact(name) fake_fact = OpenStruct.new(:value => '') used_facts[name] = {:name => name} fake_fact end
load_fact(file)
click to toggle source
loads the fact into the loader for evaluation and data collection
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 71 def self.load_fact(file) @model = OpenStruct.new(:facts => {}, :defined_methods => [], :global_used_facts => {}, :global_used_execs => {}) begin proc = Proc.new {} eval(File.read(file), proc.binding, file) rescue LoadError => e puts "Error loading dependency for file: #{file}, skipping".fatal rescue Exception => e puts "Error evaluating file: #{file}, skipping".fatal end @model end
method_missing(method_sym, *arguments, &block)
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 50 def self.method_missing(method_sym, *arguments, &block) unless methods_defined.include?(method_sym) methods_defined << method_sym end method_sym end
methods_defined()
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 36 def self.methods_defined @methods_defined ||= [] end
new(name, options, &block)
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 24 def initialize(name, options, &block) @fact_name = name end
setcode(&block)
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 57 def self.setcode(&block) begin block.call rescue Exception => e rescue NameError => e end end
used_facts()
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 32 def self.used_facts @used_facts ||= {} end
value(name)
click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/parsers/facter.rb, line 40 def self.value(name) used_facts[name] = {:name => name} end