Class: CountVonCount::Formatters::Text
- Inherits:
-
Base
- Object
- Base
- CountVonCount::Formatters::Text
show all
- Defined in:
- lib/count_von_count/formatter.rb
Instance Attribute Summary
Attributes inherited from Base
#output_dir, #path
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #write_output
Instance Method Details
#build_table(name, countObj) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/count_von_count/formatter.rb', line 52
def build_table(name, countObj)
head = [""] + countObj[:total].keys.map(&:to_s)
rows = []
rows << ["total"] + countObj[:total].values
rows << :separator
rows << [{value: "By Dir", colspan: 7, align: :center}]
rows << :separator
rows.push *countObj[:by_dir].map{ |d, v| [d] + v.values }
rows << :separator
rows << [{value: "By File", colspan: 7, align: :center}]
rows << :separator
rows.push *countObj[:by_file].map{ |f, v| [f] + v.values }
Terminal::Table.new title: name, headings: head, rows: rows
end
|
#extension ⇒ Object
43
44
45
|
# File 'lib/count_von_count/formatter.rb', line 43
def extension
"txt"
end
|
#serialize(countObj) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/count_von_count/formatter.rb', line 46
def serialize(countObj)
output = build_table("Code", countObj[:code]).to_s
output += "\n\n"
output += build_table("Tests", countObj[:tests]).to_s if countObj[:tests]
output
end
|