Sha256: 239baabd8ae8bdce54bf951d8a7fc176e691b70e9dfd6f624e6cd4c454db6876

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

module PactBroker
  module UI
    module Helpers
      module MatrixHelper

        extend self

        # rubocop: disable Metrics/CyclomaticComplexity
        def create_selector_objects(selector_hashes)
          selector_hashes.collect do | selector_hash |
            o = OpenStruct.new(selector_hash)
            o.specify_latest_tag = (o.tag && o.latest) ? "checked" : nil
            o.specify_latest_branch = (o.branch && o.latest) ? "checked" : nil
            o.specify_environment = o.environment_name ? "checked" : nil
            o.specify_all_tagged = (o.tag && !o.latest) ? "checked" : nil
            o.specify_latest = o.latest ? "checked" : nil
            o.specify_version = o.pacticipant_version_number ? "checked" : nil
            o.specify_all_versions = !(o.tag || o.pacticipant_version_number || o.branch) ? "checked" : nil
            o
          end
        end

        def create_options_model(options)
          o = OpenStruct.new(options)
          o.cvpv_checked = o.latestby == "cvpv" ? "checked" : nil
          o.cvp_checked = o.latestby == "cvp" ? "checked" : nil
          o.all_rows_checked = o.latestby.nil? ? "checked" : nil
          o
        end

        def matrix_badge_url(selectors, lines, base_url)
          if lines.any? && selectors.size == 2 && selectors.all?{ | selector| selector.latest_for_pacticipant_and_tag? }
            consumer_selector = selectors.find{ | selector| selector.pacticipant_name == lines.first.consumer_name }
            provider_selector = selectors.find{ | selector| selector.pacticipant_name == lines.first.provider_name }
            if consumer_selector && provider_selector
              PactBroker::Api::PactBrokerUrls.matrix_badge_url_for_selectors(consumer_selector, provider_selector, base_url)
            end
          end
        end
        # rubocop: enable Metrics/CyclomaticComplexity
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-2.80.0 lib/pact_broker/ui/helpers/matrix_helper.rb