Class: Pact::PactBroker::FetchPacts
- Inherits:
-
Object
- Object
- Pact::PactBroker::FetchPacts
- Defined in:
- lib/pact/pact_broker/fetch_pacts.rb
Constant Summary collapse
- ALL_PROVIDER_TAG_RELATION =
'pb:provider-pacts-with-tag'.freeze
- LATEST_PROVIDER_TAG_RELATION =
'pb:latest-provider-pacts-with-tag'.freeze
- LATEST_PROVIDER_RELATION =
'pb:latest-provider-pacts'.freeze
- PACTS =
'pacts'.freeze
- PB_PACTS =
'pb:pacts'.freeze
- HREF =
'href'.freeze
Instance Attribute Summary collapse
-
#broker_base_url ⇒ Object
readonly
Returns the value of attribute broker_base_url.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#http_client_options ⇒ Object
readonly
Returns the value of attribute http_client_options.
-
#index_entity ⇒ Object
readonly
Returns the value of attribute index_entity.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(provider, tags, broker_base_url, http_client_options) ⇒ FetchPacts
constructor
A new instance of FetchPacts.
Constructor Details
#initialize(provider, tags, broker_base_url, http_client_options) ⇒ FetchPacts
Returns a new instance of FetchPacts.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 18 def initialize(provider, , broker_base_url, ) @provider = provider @tags = ( || []).collect do |tag| if tag.is_a?(String) { name: tag, all: false, fallback: nil } else tag end end @http_client_options = @broker_base_url = broker_base_url @http_client = Pact::Hal::HttpClient.new() end |
Instance Attribute Details
#broker_base_url ⇒ Object (readonly)
Returns the value of attribute broker_base_url.
9 10 11 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 9 def broker_base_url @broker_base_url end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
9 10 11 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 9 def http_client @http_client end |
#http_client_options ⇒ Object (readonly)
Returns the value of attribute http_client_options.
9 10 11 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 9 def @http_client_options end |
#index_entity ⇒ Object (readonly)
Returns the value of attribute index_entity.
9 10 11 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 9 def index_entity @index_entity end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
9 10 11 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 9 def provider @provider end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
9 10 11 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 9 def @tags end |
Class Method Details
.call(provider, tags, broker_base_url, http_client_options) ⇒ Object
32 33 34 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 32 def self.call(provider, , broker_base_url, ) new(provider, , broker_base_url, ).call end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pact/pact_broker/fetch_pacts.rb', line 36 def call if index.success? if tagged_pacts_for_provider else latest_pacts_for_provider end else raise Pact::Error.new("Error retrieving #{broker_base_url} status=#{index_entity.response.code} #{index_entity.response.raw_body}") end end |