class CountVonCount::Formatters::Text
Public Instance Methods
build_table(name, countObj)
click to toggle source
# 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()
click to toggle source
# File lib/count_von_count/formatter.rb, line 43 def extension "txt" end
serialize(countObj)
click to toggle source
# 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