class Ghit::Stats::PunchCard

Public Class Methods

get!() click to toggle source
# File lib/ghit/stats/punch_card.rb, line 6
def get!
  new.get
end
new() click to toggle source
# File lib/ghit/stats/punch_card.rb, line 11
def initialize
  @globals = Ghit::Globals.new
  @stats   = Github::Client::Repos::Statistics.new
end

Public Instance Methods

get() click to toggle source
# File lib/ghit/stats/punch_card.rb, line 16
def get
  punch_card_data = fetch_punch_card_data
  commits_by_day = group_data_by_day punch_card_data

  print_hours_line
  commits_by_day.each do |day_ordinal, daily_commits_per_hour|
    print get_weekday day_ordinal
    print_commits_count daily_commits_per_hour
  end
end

Private Instance Methods

fetch_punch_card_data() click to toggle source
# File lib/ghit/stats/punch_card.rb, line 34
def fetch_punch_card_data
  @stats.punch_card(user: @globals.author, repo: @globals.repository).body
end
get_weekday(day) click to toggle source
# File lib/ghit/stats/punch_card.rb, line 48
def get_weekday day
  case day
  when 0
    "Mon\t"
  when 1
    "Tue\t"
  when 2
    "Wed\t"
  when 3
    "Thu\t"
  when 4
    "Fri\t"
  when 5
    "Sat\t"
  when 6
    "Sun\t"
  end
end
group_data_by_day(punch_card_data) click to toggle source
# File lib/ghit/stats/punch_card.rb, line 38
def group_data_by_day punch_card_data
  punch_card_data.group_by {|i| i.first }
end
print_commits_count(commits_group) click to toggle source
print_hours_line() click to toggle source