Class: Vendorificator::Vendor::ChefCookbook
Constant Summary
collapse
- API_PREFIX =
'http://cookbooks.opscode.com/api/v1/cookbooks/'
Instance Attribute Summary
Attributes inherited from Archive
#conjured_checksum, #conjured_filesize
#args, #block, #environment, #name, #segment
Instance Method Summary
collapse
#compute_dependencies!
#===, arg_reader, #before_conjure!, #compute_dependencies!, #git_add_extra_paths, #group, #inspect, #metadata, #version
Constructor Details
#initialize(environment, name, args = {}, &block) ⇒ ChefCookbook
Returns a new instance of ChefCookbook.
17
18
19
20
21
22
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 17
def initialize(environment, name, args={}, &block)
args[:url] ||= true args[:filename] ||= "#{name}.tgz"
super(environment, name, args, &block)
end
|
Instance Method Details
#api_data(v = nil) ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 24
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
|
#conjure! ⇒ Object
47
48
49
50
51
52
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 47
def conjure!
super
FileUtils::rm_f '.git'
end
|
#conjure_commit_message ⇒ Object
54
55
56
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 54
def conjure_commit_message
"Conjured cookbook #{name} version #{version}\nOrigin: #{url}\nChecksum: #{conjured_checksum}\n"
end
|
#cookbook_data ⇒ Object
35
36
37
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 35
def cookbook_data
@cookbook_data ||= api_data(version)
end
|
#upstream_version ⇒ Object
39
40
41
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 39
def upstream_version
URI::parse(api_data['latest_version']).path.split('/').last.gsub('_', '.')
end
|
#url ⇒ Object
43
44
45
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 43
def url
cookbook_data['file']
end
|