Class: PuppetFixtures::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_fixtures.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Metadata

Returns a new instance of Metadata.



361
362
363
364
365
366
367
# File 'lib/puppet_fixtures.rb', line 361

def initialize(path)
  raise ArgumentError unless File.file?(path) && File.readable?(path)

   = JSON.parse(File.read(path))
rescue JSON::ParserError => e
  raise ArgumentError, "Failed to read module metadata at #{path}: #{e}"
end

Instance Method Details

#nameString[1]

Returns The module name.

Returns:

  • (String[1])

    The module name



370
371
372
373
374
375
# File 'lib/puppet_fixtures.rb', line 370

def name
  n = ['name']
  raise ArgumentError 'No module name found' if !n || n.empty?

  n
end

#versionString[1]

Returns The module version.

Returns:

  • (String[1])

    The module version



378
379
380
381
382
383
# File 'lib/puppet_fixtures.rb', line 378

def version
  v = ['version']
  raise ArgumentError 'No module name found' if !v || v.empty?

  v
end