Sha256: 43433a529f2dd60b7567c9faef7ffc9205df113b4a373fbb9563f896caf300e3

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require "rack/utils"
require "pact_broker/matrix/unresolved_selector"

module PactBroker
  module Matrix
    class ParseCanIDeployQuery
      # rubocop: disable Metrics/CyclomaticComplexity
      def self.call params
        selector = PactBroker::Matrix::UnresolvedSelector.new
        options = {
          latestby: "cvp",
          latest: true
        }

        if params[:pacticipant].is_a?(String)
          selector.pacticipant_name = params[:pacticipant]
        end

        if params[:version].is_a?(String)
          selector.pacticipant_version_number = params[:version]
        end

        if params[:to].is_a?(String)
          options[:tag] = params[:to]
        end

        if params[:environment].is_a?(String)
          options[:environment_name] = params[:environment]
        end

        if params[:ignore].is_a?(Array)
          options[:ignore_selectors] = params[:ignore].collect do | pacticipant_name |
            if pacticipant_name.is_a?(String)
              PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: pacticipant_name)
            end
          end.compact
        else
          options[:ignore_selectors] = []
        end

        return [selector], options
      end
      # rubocop: enable Metrics/CyclomaticComplexity
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.81.0 lib/pact_broker/matrix/parse_can_i_deploy_query.rb
pact_broker-2.80.0 lib/pact_broker/matrix/parse_can_i_deploy_query.rb