Sha256: 2849ef29f01112158df1046b5ee0040b5504add1345d20eca5ebe1a0e5bc1613
Contents?: true
Size: 984 Bytes
Versions: 5
Compression:
Stored size: 984 Bytes
Contents
require 'terminal-table' class Herodot::Table HEADERS = %w(Project Branch Time).freeze class << self def format_time(time_is_seconds) total_seconds = time_is_seconds.to_i seconds = total_seconds % 60 minutes = (total_seconds / 60) % 60 hours = total_seconds / (60 * 60) "#{hours}:#{minutes.to_s.rjust(2, '0')}:#{seconds.to_s.rjust(2, '0')}" end def print(worklogs_totals_per_day) Terminal::Table.new(headings: HEADERS) do |table| worklogs_totals_per_day.each do |date, times| table.add_separator table << [date] table.add_separator print_day(times).each { |row| table << row } table.add_separator end end end private def print_day(times) times.values.group_by { |log| log[:project] }.flat_map do |_, logs| logs.map do |log| [log[:project], log[:branch], format_time(log[:time])] end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
herodot-0.1.5 | lib/herodot/table.rb |
herodot-0.1.4 | lib/herodot/table.rb |
herodot-0.1.3 | lib/herodot/table.rb |
herodot-0.1.2 | lib/herodot/table.rb |
herodot-0.1.0 | lib/herodot/table.rb |