Class: Berkshelf::APIClient::Connection
- Inherits:
-
Object
- Object
- Berkshelf::APIClient::Connection
- Defined in:
- lib/berkshelf/api_client/connection.rb
Instance Attribute Summary collapse
-
#retries ⇒ Integer
readonly
How many retries to attempt on HTTP requests.
-
#retry_interval ⇒ Float
readonly
Time to wait between retries.
- #url ⇒ String readonly
Instance Method Summary collapse
-
#initialize(url, options = {}) ⇒ Connection
constructor
A new instance of Connection.
-
#universe ⇒ Array<APIClient::RemoteCookbook>
Retrieves the entire universe of known cookbooks from the API source.
Constructor Details
#initialize(url, options = {}) ⇒ Connection
Returns a new instance of Connection.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/berkshelf/api_client/connection.rb', line 29 def initialize(url, = {}) # it looks like Faraday mutates the URI argument it is given, when we ripped Faraday out of this # API it stopped doing that. this may or may not be a breaking change (it broke some fairly # brittle berkshelf tests). if it causes too much berkshelf chaos we could revert by uncommenting # the next line. as it is removing this behavior feels more like fixing a bug. # @url = url.normalize! if url.is_a?(Addressable::URI) = { retries: 3, retry_interval: 0.5, open_timeout: 30, timeout: 30 }.merge() [:server_url] = url @client = Berkshelf::RidleyCompatJSON.new(**) end |
Instance Attribute Details
#retries ⇒ Integer (readonly)
Returns how many retries to attempt on HTTP requests.
13 14 15 |
# File 'lib/berkshelf/api_client/connection.rb', line 13 def retries @retries end |
#retry_interval ⇒ Float (readonly)
Returns time to wait between retries.
17 18 19 |
# File 'lib/berkshelf/api_client/connection.rb', line 17 def retry_interval @retry_interval end |
#url ⇒ String (readonly)
9 10 11 |
# File 'lib/berkshelf/api_client/connection.rb', line 9 def url @url end |
Instance Method Details
#universe ⇒ Array<APIClient::RemoteCookbook>
Retrieves the entire universe of known cookbooks from the API source
46 47 48 49 50 51 52 53 54 |
# File 'lib/berkshelf/api_client/connection.rb', line 46 def universe response = @client.get("universe") [].tap do |cookbooks| response.each do |name, versions| versions.each { |version, attributes| cookbooks << RemoteCookbook.new(name, version, attributes) } end end end |