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.
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
#name ⇒ String[1]
Returns 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 |
#version ⇒ String[1]
Returns 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 |