Class: Berkshelf::APIClient::RemoteCookbook

Inherits:
Object
  • Object
show all
Defined in:
lib/berkshelf/api_client/remote_cookbook.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, attributes = {}) ⇒ RemoteCookbook

Returns a new instance of RemoteCookbook.

Parameters:

  • name (String)
  • version (String)
  • attributes (Hash) (defaults to: {})


17
18
19
20
21
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 17

def initialize(name, version, attributes = {})
  @name       = name
  @version    = version
  @attributes = ::Mash.new(attributes)
end

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 10

def name
  @name
end

#versionString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 12

def version
  @version
end

Instance Method Details

#dependenciesHash

Returns:

  • (Hash)


24
25
26
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 24

def dependencies
  @attributes[:dependencies]
end

#location_pathString

Returns:

  • (String)


39
40
41
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 39

def location_path
  @attributes[:location_path]
end

#location_typeSymbol

Returns:

  • (Symbol)


34
35
36
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 34

def location_type
  @attributes[:location_type].to_sym
end

#platformsHash

Returns:

  • (Hash)


29
30
31
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 29

def platforms
  @attributes[:platforms]
end

#to_hashObject



43
44
45
46
47
48
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 43

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

#to_json(options = {}) ⇒ Object



50
51
52
# File 'lib/berkshelf/api_client/remote_cookbook.rb', line 50

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