Class: PactBroker::Client::PublishPacts

Inherits:
Object
  • Object
show all
Includes:
HalClientMethods
Defined in:
lib/pact_broker/client/publish_pacts.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HalClientMethods

#create_entry_point, #create_http_client, #create_index_entry_point, #index_entry_point, #index_resource, #is_pactflow?, #pact_broker_name

Constructor Details

#initialize(pact_broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options = {}) ⇒ PublishPacts

Returns a new instance of PublishPacts.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pact_broker/client/publish_pacts.rb', line 19

def initialize pact_broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options={}
  @pact_broker_base_url = pact_broker_base_url
  @pact_file_paths = pact_file_paths
  @consumer_version_params = consumer_version_params
  @consumer_version_number = strip(consumer_version_params[:number])
  @branch = strip(consumer_version_params[:branch])
  @build_url = strip(consumer_version_params[:build_url])
  @tags = consumer_version_params[:tags] ? consumer_version_params[:tags].collect{ |tag| strip(tag) } : []
  @options = options
  @pact_broker_client_options = pact_broker_client_options
end

Class Method Details

.call(pact_broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options = {}) ⇒ Object



15
16
17
# File 'lib/pact_broker/client/publish_pacts.rb', line 15

def self.call(pact_broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options={})
  new(pact_broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options).call
end

Instance Method Details

#callObject



31
32
33
34
35
36
37
38
39
# File 'lib/pact_broker/client/publish_pacts.rb', line 31

def call
  validate
  if !force_use_old_api? && index_resource.can?("pb:publish-contracts")
    publish_pacts
    PactBroker::Client::CommandResult.new(success?, message)
  else
    PublishPactsTheOldWay.call(pact_broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options)
  end
end