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(context, from, to) ⇒ Timeline
constructor
A new instance of Timeline.
- #months ⇒ Object
- #ticks ⇒ Object
Constructor Details
#initialize(context, from, to) ⇒ Timeline
Returns a new instance of Timeline.
9 10 11 12 13 |
# File 'lib/spoom/timeline.rb', line 9 def initialize(context, from, to) @context = context @from = from @to = to end |
Instance Method Details
#commits_for_dates(dates) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/spoom/timeline.rb', line 36 def commits_for_dates(dates) dates.map do |t| result = @context.git_log( "--since='#{t}'", "--until='#{t.to_date.next_month}'", "--format='format:%h %at'", "--author-date-order", "-1", ) next if result.out.empty? Spoom::Git::Commit.parse_line(result.out.strip) end.compact.uniq(&:sha) end |
#months ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spoom/timeline.rb', line 23 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
17 18 19 |
# File 'lib/spoom/timeline.rb', line 17 def ticks commits_for_dates(months) end |