Module: PactBroker::Services::PactService
Instance Method Summary
collapse
pact_repository, pacticipant_repository, tag_repository, version_repository, webhook_repository
group_service, pact_service, pacticipant_service, tag_service, webhook_service
Instance Method Details
#create_or_update_pact(params) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/pact_broker/services/pact_service.rb', line 25
def create_or_update_pact params
provider = pacticipant_repository.find_by_name_or_create params[:provider_name]
consumer = pacticipant_repository.find_by_name_or_create params[:consumer_name]
consumer_version = version_repository.find_by_pacticipant_id_and_number_or_create consumer.id, params[:consumer_version_number]
existing_pact = pact_repository.find_by_version_and_provider(consumer_version.id, provider.id)
if existing_pact
update_pact params, existing_pact
else
create_pact params, consumer_version, provider
end
end
|
#find_all_pacts_between(consumer, options) ⇒ Object
38
39
40
|
# File 'lib/pact_broker/services/pact_service.rb', line 38
def find_all_pacts_between consumer, options
pact_repository.find_all_pacts_between consumer, options
end
|
#find_distinct_pacts_between(consumer, options) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/pact_broker/services/pact_service.rb', line 42
def find_distinct_pacts_between consumer, options
all = pact_repository.find_all_pacts_between consumer, options
distinct = []
(0...all.size).each do | i |
if i == all.size - 1
distinct << all[i]
else
if all[i].json_content != all[i+1].json_content
distinct << all[i]
end
end
end
distinct
end
|
#find_latest_pact(params) ⇒ Object
13
14
15
|
# File 'lib/pact_broker/services/pact_service.rb', line 13
def find_latest_pact params
pact_repository.find_latest_pact(params[:consumer_name], params[:provider_name], params[:tag])
end
|
#find_latest_pacts ⇒ Object
17
18
19
|
# File 'lib/pact_broker/services/pact_service.rb', line 17
def find_latest_pacts
pact_repository.find_latest_pacts
end
|
#find_pact(params) ⇒ Object
21
22
23
|
# File 'lib/pact_broker/services/pact_service.rb', line 21
def find_pact params
pact_repository.find_pact(params[:consumer_name], params[:consumer_version_number], params[:provider_name])
end
|
#pact_has_changed_since_previous_version?(pact) ⇒ Boolean
58
59
60
61
|
# File 'lib/pact_broker/services/pact_service.rb', line 58
def pact_has_changed_since_previous_version? pact
previous_pact = pact_repository.find_previous_pact pact
previous_pact && pact.json_content != previous_pact.json_content
end
|