Module: PactBroker::Matrix::Service
Instance Method Summary
collapse
label_repository, matrix_repository, pact_repository, pacticipant_repository, tag_repository, verification_repository, version_repository, webhook_repository
Methods included from Services
badge_service, certificate_service, group_service, index_service, label_service, matrix_service, pact_service, pacticipant_service, tag_service, verification_service, version_service, webhook_service
Instance Method Details
#find(criteria, options = {}) ⇒ Object
20
21
22
|
# File 'lib/pact_broker/matrix/service.rb', line 20
def find criteria, options = {}
matrix_repository.find criteria, options
end
|
#find_compatible_pacticipant_versions(criteria) ⇒ Object
48
49
50
|
# File 'lib/pact_broker/matrix/service.rb', line 48
def find_compatible_pacticipant_versions criteria
matrix_repository.find_compatible_pacticipant_versions criteria
end
|
#find_for_consumer_and_provider(params) ⇒ Object
24
25
26
|
# File 'lib/pact_broker/matrix/service.rb', line 24
def find_for_consumer_and_provider params
matrix_repository.find_for_consumer_and_provider params[:consumer_name], params[:provider_name]
end
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/pact_broker/matrix/service.rb', line 28
def find_for_consumer_and_provider_with_tags params
consumer_criteria = {
pacticipant_name: params[:consumer_name],
tag: params[:tag],
latest: true
}
provider_criteria = {
pacticipant_name: params[:provider_name],
tag: params[:provider_tag],
latest: true
}
selectors = [consumer_criteria, provider_criteria]
options = { latestby: 'cvpv' }
if validate_selectors(selectors).empty?
matrix_repository.find(selectors, options).first
else
nil
end
end
|
#refresh(params, &block) ⇒ Object
12
13
14
|
# File 'lib/pact_broker/matrix/service.rb', line 12
def refresh params, &block
matrix_repository.refresh(params, &block)
end
|
16
17
18
|
# File 'lib/pact_broker/matrix/service.rb', line 16
def refresh_tags params, &block
matrix_repository.refresh_tags(params, &block)
end
|
#validate_selectors(selectors) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/pact_broker/matrix/service.rb', line 52
def validate_selectors selectors
error_messages = []
selectors.each do | s |
if s[:pacticipant_name].nil?
error_messages << "Please specify the pacticipant name"
else
if s.key?(:pacticipant_version_number) && s.key?(:latest)
error_messages << "A version and latest flag cannot both be specified for #{s[:pacticipant_name]}"
end
if s.key?(:tag) && !s.key?(:latest)
error_messages << "Querying for all versions with a tag is not currently supported. The latest=true flag must be specified when a tag is given."
end
end
end
selectors.collect{ |selector| selector[:pacticipant_name] }.compact.each do | pacticipant_name |
unless pacticipant_service.find_pacticipant_by_name(pacticipant_name)
error_messages << "Pacticipant #{pacticipant_name} not found"
end
end
if error_messages.empty?
selectors.each do | s |
if s[:pacticipant_version_number]
version = version_service.find_by_pacticipant_name_and_number(pacticipant_name: s[:pacticipant_name], pacticipant_version_number: s[:pacticipant_version_number])
error_messages << "No pact or verification found for #{s[:pacticipant_name]} version #{s[:pacticipant_version_number]}" if version.nil?
elsif s[:tag]
version = version_service.find_by_pacticpant_name_and_latest_tag(s[:pacticipant_name], s[:tag])
error_messages << "No version of #{s[:pacticipant_name]} found with tag #{s[:tag]}" if version.nil?
end
end
end
if selectors.size == 0
error_messages << "Please provide 1 or more version selectors."
end
error_messages
end
|