Sha256: bb56e767eb9cc64534c7aa3b57adebf0ce5e181d4b0c1a6e071f902e74ffce45

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

require 'json'

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 = 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

12 entries across 12 versions & 1 rubygems

Version Path
berkshelf-api-client-3.0.0 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-2.0.2 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-2.0.1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.3.1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-2.0.0 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.3.0 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.2.1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.2.0 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.2.0.rc2 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.2.0.rc1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.1.1 lib/berkshelf/api_client/remote_cookbook.rb
berkshelf-api-client-1.1.0 lib/berkshelf/api_client/remote_cookbook.rb