Class: Chef::RemoteCookbookVersion
- Inherits:
-
Object
- Object
- Chef::RemoteCookbookVersion
- Defined in:
- lib/chef/remote_cookbook.rb
Instance Attribute Summary collapse
-
#tarball_uri ⇒ Object
Returns the value of attribute tarball_uri.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri) ⇒ RemoteCookbookVersion
constructor
A new instance of RemoteCookbookVersion.
- #set_from_json_hash(hostname, json_hash) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(uri) ⇒ RemoteCookbookVersion
Returns a new instance of RemoteCookbookVersion.
7 8 9 |
# File 'lib/chef/remote_cookbook.rb', line 7 def initialize(uri) @uri = uri end |
Instance Attribute Details
#tarball_uri ⇒ Object
Returns the value of attribute tarball_uri.
5 6 7 |
# File 'lib/chef/remote_cookbook.rb', line 5 def tarball_uri @tarball_uri end |
#uri ⇒ Object
Returns the value of attribute uri.
4 5 6 |
# File 'lib/chef/remote_cookbook.rb', line 4 def uri @uri end |
Instance Method Details
#set_from_json_hash(hostname, json_hash) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chef/remote_cookbook.rb', line 20 def set_from_json_hash(hostname, json_hash) tarball_path = json_hash['file'] if tarball_path =~ /http/ # absolute path. use it verbatim. @tarball_uri = tarball_path else # relative path. use the hostname we already have and the path in 'file' # chop off leading slash for relative paths if tarball_path =~ /^\/(.+)$/ tarball_path = $1 end @tarball_uri = "http://#{hostname}/#{tarball_path}" end #created_at = Date.parse json_hash['created_at'] #updated_at = Date.parse json_hash['updated_at'] #average_rating = json_hash['average_rating'] #license = json_hash['license'] end |
#version ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/chef/remote_cookbook.rb', line 11 def version # http://www.example.com/api/v1/cookbooks/apache/versions/1_0 version = "" if /.+\/([^\/]+)$/ =~ @uri version = $1 end version.gsub(/_/, '.') end |