Module: RepoTimetracker

Defined in:
lib/repo_timetracker.rb,
lib/repo_timetracker/version.rb

Constant Summary collapse

VERSION =
"1.0.3"

Class Method Summary collapse

Class Method Details

.current_commit_time(directory) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/repo_timetracker.rb', line 17

def current_commit_time(directory)
  repo_timeline = RepoTimeline.load_or_initialize_for(directory)
  
  if repo_timeline.nil?
    'Error: no repo found.'
  else
    time = repo_timeline.current_commit_time
    Time.at(time).utc.strftime("%H:%M:%S")
  end
end

.project_time(directory) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/repo_timetracker.rb', line 28

def project_time(directory)
  repo_timeline = RepoTimeline.load_or_initialize_for(directory)

  if repo_timeline.nil?
    'Error: no repo found.'
  else
    time = repo_timeline.project_time
    Time.at(time).utc.strftime("%H:%M:%S")
  end
end

.record(event_string, directory) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/repo_timetracker.rb', line 6

def record(event_string, directory)
  repo_timeline = RepoTimeline.load_or_initialize_for(directory)

  if repo_timeline.nil?
    'Error: no repo found.'
  else
    repo_timeline.add_event(event_string)
    repo_timeline.watch_for_file_change_events
  end
end