Class: Stove::CommunitySite

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/stove/community_site.rb

Class Method Summary collapse

Class Method Details

.cookbook(name, version = nil) ⇒ Object

Get and cache a community cookbook’s JSON response from the given name and version.

Examples:

Find a cookbook by name

CommunitySite.cookbook('apache2') #=> {...}

Find a cookbook by name and version

CommunitySite.cookbook('apache2', '1.0.0') #=> {...}

Find a non-existent cookbook

CommunitySite.cookbook('not-real') #=> CommunitySite::BadResponse

Parameters:

  • name (String)

    the name of the cookbook on the community site

  • version (String) (defaults to: nil)

    (optional) the version of the cookbook to find

Raises:

  • (CommunitySite::BadResponse)

    if the given cookbook (or cookbook version) does not exist on the community site



44
45
46
47
48
49
50
# File 'lib/stove/community_site.rb', line 44

def cookbook(name, version = nil)
  if version.nil?
    get("/cookbooks/#{name}")
  else
    get("/cookbooks/#{name}/versions/#{format_version(version)}")
  end
end

.http_uri(arg = nil) ⇒ String

The URI for the web-based version of the site. (default: community.opscode.com).

If a parameter is given, the http_uri is set to that value.

Returns:

  • (String)


16
17
18
19
20
21
22
23
# File 'lib/stove/community_site.rb', line 16

def http_uri(arg = nil)
  if arg.nil?
    @http_uri ||= 'https://community.opscode.com'
  else
    @http_uri = arg
    @http_uri
  end
end