class CommunityZero::CookbookEndpoint
The endpoint for interacting with a single cookbook.
@author Seth Vargo <sethvargo@gmail.com>
Public Instance Methods
delete(request)
click to toggle source
DELETE /cookbooks/:name
# File lib/community_zero/endpoints/cookbook_endpoint.rb, line 52 def delete(request) name = request.path.last if cookbook = store.find(name) store.remove(cookbook) respond({}) else respond(404, { 'error_code' => 'NOT_FOUND', 'error_messages' => ['Resource not found'], } ) end end
get(request)
click to toggle source
GET /cookbooks/:name
# File lib/community_zero/endpoints/cookbook_endpoint.rb, line 24 def get(request) name = request.path.last cookbook = store.find(name) if cookbook = store.find(name) respond({ 'name' => cookbook.name, 'maintainer' => cookbook.maintainer, 'category' => cookbook.category, 'external_url' => cookbook.external_url, 'description' => cookbook.description, 'average_rating' => cookbook.average_rating, 'versions' => store.versions(cookbook).map { |i| version_url_for(cookbook, i) }, 'latest_version' => version_url_for(cookbook, store.latest_version(cookbook)), 'created_at' => cookbook.created_at, 'updated_at' => cookbook.upadated_at, }) else respond(404, { 'error_code' => 'NOT_FOUND', 'error_messages' => ['Resource not found'], } ) end end