Class: PuppetFixtures::Metadata
- Inherits:
-
Object
- Object
- PuppetFixtures::Metadata
- Defined in:
- lib/puppet_fixtures.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ Metadata
constructor
A new instance of Metadata.
-
#name ⇒ String[1]
The module name.
-
#version ⇒ String[1]
The module version.
Constructor Details
#initialize(path) ⇒ Metadata
Returns a new instance of Metadata.
382 383 384 385 386 387 388 |
# File 'lib/puppet_fixtures.rb', line 382 def initialize(path) raise ArgumentError unless File.file?(path) && File.readable?(path) @metadata = JSON.parse(File.read(path)) rescue JSON::ParserError => e raise ArgumentError, "Failed to read module metadata at #{path}: #{e}" end |
Instance Method Details
#name ⇒ String[1]
Returns The module name.
391 392 393 394 395 396 |
# File 'lib/puppet_fixtures.rb', line 391 def name n = @metadata['name'] raise ArgumentError 'No module name found' if !n || n.empty? n end |
#version ⇒ String[1]
Returns The module version.
399 400 401 402 403 404 |
# File 'lib/puppet_fixtures.rb', line 399 def version v = @metadata['version'] raise ArgumentError 'No module name found' if !v || v.empty? v end |