Sha256: 4d0755dd27579132ccd1787f1832b6abac06a1d60b87106c6c67500034c0d155

Contents?: true

Size: 969 Bytes

Versions: 98

Compression:

Stored size: 969 Bytes

Contents

require 'term/ansicolor'

module Pact
  module Provider
    class PrintMissingProviderStates

      C = ::Term::ANSIColor

      # Hash of consumer names to array of names of missing provider states
      def self.call missing_provider_states, output
        if missing_provider_states.any?
          output.puts colorize(text(missing_provider_states))
        end
      end

      def self.colorize string
        lines = string.split("\n")
        first_line = C.cyan(C.underline(lines[0]))
        other_lines = C.cyan(lines[1..-1].join("\n"))
        first_line + "\n" + other_lines
      end

      def self.text missing_provider_states
        create_provider_states_for(missing_provider_states)
      end

      def self.create_provider_states_for consumers
        ERB.new(template_string).result(binding)
      end

      def self.template_string
        File.read(File.expand_path( '../../templates/provider_state.erb', __FILE__))
      end

    end
  end
end

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
pact-1.65.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.64.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.63.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.62.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.61.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.60.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.59.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.58.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.57.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.56.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.7 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.6 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.5 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.4 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.3 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.2 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.1 lib/pact/provider/print_missing_provider_states.rb
pact-1.55.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.54.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.53.0 lib/pact/provider/print_missing_provider_states.rb