Method: FalkorLib::Puppet::Modules.metadata
- Defined in:
- lib/falkorlib/puppet/modules.rb
.metadata(moduledir = Dir.pwd, options = { :use_symbols => true, :extras => true, :no_interaction => false }) ⇒ Object
Retrieves the metadata from the metadata.json file in ‘moduledir`. Supported options:
:use_symbols [boolean]: convert all keys to symbols
:extras [boolean]: add extra keys
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/falkorlib/puppet/modules.rb', line 242 def (moduledir = Dir.pwd, = { :use_symbols => true, :extras => true, :no_interaction => false }) add_extras = ([:extras].nil?) ? true : [:extras] name = File.basename( moduledir ) error "The module #{name} does not exist" unless File.directory?( moduledir ) jsonfile = File.join( moduledir, 'metadata.json') error "Unable to find #{jsonfile}" unless File.exist?( jsonfile ) = JSON.parse( IO.read( jsonfile ) ) ["docs_project"] = ask("\tRead the Docs (RTFD) project:", (['name'].downcase.gsub(/\//, '-puppet-')).to_s) if ["docs_project"].nil? if add_extras [:shortname] = name.gsub(/.*-/, '') [:platforms] = [] ["operatingsystem_support"].each do |e| [:platforms] << e["operatingsystem"].downcase unless e["operatingsystem"].nil? end # Analyse params params_manifest = File.join(moduledir, 'manifests', 'params.pp') if File.exist?(params_manifest) params = [] File.read(params_manifest).scan(/^\s*\$(.*)\s*=/) do |_m| params << Regexp.last_match(1).gsub(/\s+$/, '') unless Regexp.last_match(1).nil? end [:params] = params.uniq end end if [:use_symbols] # convert string keys to symbols .keys.each do |k| [(begin k.to_sym rescue k end) || k] = .delete(k) end end end |