Class: Stove::Community
- Inherits:
-
Object
- Object
- Stove::Community
- Includes:
- Mixin::Instanceable, Mixin::Optionable
- Defined in:
- lib/stove/community.rb
Constant Summary collapse
- DEFAULT_ENDPOINT =
The default endpoint where the community site lives.
'https://supermarket.getchef.com/api/v1'
Instance Method Summary collapse
-
#cookbook(name, version = nil) ⇒ Hash
Get and cache a community cookbook’s JSON response from the given name and version.
-
#upload(cookbook) ⇒ Object
Upload a cookbook to the community site.
-
#yank(name) ⇒ true, false
Delete the given cookbook from the communit site.
Methods included from Mixin::Optionable
Methods included from Mixin::Instanceable
Instance Method Details
#cookbook(name, version = nil) ⇒ Hash
Get and cache a community cookbook’s JSON response from the given name and version.
39 40 41 42 43 44 45 |
# File 'lib/stove/community.rb', line 39 def cookbook(name, version = nil) if version.nil? connection.get("cookbooks/#{name}") else connection.get("cookbooks/#{name}/versions/#{Util.version_for_url(version)}") end end |
#upload(cookbook) ⇒ Object
Upload a cookbook to the community site.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/stove/community.rb', line 53 def upload(cookbook) connection.post('cookbooks', { 'tarball' => cookbook.tarball, # This is for legacy, backwards-compatability reasons. The new # Supermarket site does not require a category, but many of the testing # tools still assume a cookbook category is present. We just hardcode # "Other" here. 'cookbook' => { 'category' => 'Other' }.to_json, }) end |
#yank(name) ⇒ true, false
Delete the given cookbook from the communit site.
74 75 76 77 78 79 80 |
# File 'lib/stove/community.rb', line 74 def yank(name) connection.delete("/cookbooks/#{name}") true rescue ChefAPI::Error::HTTPBadRequest, ChefAPI::Error::HTTPNotFound, false end |