Class: Berkshelf::APIClient::ChefServerConnection
- Inherits:
-
Object
- Object
- Berkshelf::APIClient::ChefServerConnection
- Defined in:
- lib/berkshelf/api_client/chef_server_connection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(*args) ⇒ ChefServerConnection
constructor
A new instance of ChefServerConnection.
- #universe ⇒ Object
Constructor Details
#initialize(*args) ⇒ ChefServerConnection
Returns a new instance of ChefServerConnection.
9 10 11 12 |
# File 'lib/berkshelf/api_client/chef_server_connection.rb', line 9 def initialize(*args) @client = Berkshelf::RidleyCompat.new(*args) @url = args[0][:server_url] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/berkshelf/api_client/chef_server_connection.rb', line 7 def client @client end |
Instance Method Details
#universe ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/berkshelf/api_client/chef_server_connection.rb', line 14 def universe response = client.get("universe") [].tap do |cookbooks| response.each do |name, versions| versions.each { |version, attributes| attributes[:location_path] = @url cookbooks << RemoteCookbook.new(name, version, attributes) } end end rescue Ridley::Errors::HTTPNotFound raise ServiceNotFound, "service not found at: #{@url}" end |