Class: R10K::Module::Metadata
- Inherits:
-
Object
- Object
- R10K::Module::Metadata
- Defined in:
- lib/r10k/module/metadata.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#exist? ⇒ Boolean
Does the metadata file itself exist?.
-
#initialize(metadata_path) ⇒ Metadata
constructor
A new instance of Metadata.
-
#read ⇒ Object
Attempt to read the metadata file.
Constructor Details
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
13 14 15 |
# File 'lib/r10k/module/metadata.rb', line 13 def @author end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/r10k/module/metadata.rb', line 9 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
17 18 19 |
# File 'lib/r10k/module/metadata.rb', line 17 def version @version end |
Instance Method Details
#exist? ⇒ Boolean
Does the metadata file itself exist?
27 28 29 |
# File 'lib/r10k/module/metadata.rb', line 27 def exist? @metadata_path.file? and @metadata_path.readable? end |
#read ⇒ Object
Attempt to read the metadata file
32 33 34 35 36 37 38 39 |
# File 'lib/r10k/module/metadata.rb', line 32 def read if self.exist? hash = JSON.parse(@metadata_path.read) attributes_from_hash(hash) end rescue JSON::ParserError false end |