Module: Retrospec::Puppet::Parser::Functions

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

Class Method Summary collapse

Class Method Details

.create_function(func_name, function_base = Function, &block) ⇒ Object

for puppet 4 functions



69
70
71
# File 'lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb', line 69

def self.create_function(func_name, function_base = Function, &block)
  {:name => func_name }
end

.load_function(file) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb', line 73

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'), :arity => nil, :doc => '', :type => nil,
                          :class_methods => [], :instance_methods => [], :options => {})
  f = eval(File.read(file))
  @model.name = f[:name]
  @model.arity = f[:arity]
  @model.doc   = f[:doc]
  @model.type = f[:type]
  @model
end

.newfunction(name, options = {}, &block) ⇒ Object

for puppet 3 functions



64
65
66
# File 'lib/retrospec/plugins/v1/plugin/generators/parsers/function.rb', line 64

def self.newfunction(name, options = {}, &block)
  options.merge({:name => name})
end