Sha256: a147049f21cf7f17a016636a32b2743de6e4c45340ed87af6aef687c64f8e63c

Contents?: true

Size: 1.13 KB

Versions: 8

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

8 entries across 8 versions & 1 rubygems

Version Path
berkshelf-6.3.4 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-6.3.3 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-7.0.0 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-6.3.2 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-6.3.1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-6.3.0 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-6.2.2 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-6.2.1 lib/berkshelf/api_client/remote_cookbook.rb