class Spoom::Timeline

Public Class Methods

new(from, to, path: ".") click to toggle source
# File lib/spoom/timeline.rb, line 11
def initialize(from, to, path: ".")
  @from = from
  @to = to
  @path = path
end

Public Instance Methods

commits_for_dates(dates) click to toggle source
# File lib/spoom/timeline.rb, line 38
def commits_for_dates(dates)
  dates.map do |t|
    out, _, _ = Spoom::Git.log(
      "--since='#{t}'",
      "--until='#{t.to_date.next_month}'",
      "--format='format:%h'",
      "--author-date-order",
      "-1",
      path: @path,
    )
    next if out.empty?
    out
  end.compact.uniq
end
months() click to toggle source
# File lib/spoom/timeline.rb, line 25
def months
  d = Date.new(@from.year, @from.month, 1)
  to = Date.new(@to.year, @to.month, 1)
  res = [d.to_time]
  while d < to
    d = d.next_month
    res << d.to_time
  end
  res
end
ticks() click to toggle source
# File lib/spoom/timeline.rb, line 19
def ticks
  commits_for_dates(months)
end