class Pact::Provider::Help::ConsoleText

Attributes

options[R]
reports_dir[R]

Public Class Methods

call(reports_dir = Pact.configuration.reports_dir, options = {color: true}) click to toggle source
# File lib/pact/provider/help/console_text.rb, line 12
def self.call reports_dir = Pact.configuration.reports_dir, options = {color: true}
  new(reports_dir || Pact.configuration.reports_dir, options).call
end
new(reports_dir, options) click to toggle source
# File lib/pact/provider/help/console_text.rb, line 16
def initialize reports_dir, options
  @reports_dir = File.expand_path(reports_dir)
  @options = options
end

Public Instance Methods

call() click to toggle source
# File lib/pact/provider/help/console_text.rb, line 21
def call
  begin
    options[:color] ? ColorizeMarkdown.(help_text) : help_text
  rescue Errno::ENOENT
    options[:color] ? error_text_coloured : error_text_plain
  end
end

Private Instance Methods

error_text_coloured() click to toggle source
# File lib/pact/provider/help/console_text.rb, line 46
def error_text_coloured
  Rainbow(error_text_plain).red
end
error_text_plain() click to toggle source
# File lib/pact/provider/help/console_text.rb, line 41
def error_text_plain
  "Sorry, could not find help file at #{help_file_path}. Please ensure you have run `rake pact:verify`.\n" +
   "If this does not fix the problem, please raise a github issues for this bug."
end
help_file_path() click to toggle source
# File lib/pact/provider/help/console_text.rb, line 37
def help_file_path
  File.join(reports_dir, Write::HELP_FILE_NAME)
end
help_text() click to toggle source
# File lib/pact/provider/help/console_text.rb, line 33
def help_text
  File.read(help_file_path)
end