Sha256: f53c61f591c5edbe2b64c233af5c8aaf6ff81a862578bd87d718d23b145e8516
Contents?: true
Size: 1.55 KB
Versions: 7
Compression:
Stored size: 1.55 KB
Contents
require 'net/http' require 'uri' autoload :MultiJson, 'multi_json' require 'vendorificator/vendor/archive' require 'vendorificator/hooks/chef_cookbook' module Vendorificator class Vendor::ChefCookbook < Vendor::Archive include Hooks::ChefCookbookDependencies @method_name = :chef_cookbook @group = :cookbooks API_PREFIX = 'http://cookbooks.opscode.com/api/v1/cookbooks/' def initialize(environment, name, args={}, &block) args[:url] ||= true # to avoid having name treated as url args[:filename] ||= "#{name}.tgz" super(environment, name, args, &block) end def api_data(v=nil) v = v.gsub(/[^0-9]/, '_') if v @api_data ||= {} @api_data[v] ||= begin url = "#{API_PREFIX}#{name}" url << "/versions/#{v}" if v MultiJson::load(Net::HTTP.get_response(URI.parse(url)).body) end end def cookbook_data @cookbook_data ||= api_data(version) end def upstream_version URI::parse(api_data['latest_version']).path.split('/').last.gsub('_', '.') end def url cookbook_data['file'] end def conjure! super # Some Opscode Community tarballs include a confusing .git file, # we don't want this. FileUtils::rm_f '.git' end def conjure_commit_message "Conjured cookbook #{name} version #{version}\nOrigin: #{url}\nChecksum: #{conjured_checksum}\n" end end class Config register_module :chef_cookbook, Vendor::ChefCookbook option :chef_cookbook_ignore_dependencies end end
Version data entries
7 entries across 7 versions & 1 rubygems