Method: Gitgo::Repo#timeline

Defined in:
lib/gitgo/repo.rb

#timeline(options = {}) ⇒ Object

Returns an array of shas representing recent documents added.



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/gitgo/repo.rb', line 440

def timeline(options={})
  options = {:n => 10, :offset => 0}.merge(options)
  offset = options[:offset]
  n = options[:n]

  shas = []
  return shas if n <= 0
  
  dates = index.values('date').sort.reverse
  index.each_sha('date', dates) do |sha|
    if block_given?
      next unless yield(sha)
    end
    
    if offset > 0
      offset -= 1
    else
      shas << sha
      break if n && shas.length == n
    end
  end
  
  shas
end