Sha256: 24993d2af8b1c55585db91958eb05f27eb396fce75d74095088b385e8c53284b
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require 'terminal-table' module Swoop class TableRenderer < Renderer def render puts table end private def f(lines) return lines if lines < 1_000 count_in_thousand = Integer(Float(lines) / Float(1_000)) "#{count_in_thousand}K" end def table headings = [ "name", "date", "swift\nfiles (%)", "objc\nfiles (%)", "swift\nlines (%)", "objc\nlines (%)", "swift\nclass (%)", "objc\nclass (%)", "swift\nstruct(%)", "objc\nstruct(%)", "swift\next(%)", "objc\next(%)" ] rows = reports.map do |r| [r.name,r.date, "#{'%.02f' % r.swift_files_percentage} (#{f r.swift_files_count}/#{f r.files_count})", "#{'%.02f' % r.objc_files_percentage} (#{f r.objc_files_count}/#{f r.files_count})", "#{'%.02f' % r.swift_lines_percentage} (#{f r.swift_lines_count}/#{f r.lines_count})", "#{'%.02f' % r.objc_lines_percentage} (#{f r.objc_lines_count}/#{f r.lines_count})", "#{'%.02f' % r.swift_classes_percentage} (#{r.swift_classes_count}/#{r.classes_count})", "#{'%.02f' % r.objc_classes_percentage} (#{r.objc_classes_count}/#{r.classes_count})", "#{'%.02f' % r.swift_structs_percentage} (#{r.swift_structs_count}/#{r.structs_count})", "#{'%.02f' % r.objc_structs_percentage} (#{r.objc_structs_count}/#{r.structs_count})", "#{'%.02f' % r.swift_extensions_percentage} (#{r.swift_extensions_count}/#{r.extensions_count})", "#{'%.02f' % r.objc_extensions_percentage} (#{r.objc_extensions_count}/#{r.extensions_count})", ] end @table ||= Terminal::Table.new(:title => title, :headings => headings, :rows => rows) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
swoop_report-0.3.1 | lib/swoop/renderer/table_renderer.rb |