Sha256: 1b79ee51bbcf2dea0439f97774a4cf12624ccf4d0631d97863bbc7c60817a866

Contents?: true

Size: 1.19 KB

Versions: 98

Compression:

Stored size: 1.19 KB

Contents

require 'pact/consumer/configuration'
require 'term/ansicolor'
require 'pathname'

module Pact
  module Provider
    module Help
      class PromptText

        C = ::Term::ANSIColor

        def self.call reports_dir = Pact.configuration.reports_dir, options = {color: Pact.configuration.color_enabled}
          new(reports_dir, options).call
        end

        def initialize reports_dir, options
          @reports_dir = File.expand_path(reports_dir)
          @options = options
        end

        def call
          options[:color] ? prompt_text_colored : prompt_text_plain
        end

        private

        attr_reader :reports_dir, :options

        def prompt_text_plain
          "For assistance debugging failures, run `bundle exec rake pact:verify:help#{rake_args}`\n"
        end

        def prompt_text_colored
          C.yellow(prompt_text_plain)
        end

        def rake_args
          if reports_dir == Pact.configuration.default_reports_dir
            ''
          else
            "[#{relative_reports_dir}]"
          end
        end

        def relative_reports_dir
          Pathname.new(reports_dir).relative_path_from(Pathname.new(Dir.pwd))
        end
      end
    end
  end
end

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
pact-1.28.0.rc1 lib/pact/provider/help/prompt_text.rb
pact-1.27.0 lib/pact/provider/help/prompt_text.rb
pact-1.26.0 lib/pact/provider/help/prompt_text.rb
pact-1.25.0 lib/pact/provider/help/prompt_text.rb
pact-1.24.0 lib/pact/provider/help/prompt_text.rb
pact-1.23.0 lib/pact/provider/help/prompt_text.rb
pact-1.22.2 lib/pact/provider/help/prompt_text.rb
pact-1.22.0 lib/pact/provider/help/prompt_text.rb
pact-1.21.0 lib/pact/provider/help/prompt_text.rb
pact-1.20.1 lib/pact/provider/help/prompt_text.rb
pact-1.20.0 lib/pact/provider/help/prompt_text.rb
pact-1.19.2 lib/pact/provider/help/prompt_text.rb
pact-1.19.1 lib/pact/provider/help/prompt_text.rb
pact-1.19.0 lib/pact/provider/help/prompt_text.rb
pact-1.18.0 lib/pact/provider/help/prompt_text.rb
pact-1.17.0 lib/pact/provider/help/prompt_text.rb
pact-1.16.1 lib/pact/provider/help/prompt_text.rb
pact-1.16.0 lib/pact/provider/help/prompt_text.rb
pact-1.15.0 lib/pact/provider/help/prompt_text.rb
pact-1.14.0 lib/pact/provider/help/prompt_text.rb