Class: PactBroker::Pacts::Selectors
- Inherits:
-
Array
- Object
- Array
- PactBroker::Pacts::Selectors
- Defined in:
- lib/pact_broker/pacts/selectors.rb
Class Method Summary collapse
- .create_for_all_of_each_tag(tag_names) ⇒ Object
- .create_for_latest_for_branch(branch) ⇒ Object
- .create_for_latest_for_tag(tag_name) ⇒ Object
- .create_for_latest_of_each_branch(branches) ⇒ Object
- .create_for_latest_of_each_tag(tag_names) ⇒ Object
- .create_for_overall_latest ⇒ Object
Instance Method Summary collapse
- #+(other) ⇒ Object
- #branches_of_selectors_for_latest_pacts ⇒ Object
-
#initialize(*selectors) ⇒ Selectors
constructor
A new instance of Selectors.
- #latest_for_tag?(potential_tag = nil) ⇒ Boolean
- #overall_latest? ⇒ Boolean
- #resolve(consumer_version) ⇒ Object
- #resolve_for_environment(consumer_version, environment) ⇒ Object
- #sort ⇒ Object
- #tag_names_of_selectors_for_all_pacts ⇒ Object
- #tag_names_of_selectors_for_latest_pacts ⇒ Object
Constructor Details
#initialize(*selectors) ⇒ Selectors
Returns a new instance of Selectors.
6 7 8 |
# File 'lib/pact_broker/pacts/selectors.rb', line 6 def initialize *selectors super([*selectors].flatten) end |
Class Method Details
.create_for_all_of_each_tag(tag_names) ⇒ Object
10 11 12 |
# File 'lib/pact_broker/pacts/selectors.rb', line 10 def self.create_for_all_of_each_tag(tag_names) Selectors.new(tag_names.collect{ | tag_name | Selector.all_for_tag(tag_name) }) end |
.create_for_latest_for_branch(branch) ⇒ Object
26 27 28 |
# File 'lib/pact_broker/pacts/selectors.rb', line 26 def self.create_for_latest_for_branch(branch) Selectors.new([Selector.latest_for_branch(branch)]) end |
.create_for_latest_for_tag(tag_name) ⇒ Object
18 19 20 |
# File 'lib/pact_broker/pacts/selectors.rb', line 18 def self.create_for_latest_for_tag(tag_name) Selectors.new([Selector.latest_for_tag(tag_name)]) end |
.create_for_latest_of_each_branch(branches) ⇒ Object
22 23 24 |
# File 'lib/pact_broker/pacts/selectors.rb', line 22 def self.create_for_latest_of_each_branch(branches) Selectors.new(branches.collect{ | branch | Selector.latest_for_branch(branch) }) end |
.create_for_latest_of_each_tag(tag_names) ⇒ Object
14 15 16 |
# File 'lib/pact_broker/pacts/selectors.rb', line 14 def self.create_for_latest_of_each_tag(tag_names) Selectors.new(tag_names.collect{ | tag_name | Selector.latest_for_tag(tag_name) }) end |
.create_for_overall_latest ⇒ Object
30 31 32 |
# File 'lib/pact_broker/pacts/selectors.rb', line 30 def self.create_for_overall_latest Selectors.new([Selector.overall_latest]) end |
Instance Method Details
#+(other) ⇒ Object
42 43 44 |
# File 'lib/pact_broker/pacts/selectors.rb', line 42 def + other Selectors.new(super) end |
#branches_of_selectors_for_latest_pacts ⇒ Object
66 67 68 |
# File 'lib/pact_broker/pacts/selectors.rb', line 66 def branches_of_selectors_for_latest_pacts select(&:latest_for_branch?).collect(&:branch).uniq end |
#latest_for_tag?(potential_tag = nil) ⇒ Boolean
54 55 56 |
# File 'lib/pact_broker/pacts/selectors.rb', line 54 def latest_for_tag? potential_tag = nil any? { | selector | selector.latest_for_tag?(potential_tag) } end |
#overall_latest? ⇒ Boolean
50 51 52 |
# File 'lib/pact_broker/pacts/selectors.rb', line 50 def overall_latest? any?(&:overall_latest?) end |
#resolve(consumer_version) ⇒ Object
34 35 36 |
# File 'lib/pact_broker/pacts/selectors.rb', line 34 def resolve(consumer_version) Selectors.new(collect{ |selector| selector.resolve(consumer_version) }) end |
#resolve_for_environment(consumer_version, environment) ⇒ Object
38 39 40 |
# File 'lib/pact_broker/pacts/selectors.rb', line 38 def resolve_for_environment(consumer_version, environment) Selectors.new(collect{ |selector| selector.resolve_for_environment(consumer_version, environment) }) end |
#sort ⇒ Object
46 47 48 |
# File 'lib/pact_broker/pacts/selectors.rb', line 46 def sort Selectors.new(super) end |
#tag_names_of_selectors_for_all_pacts ⇒ Object
58 59 60 |
# File 'lib/pact_broker/pacts/selectors.rb', line 58 def tag_names_of_selectors_for_all_pacts select(&:all_for_tag?).collect(&:tag).uniq end |
#tag_names_of_selectors_for_latest_pacts ⇒ Object
62 63 64 |
# File 'lib/pact_broker/pacts/selectors.rb', line 62 def tag_names_of_selectors_for_latest_pacts select(&:latest_for_tag?).collect(&:tag).uniq end |