Class: Snuffle::Formatters::Text

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/snuffle/formatters/text.rb

Instance Method Summary collapse

Methods included from Base

#columns, #content, #file_extension, #filename, included, #initialize, #output_path, #path_to_results, #root_path

Instance Method Details

#exportObject



14
15
16
17
18
19
# File 'lib/snuffle/formatters/text.rb', line 14

def export
  table = ::Text::Table.new
  table.head = header
  table.rows = rows
  table.to_s
end

#headerObject



10
11
12
# File 'lib/snuffle/formatters/text.rb', line 10

def header
  columns.map(&:titleize)
end

#rowsObject



21
22
23
24
25
# File 'lib/snuffle/formatters/text.rb', line 21

def rows
  summary.cohorts.group_by{|c| c.values}.map do |cohort|
    [summary.path_to_file, summary.class_name, "#{cohort[0].join(', ')}", cohort[1].map(&:line_numbers).join(", ")]
  end
end