Sha256: c7c395b14a5bd5e81a01b323a7109a231c60016dbfd9be17d72d2dda53029fd4

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'json'
require 'chef/mash'

module Berkshelf::APIClient
  # A representation of cookbook metadata indexed by a Berkshelf API Server. Returned
  # by sending messages to a {Berkshelf::APIClient} and used to download cookbooks
  # indexed by the Berkshelf API Server.
  class RemoteCookbook
    # @return [String]
    attr_reader :name
    # @return [String]
    attr_reader :version

    # @param [String] name
    # @param [String] version
    # @param [Hash] attributes
    def initialize(name, version, attributes = {})
      @name       = name
      @version    = version
      @attributes = ::Mash.new(attributes)
    end

    # @return [Hash]
    def dependencies
      @attributes[:dependencies]
    end

    # @return [Hash]
    def platforms
      @attributes[:platforms]
    end

    # @return [Symbol]
    def location_type
      @attributes[:location_type].to_sym
    end

    # @return [String]
    def location_path
      @attributes[:location_path]
    end

    def to_hash
      {
        name: name,
        version: version
      }
    end

    def to_json(options = {})
      ::JSON.pretty_generate(to_hash, options)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
berkshelf-api-client-4.0.1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-4.0.0 lib/berkshelf/api_client/remote_cookbook.rb