Sha256: 5bc3baf6f7935a4330c3f6fa70441df8391349fdb958a0ea039ba746f4917451

Contents?: true

Size: 872 Bytes

Versions: 68

Compression:

Stored size: 872 Bytes

Contents

require 'r10k/module'
require 'r10k/errors'
require 'puppet_forge'

class R10K::Module::MetadataFile

  # @param metadata_path [Pathname] The file path to the metadata
  def initialize(metadata_file_path)
    @metadata_file_path = metadata_file_path
  end

  # Does the metadata file itself exist?
  def exist?
    @metadata_file_path.file? and @metadata_file_path.readable?
  end

  # @return [Puppet::ModuleTool::Metadata ] The metadata object created by the metadatafile
  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
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
r10k-5.0.0 lib/r10k/module/metadata_file.rb
r10k-4.1.0 lib/r10k/module/metadata_file.rb
r10k-4.0.2 lib/r10k/module/metadata_file.rb
r10k-4.0.1 lib/r10k/module/metadata_file.rb
r10k-4.0.0 lib/r10k/module/metadata_file.rb
r10k-4.0.0.pre lib/r10k/module/metadata_file.rb
r10k-3.16.0 lib/r10k/module/metadata_file.rb
r10k-3.15.4 lib/r10k/module/metadata_file.rb
r10k-3.15.3 lib/r10k/module/metadata_file.rb
r10k-3.15.2 lib/r10k/module/metadata_file.rb
r10k-3.15.1 lib/r10k/module/metadata_file.rb
r10k-3.15.0 lib/r10k/module/metadata_file.rb
akerl-r10k-3.14.2.1 lib/r10k/module/metadata_file.rb
r10k-3.14.2 lib/r10k/module/metadata_file.rb
r10k-3.14.1 lib/r10k/module/metadata_file.rb
r10k-3.14.0 lib/r10k/module/metadata_file.rb
r10k-3.13.0 lib/r10k/module/metadata_file.rb
r10k-3.12.1 lib/r10k/module/metadata_file.rb
r10k-3.12.0 lib/r10k/module/metadata_file.rb
r10k-3.11.0 lib/r10k/module/metadata_file.rb