class Pact::Provider::Help::Write

Constants

HELP_FILE_NAME

Attributes

pact_sources[R]
reports_dir[R]

Public Class Methods

call(pact_sources, reports_dir = Pact.configuration.reports_dir) click to toggle source
# File lib/pact/provider/help/write.rb, line 12
def self.call pact_sources, reports_dir = Pact.configuration.reports_dir
  new(pact_sources, reports_dir).call
end
new(pact_sources, reports_dir) click to toggle source
# File lib/pact/provider/help/write.rb, line 16
def initialize pact_sources, reports_dir
  @pact_sources = pact_sources
  @reports_dir = File.expand_path(reports_dir)
end

Public Instance Methods

call() click to toggle source
# File lib/pact/provider/help/write.rb, line 21
def call
  clean_reports_dir
  write
rescue StandardError => e
  Pact.configuration.error_stream.puts("ERROR: Error generating help output - #{e.class} #{e.message} \n" + e.backtrace.join("\n"))
end

Private Instance Methods

clean_reports_dir() click to toggle source
# File lib/pact/provider/help/write.rb, line 32
def clean_reports_dir
  raise "Cleaning report dir #{reports_dir} would delete project!" if reports_dir_contains_pwd
  FileUtils.rm_rf reports_dir
  FileUtils.mkdir_p reports_dir
end
help_path() click to toggle source
# File lib/pact/provider/help/write.rb, line 46
def help_path
  File.join(reports_dir, 'help.md')
end
help_text() click to toggle source
# File lib/pact/provider/help/write.rb, line 50
def help_text
  Content.new(pact_sources).text
end
reports_dir_contains_pwd() click to toggle source
# File lib/pact/provider/help/write.rb, line 38
def reports_dir_contains_pwd
  Dir.pwd.start_with?(reports_dir)
end
write() click to toggle source
# File lib/pact/provider/help/write.rb, line 42
def write
  File.open(help_path, "w") { |file| file << help_text }
end