Class: Aardi::Timekeeper

Inherits:
Object
  • Object
show all
Defined in:
lib/aardi/timekeeper.rb

Instance Method Summary collapse

Constructor Details

#initializeTimekeeper

Returns a new instance of Timekeeper.



7
8
9
10
11
12
13
# File 'lib/aardi/timekeeper.rb', line 7

def initialize
  repo = Git.open(Dir.pwd)
  @commit_log = repo.log(:all).all
  @files = repo.ls_files.keys.sort_by { |file| File.mtime(file) }.reverse!
  @updated = 0
  @prior_summary_length = 0
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
# File 'lib/aardi/timekeeper.rb', line 15

def run
  @files.each_with_index do |path, index|
    @prior_summary_length = print_progress(index, path)
    commit_date = author_date(path)
    next unless commit_date

    @updated += 1 if fix_mtime?(path, commit_date)
  end
end