class Librarian::Puppet::Dsl::Receiver
Attributes
specfile[R]
working_path[R]
Public Instance Methods
metadata()
click to toggle source
implement the 'metadata' syntax for Puppetfile
# File lib/librarian/puppet/dsl.rb, line 92 def metadata f = working_path.join('metadata.json') unless File.exists?(f) msg = "Metadata file does not exist: #{f}" # try modulefile, in case we don't have a Puppetfile and we are using the default template if File.exists?(modulefile_path) modulefile return else raise Error, msg end end 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
modulefile()
click to toggle source
implement the 'modulefile' syntax for Puppetfile
# File lib/librarian/puppet/dsl.rb, line 82 def modulefile f = modulefile_path raise Error, "Modulefile file does not exist: #{f}" unless File.exists?(f) File.read(f).lines.each do |line| regexp = /\s*dependency\s+('|")([^'"]+)\1\s*(?:,\s*('|")([^'"]+)\3)?/ regexp =~ line && mod($2, $4) end end
run(specfile = nil)
click to toggle source
save the specfile and call librarian
Calls superclass method
# File lib/librarian/puppet/dsl.rb, line 75 def run(specfile = nil) @working_path = specfile.kind_of?(Pathname) ? specfile.parent : Pathname.new(Dir.pwd) @specfile = specfile super end
Private Instance Methods
modulefile_path()
click to toggle source
# File lib/librarian/puppet/dsl.rb, line 117 def modulefile_path working_path.join('Modulefile') end