Class: Librarian::Puppet::Dsl::Receiver

Inherits:
Dsl::Receiver
  • Object
show all
Defined in:
lib/librarian/puppet/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#specfileObject (readonly)

Returns the value of attribute specfile.



78
79
80
# File 'lib/librarian/puppet/dsl.rb', line 78

def specfile
  @specfile
end

#working_pathObject (readonly)

Returns the value of attribute working_path.



78
79
80
# File 'lib/librarian/puppet/dsl.rb', line 78

def working_path
  @working_path
end

Instance Method Details

#metadataObject

implement the ‘metadata’ syntax for Puppetfile

Raises:

  • (Error)


88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/librarian/puppet/dsl.rb', line 88

def 
  f = working_path.join('metadata.json')
  raise Error, "Metadata file does not exist: #{f}" unless File.exist?(f)

  begin
    json = JSON.parse(File.read(f))
  rescue JSON::ParserError => e
    raise Error, "Unable to parse json file #{f}: #{e}"
  end
  dependencyList = json['dependencies']
  dependencyList.each do |d|
    mod(d['name'], d['version_requirement'])
  end
end

#run(specfile = nil) ⇒ Object

save the specfile and call librarian



81
82
83
84
85
# File 'lib/librarian/puppet/dsl.rb', line 81

def run(specfile = nil)
  @working_path = specfile.is_a?(Pathname) ? specfile.parent : Pathname.new(Dir.pwd)
  @specfile = specfile
  super
end