Class: Spoom::Timeline
- Inherits:
-
Object
- Object
- Spoom::Timeline
- Extended by:
- T::Sig
- Defined in:
- lib/spoom/timeline.rb
Instance Method Summary collapse
- #commits_for_dates(dates) ⇒ Object
-
#initialize(from, to, path: ".") ⇒ Timeline
constructor
A new instance of Timeline.
- #months ⇒ Object
- #ticks ⇒ Object
Constructor Details
#initialize(from, to, path: ".") ⇒ Timeline
Returns a new instance of Timeline.
11 12 13 14 15 |
# File 'lib/spoom/timeline.rb', line 11 def initialize(from, to, path: ".") @from = from @to = to @path = path end |
Instance Method Details
#commits_for_dates(dates) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# 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 ⇒ Object
19 20 21 |
# File 'lib/spoom/timeline.rb', line 19 def ticks commits_for_dates(months) end |