class Ghit::Stats::CodeFrequency
Public Class Methods
get!()
click to toggle source
# File lib/ghit/stats/code_frequency.rb, line 6 def get! new.get end
new()
click to toggle source
# File lib/ghit/stats/code_frequency.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/code_frequency.rb, line 16 def get code_frequency = fetch_freq_data print_output_heading code_frequency.each do |date, additions, deletions| date = unixtime_to_date date format_and_print_freq_data date, additions, deletions end print_fourty_one_dashes end
Private Instance Methods
fetch_freq_data()
click to toggle source
# File lib/ghit/stats/code_frequency.rb, line 36 def fetch_freq_data @stats.code_frequency(user: @globals.author, repo: @globals.repository).body end
format_and_print_freq_data(date, additions, deletions)
click to toggle source
# File lib/ghit/stats/code_frequency.rb, line 28 def format_and_print_freq_data date, additions, deletions puts "#{date}\t#{Rainbow(additions).green}\t\t#{Rainbow(deletions).red}" end
print_fourty_one_dashes()
click to toggle source
# File lib/ghit/stats/code_frequency.rb, line 45 def print_fourty_one_dashes puts "-" * 41 end
print_output_heading()
click to toggle source
# File lib/ghit/stats/code_frequency.rb, line 40 def print_output_heading puts "From:\t\tAdditions\tDeletions" print_fourty_one_dashes end
unixtime_to_date(timestamp)
click to toggle source
# File lib/ghit/stats/code_frequency.rb, line 32 def unixtime_to_date timestamp DateTime.strptime(timestamp.to_s, "%s").to_date.to_s end