Sha256: f71d2707da36d252227374419f8227cbb7fc29ada77efca196185a4dbf5f826a

Contents?: true

Size: 1.06 KB

Versions: 35

Compression:

Stored size: 1.06 KB

Contents

require 'pact_broker/pacts/selector'

module PactBroker
  module Pacts
    class Selectors < Array
      def initialize *selectors
        super([*selectors].flatten)
      end

      def self.create_for_all_of_each_tag(tag_names)
        Selectors.new(tag_names.collect{ | tag_name | Selector.all_for_tag(tag_name) })
      end

      def self.create_for_latest_of_each_tag(tag_names)
        Selectors.new(tag_names.collect{ | tag_name | Selector.latest_for_tag(tag_name) })
      end

      def self.create_for_overall_latest
        Selectors.new([Selector.overall_latest])
      end

      def + other
        Selectors.new(super)
      end

      def overall_latest?
        any?(&:overall_latest?)
      end

      def latest_for_tag? potential_tag = nil
        any? { | selector | selector.latest_for_tag?(potential_tag) }
      end

      def tag_names_of_selectors_for_all_pacts
        select(&:all_for_tag?).collect(&:tag).uniq
      end

      def tag_names_of_selectors_for_latest_pacts
        select(&:latest_for_tag?).collect(&:tag).uniq
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
pact_broker-2.73.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.72.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.71.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.70.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.69.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.68.1 lib/pact_broker/pacts/selectors.rb
pact_broker-2.68.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.67.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.66.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.65.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.64.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.63.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.62.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.61.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.60.1 lib/pact_broker/pacts/selectors.rb
pact_broker-2.60.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.59.2 lib/pact_broker/pacts/selectors.rb
pact_broker-2.59.1 lib/pact_broker/pacts/selectors.rb
pact_broker-2.59.0 lib/pact_broker/pacts/selectors.rb
pact_broker-2.58.3 lib/pact_broker/pacts/selectors.rb