Class: Spoom::Timeline
- Inherits:
-
Object
- Object
- Spoom::Timeline
- Defined in:
- lib/spoom/timeline.rb
Instance Method Summary collapse
- #commits_for_dates(dates) ⇒ Object
-
#initialize(context, from, to) ⇒ Timeline
constructor
: (Context context, Time from, Time to) -> void.
-
#months ⇒ Object
Return all months between ‘from` and `to` : -> Array.
-
#ticks ⇒ Object
Return one commit for each month between ‘from` and `to` : -> Array.
Constructor Details
#initialize(context, from, to) ⇒ Timeline
: (Context context, Time from, Time to) -> void
7 8 9 10 11 |
# File 'lib/spoom/timeline.rb', line 7 def initialize(context, from, to) @context = context @from = from @to = to end |
Instance Method Details
#commits_for_dates(dates) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/spoom/timeline.rb', line 34 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
Return all months between ‘from` and `to` : -> Array
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spoom/timeline.rb', line 21 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
Return one commit for each month between ‘from` and `to` : -> Array
15 16 17 |
# File 'lib/spoom/timeline.rb', line 15 def ticks commits_for_dates(months) end |