Method: Retrospec::Puppet::Functions.load_function

Defined in:
lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb

.load_function(file) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb', line 25

def self.load_function(file)
  begin
    ::Puppet.initialize_settings
  rescue
    # do nothing otherwise calling init twice raises an error
  end
  @model = OpenStruct.new(:name => File.basename(file, '.rb'), :dispatched_methods => {},
                          :required_methods => [])

  f = eval(File.read(file))
  @model.required_methods = find_required_methods(@model.name, @model.dispatched_methods.keys)
  @model
end