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
#args, #block, #environment, #name
Instance Method Summary
collapse
#compute_dependencies!
#===, [], arg_reader, #branch_name, #category, #compute_dependencies!, compute_dependencies!, each, #head, #in_branch, #inspect, install!, instances, #merged, #merged_tag, #merged_version, #needed?, #path, #run!, #shell, #status, #tag_message, #tag_name, #tag_name_base, #tagged_sha1, #to_s, #updatable?, #version, #work_dir, #work_subdir
Constructor Details
#initialize(environment, name, args = {}, &block) ⇒ ChefCookbook
Returns a new instance of ChefCookbook.
16
17
18
19
20
21
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 16
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
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 23
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
JSON::load(Net::HTTP.get_response(URI.parse(url)).body)
end
end
|
#conjure! ⇒ Object
46
47
48
49
50
51
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 46
def conjure!
super
FileUtils::rm_f '.git'
end
|
#conjure_commit_message ⇒ Object
53
54
55
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 53
def conjure_commit_message
"Conjured cookbook #{name} version #{version}\nOrigin: #{url}\nChecksum: #{conjured_checksum}\n"
end
|
#cookbook_data ⇒ Object
34
35
36
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 34
def cookbook_data
@cookbook_data ||= api_data(version)
end
|
#upstream_version ⇒ Object
38
39
40
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 38
def upstream_version
URI::parse(api_data['latest_version']).path.split('/').last.gsub('_', '.')
end
|
#url ⇒ Object
42
43
44
|
# File 'lib/vendorificator/vendor/chef_cookbook.rb', line 42
def url
cookbook_data['file']
end
|