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.42.1 lib/pact/provider/print_missing_provider_states.rb
pact-1.42.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.41.2 lib/pact/provider/print_missing_provider_states.rb
pact-1.41.1 lib/pact/provider/print_missing_provider_states.rb
pact-1.41.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.40.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.39.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.38.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.37.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.36.2 lib/pact/provider/print_missing_provider_states.rb
pact-1.36.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.34.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.33.2 lib/pact/provider/print_missing_provider_states.rb
pact-1.33.1 lib/pact/provider/print_missing_provider_states.rb
pact-1.33.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.32.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.31.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.30.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.29.0 lib/pact/provider/print_missing_provider_states.rb
pact-1.28.0 lib/pact/provider/print_missing_provider_states.rb