Class: Watson::Formatters::DefaultFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/watson/formatters/default_formatter.rb

Direct Known Subclasses

SilentFormatter

Constant Summary

Constants included from Watson

BLUE, BOLD, CYAN, GRAY, GREEN, MAGENTA, RED, RESET, UNDERLINE, VERSION, WHITE, YELLOW

Instance Method Summary collapse

Methods included from Watson

check_less, debug_print

Constructor Details

#initialize(config) ⇒ DefaultFormatter

Returns a new instance of DefaultFormatter.



3
4
5
6
7
# File 'lib/watson/formatters/default_formatter.rb', line 3

def initialize(config)
  super

  @output = STDOUT
end

Instance Method Details

Standard header print for class call (uses member cprint)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/watson/formatters/default_formatter.rb', line 29

def print_header
  # Identify method entry
  debug_print "#{ self } : #{ __method__ }\n"

  # Header
  cprint <<-MESSAGE.gsub(/^(\s+)/, '')
  #{BOLD}------------------------------#{RESET}
  #{BOLD}watson#{RESET} - #{RESET}#{BOLD}#{YELLOW}inline issue manager\n#{RESET}

  Run in: #{Dir.pwd}
  Run @ #{Time.now.asctime}
  #{BOLD}------------------------------\n#{RESET}
  MESSAGE
end

Status printer for member call (uses member cprint) Print status block in standard format



47
48
49
50
51
# File 'lib/watson/formatters/default_formatter.rb', line 47

def print_status(msg, color)
  cprint "#{RESET}#{BOLD}#{WHITE}[ "
  cprint "#{msg} ", color
  cprint "#{WHITE}] #{RESET}"
end

#run(structure) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/watson/formatters/default_formatter.rb', line 9

def run(structure)
  debug_print "#{self} : #{__method__}\n"

  output_result do
    # Check Config to see if we have access to less for printing
    # If so, open our temp file as the output to write to
    # Else, just print out to STDOUT
    # Print header for output
    debug_print "Printing Header\n"

    print_header

    # Print out structure that was passed to this Printer
    debug_print "Starting structure printing\n"
    print_structure(structure)
  end
end