Class: R10K::Module::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/module/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata_path) ⇒ Metadata

Returns a new instance of Metadata.

Parameters:

  • metadata_path (Pathname)

    The file path to the metadata



20
21
22
23
24
# File 'lib/r10k/module/metadata.rb', line 20

def initialize()
  @metadata_path = 

  @version = R10K::SemVer::MIN
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



13
14
15
# File 'lib/r10k/module/metadata.rb', line 13

def author
  @author
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/r10k/module/metadata.rb', line 9

def name
  @name
end

#versionObject (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?

Returns:

  • (Boolean)


27
28
29
# File 'lib/r10k/module/metadata.rb', line 27

def exist?
  @metadata_path.file? and @metadata_path.readable?
end

#readObject

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