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()
  @metadata_file_path = 
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?
  @metadata_file_path.file? and @metadata_file_path.readable?
end

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

Returns The metadata object created by the metadatafile.

Returns:

  • (Puppet::ModuleTool::Metadata)

    The metadata object created by the metadatafile



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

def read( = @metadata_file_path)
  if self.exist?
    .open do |f|
      begin
         = PuppetForge::Metadata.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