Class: Chef::RemoteCookbook
- Inherits:
-
Object
- Object
- Chef::RemoteCookbook
- Defined in:
- lib/chef/remote_cookbook.rb
Instance Attribute Summary collapse
-
#deprecated ⇒ Object
Returns the value of attribute deprecated.
-
#description ⇒ Object
Returns the value of attribute description.
-
#latest_version ⇒ Object
Returns the value of attribute latest_version.
-
#maintainer ⇒ Object
Returns the value of attribute maintainer.
-
#name ⇒ Object
Returns the value of attribute name.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#versions ⇒ Object
Returns the value of attribute versions.
Class Method Summary collapse
-
.from_json_details(uri, json_hash) ⇒ Object
this type of response comes back from directly looking up a cookbook.
-
.from_json_list(json_hash) ⇒ Object
these kind of responses come back from ‘search’ and ‘list’.
Instance Method Summary collapse
- #find_version_by_uri(uri) ⇒ Object
- #find_version_by_user_version(version) ⇒ Object
-
#initialize(params = {}) ⇒ RemoteCookbook
constructor
A new instance of RemoteCookbook.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ RemoteCookbook
Returns a new instance of RemoteCookbook.
49 50 51 52 53 54 55 56 |
# File 'lib/chef/remote_cookbook.rb', line 49 def initialize(params = {}) @uri = params[:uri] @maintainer = params[:maintainer] @name = params[:name] @description = params[:description] @versions = Array.new end |
Instance Attribute Details
#deprecated ⇒ Object
Returns the value of attribute deprecated.
46 47 48 |
# File 'lib/chef/remote_cookbook.rb', line 46 def deprecated @deprecated end |
#description ⇒ Object
Returns the value of attribute description.
45 46 47 |
# File 'lib/chef/remote_cookbook.rb', line 45 def description @description end |
#latest_version ⇒ Object
Returns the value of attribute latest_version.
47 48 49 |
# File 'lib/chef/remote_cookbook.rb', line 47 def latest_version @latest_version end |
#maintainer ⇒ Object
Returns the value of attribute maintainer.
45 46 47 |
# File 'lib/chef/remote_cookbook.rb', line 45 def maintainer @maintainer end |
#name ⇒ Object
Returns the value of attribute name.
45 46 47 |
# File 'lib/chef/remote_cookbook.rb', line 45 def name @name end |
#uri ⇒ Object
Returns the value of attribute uri.
45 46 47 |
# File 'lib/chef/remote_cookbook.rb', line 45 def uri @uri end |
#versions ⇒ Object
Returns the value of attribute versions.
47 48 49 |
# File 'lib/chef/remote_cookbook.rb', line 47 def versions @versions end |
Class Method Details
.from_json_details(uri, json_hash) ⇒ Object
this type of response comes back from directly looking up a cookbook
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/chef/remote_cookbook.rb', line 71 def self.from_json_details(uri, json_hash) unless json_hash.kind_of?(Hash) raise "from_json_show needs a hash" end res = new res.uri = uri res.name = json_hash['name'] res.maintainer = json_hash['maintainer'] res.description = json_hash['description'] res.deprecated = json_hash['deprecated'] == 'true' # res.external_url = json_hash['external_url'] # res.category = json_hash['category'] # res.average_rating = json_hash['average_rating'] # res.created_at = Date.parse json_hash['created_at'] # res.updated_at = Date.parse json_hash['updated_at'] versions = json_hash['versions'] if (!versions.nil?) && (versions.kind_of? Array) versions.each do |ver| res.versions.push(RemoteCookbookVersion.new ver) end res.latest_version = res.find_version_by_uri json_hash['latest_version'] end res end |
.from_json_list(json_hash) ⇒ Object
these kind of responses come back from ‘search’ and ‘list’
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/remote_cookbook.rb', line 59 def self.from_json_list(json_hash) res = new res.uri = json_hash['cookbook'] res.maintainer = json_hash['cookbook_maintainer'] res.name = json_hash['cookbook_name'] res.description = json_hash['cookbook_description'] res end |
Instance Method Details
#find_version_by_uri(uri) ⇒ Object
100 101 102 |
# File 'lib/chef/remote_cookbook.rb', line 100 def find_version_by_uri(uri) @versions.find { |ver| ver.uri == uri } end |
#find_version_by_user_version(version) ⇒ Object
104 105 106 |
# File 'lib/chef/remote_cookbook.rb', line 104 def find_version_by_user_version(version) @versions.find { |ver| ver.version == version } end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/chef/remote_cookbook.rb', line 108 def to_s "RemoteCookbook #{@name}: description '#{@description}', maint #{@maintainer}, uri #{@uri}" end |