Sha256: 48501055987e028b214ab969327ec62ec11c4bf765fca29a8afcf6373427efee

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require 'terminal-table'

module Swoop

  class TableRenderer < Renderer

    def render
      puts table
    end

    private

    def table
      headings =  ["name", "date", "swift\nclass", "swift\nclass (%)", "objc\nclass", "objc\nclass (%)", "total\nclass", "swift\nstruct", "swift\nstruct(%)", "objc\nstruct", "objc\nstruct(%)", "total\nstruct", "swift\next", "swift\next(%)", "objc\next", "objc\next(%)", "total\next"]
      rows = reports.map do |r|
        [r.name,r.date,r.swift_classes_count,"#{'%.02f' % r.swift_classes_percentage}",r.objc_classes_count,"#{'%.02f' % r.objc_classes_percentage}",r.classes_count,r.swift_structs_count,"#{'%.02f' % r.swift_structs_percentage}",r.objc_structs_count,"#{'%.02f' % r.objc_structs_percentage}",r.structs_count,r.swift_extensions_count,"#{'%.02f' % r.swift_extensions_percentage}",r.objc_extensions_count,"#{'%.02f' % r.objc_extensions_percentage}",r.extensions_count]
      end

      @table ||= Terminal::Table.new(:title => title, :headings => headings, :rows => rows)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
swoop_report-0.3 lib/swoop/renderer/table_renderer.rb
swoop_report-0.2.2 lib/swoop/renderer/table_renderer.rb
swoop_report-0.2.1 lib/swoop/renderer/table_renderer.rb
swoop_report-0.2.0 lib/swoop/renderer/table_renderer.rb