Class: R10K::Module::MetadataFile

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

Instance Method Summary collapse

Constructor Details

#initialize(metadata_file_path) ⇒ MetadataFile

Returns a new instance of MetadataFile.

Parameters:

  • metadata_path (Pathname)

    The file path to the metadata



8
9
10
# File 'lib/r10k/module/metadata_file.rb', line 8

def initialize()
   = 
end

Instance Method Details

#exist?Boolean

Does the metadata file itself exist?

Returns:

  • (Boolean)


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

def exist?
  .file? and .readable?
end

#read(metadata_file_path = @metadata_file_path) ⇒ Puppet::ModuleTool::Metadata

Returns The metadata object created by the metadatafile.

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/r10k/module/metadata_file.rb', line 18

def read( = )
  if self.exist?
    .open do |f|
      begin
         = Puppet::ModuleTool::.new
        .update(JSON.load(f), false)
      rescue JSON::ParserError => e
        exception = R10K::Error.wrap(e, "Could not read metadata.json")
        raise exception
      end
    end
  end
end