class R10K::Module::MetadataFile

Public Class Methods

new(metadata_file_path) click to toggle source

@param metadata_path [Pathname] The file path to the metadata

# File lib/r10k/module/metadata_file.rb, line 8
def initialize(metadata_file_path)
  @metadata_file_path = metadata_file_path
end

Public Instance Methods

exist?() click to toggle source

Does the metadata file itself exist?

# 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) click to toggle source

@return [Puppet::ModuleTool::Metadata ] The metadata object created by the metadatafile

# File lib/r10k/module/metadata_file.rb, line 18
def read(metadata_file_path = @metadata_file_path)
  if self.exist?
    metadata_file_path.open do |f|
      begin
        metadata = PuppetForge::Metadata.new
        metadata.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