class TXTFormatter
TXTFormatter
class
Public Class Methods
new(report, color=false)
click to toggle source
Calls superclass method
ArrayFormatter::new
# File lib/teuton/report/formatter/txt_formatter.rb, line 9 def initialize(report, color=false) @color = color super(report) @data = {} end
Public Instance Methods
process()
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 15 def process rainbow_state = Rainbow.enabled Rainbow.enabled = @color build_data process_config process_logs process_groups process_results process_hof deinit Rainbow.enabled = rainbow_state end
Private Instance Methods
process_config()
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 32 def process_config w "#{Rainbow("CONFIGURATION").bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| @data[:config].sort.each { |key,value| st.add_row [ key.to_s, value.to_s] } end w my_screen_table.to_s+"\n\n" end
process_group(group)
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 86 def process_group(group) tab = ' ' w "- #{Rainbow(group[:title]).blue.bright}\n" group[:targets].each do |i| color = :red color = :green if i[:check] w tab*2 + format("%02d", i[:target_id].to_i) w " (#{Rainbow(i[:score].to_s+"/"+i[:weight].to_s).color(color)})\n" w tab*4+"Description : #{i[:description].to_s}\n" w tab*4+"Command : #{i[:command].to_s}\n" w tab*4+"Duration : #{i[:duration].to_s} (#{i[:conn_type].to_s})\n" w tab*4+"Alterations : #{i[:alterations].to_s}\n" w tab*4+"Expected : #{i[:expected].to_s} (#{i[:expected].class.to_s})\n" w tab*4+"Result : #{i[:result].to_s} (#{i[:result].class.to_s})\n" end end
process_groups()
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 47 def process_groups return if @data[:groups].size == 0 w "\n#{Rainbow("GROUPS").bg(:blue)}\n" @data[:groups].each { |g| process_group g } end
process_hof()
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 64 def process_hof return if @data[:hall_of_fame].size < 3 w "\n#{Rainbow("HALL OF FAME").bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| @data[:hall_of_fame].each do |line| mycolor = :green mycolor = :red if line[0] < 50 text1 = Rainbow(line[0]).color(mycolor) text2 = Rainbow(line[1]).color(mycolor) if line[0] == @data[:results][:grade] text1 = text1.bright text2 = text2.bright end st.add_row [text1, text2] end end w my_screen_table.to_s + "\n" end
process_logs()
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 40 def process_logs return if @data[:logs].size == 0 w "#{Rainbow("LOGS").bg(:blue)}\n" @data[:logs].each { |line| w " #{line}\n" } end
process_results()
click to toggle source
# File lib/teuton/report/formatter/txt_formatter.rb, line 54 def process_results w "\n#{Rainbow("RESULTS").bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| @data[:results].each do |key,value| st.add_row [ key.to_s, value.to_s] end end w my_screen_table.to_s+"\n" end