Class: Watson::Formatters::DefaultFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Watson::Formatters::DefaultFormatter
- Defined in:
- lib/watson/formatters/default_formatter.rb
Direct Known Subclasses
Constant Summary
Constants included from Watson
BLUE, BOLD, CYAN, GRAY, GREEN, MAGENTA, RED, RESET, UNDERLINE, VERSION, WHITE, YELLOW
Instance Method Summary collapse
-
#initialize(config) ⇒ DefaultFormatter
constructor
A new instance of DefaultFormatter.
-
#print_header ⇒ Object
Standard header print for class call (uses member cprint).
-
#print_status(msg, color) ⇒ Object
Status printer for member call (uses member cprint) Print status block in standard format.
- #run(structure) ⇒ Object
Methods included from Watson
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
#print_header ⇒ Object
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 |
#print_status(msg, color) ⇒ Object
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 |