repo_timetracker 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/repo_timetracker/repo_timeline.rb +17 -17
- data/lib/repo_timetracker/repo_timeline_class.rb +3 -4
- data/lib/repo_timetracker/version.rb +1 -1
- data/lib/repo_timetracker.rb +20 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2be9275c576a355976273807b2fd2aae0680d3da
|
|
4
|
+
data.tar.gz: bed12f1336ed446f55ba3de9a9d8c84a3c2f9730
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32e3472f8ecbd22e20b595f980fb2c2ec854558e1950759d7f6c3bf51817aa1360e1c77968725ff56c5fd8a169ea7f3fcc4bf1a5278452b20078d994640f8ead
|
|
7
|
+
data.tar.gz: 13dba9ed9c8778b185abcea189f13b537fe5dc2681e197c1c2779eb0775b177bb3df8d258834ed1ec94b880f98fd79d04450e62455750fc10e1b9e8c17dfb651
|
|
@@ -11,7 +11,6 @@ class RepoTimeline
|
|
|
11
11
|
|
|
12
12
|
@timeline_directory = initialize_timeline_directory_for(@repo_directory)
|
|
13
13
|
@commit_records = load_commit_records
|
|
14
|
-
watch_for_file_change_events
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
def add_event(event_string)
|
|
@@ -38,6 +37,19 @@ class RepoTimeline
|
|
|
38
37
|
}
|
|
39
38
|
end
|
|
40
39
|
|
|
40
|
+
def watch_for_file_change_events
|
|
41
|
+
if defined? Process.daemon
|
|
42
|
+
kill_previous_commit_timeline_process
|
|
43
|
+
|
|
44
|
+
Process.daemon
|
|
45
|
+
|
|
46
|
+
FileWatcher.new([@repo_directory]).watch do |filename|
|
|
47
|
+
staging.generate_new_event("File changed: #{filename}")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
41
53
|
|
|
42
54
|
private
|
|
43
55
|
|
|
@@ -81,8 +93,9 @@ class RepoTimeline
|
|
|
81
93
|
def initialize_timeline_directory_for(repo_directory)
|
|
82
94
|
timeline_directory = "#{repo_directory}/.repo_timeline"
|
|
83
95
|
gitignore_path = "#{repo_directory}.gitignore"
|
|
84
|
-
|
|
96
|
+
|
|
85
97
|
ensure_gitignored(timeline_directory)
|
|
98
|
+
FileUtils.mkdir_p(timeline_directory) unless File.directory?(timeline_directory)
|
|
86
99
|
|
|
87
100
|
timeline_directory
|
|
88
101
|
end
|
|
@@ -102,22 +115,9 @@ class RepoTimeline
|
|
|
102
115
|
commit_filenames = dir_filenames.select { |f| f.include? '__commit__' }
|
|
103
116
|
commit_filenames.map { |fn| "#{@timeline_directory}/#{fn}" }
|
|
104
117
|
end
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def watch_for_file_change_events
|
|
108
|
-
if defined? Process.daemon
|
|
109
|
-
kill_previous_commit_timeline_process
|
|
110
|
-
|
|
111
|
-
Process.daemon
|
|
112
|
-
|
|
113
|
-
FileWatcher.new([@repo_directory]).watch do |filename|
|
|
114
|
-
staging.generate_new_event("File changed: #{filename}")
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
def kill_previous_commit_timeline_process
|
|
120
|
-
similar_processes = `ps -ax | grep repo_timetracker
|
|
120
|
+
similar_processes = `ps -ax | grep ruby.*repo_timetracker/bin/rpt`.split("\n")
|
|
121
121
|
|
|
122
122
|
if previous_commit_timeline_process = similar_processes.find { |p| not p.include? 'grep' }
|
|
123
123
|
previous_commit_timeline_pid = previous_commit_timeline_process.match(/\d+/)[0]
|
|
@@ -2,15 +2,14 @@ class RepoTimeline
|
|
|
2
2
|
class << self
|
|
3
3
|
|
|
4
4
|
def load_or_initialize_for(directory_called_from)
|
|
5
|
-
directory = find_in_or_above(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return 'No repo found.' if directory.nil?
|
|
5
|
+
directory = find_in_or_above(directory_called_from)
|
|
6
|
+
return nil if directory.nil?
|
|
9
7
|
|
|
10
8
|
RepoTimeline.new(directory)
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
def find_in_or_above(directory)
|
|
12
|
+
return nil if directory.nil?
|
|
14
13
|
|
|
15
14
|
if contains_repo? directory
|
|
16
15
|
directory
|
data/lib/repo_timetracker.rb
CHANGED
|
@@ -5,23 +5,35 @@ module RepoTimetracker
|
|
|
5
5
|
class << self
|
|
6
6
|
def record(event_string, directory)
|
|
7
7
|
repo_timeline = RepoTimeline.load_or_initialize_for(directory)
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
if repo_timeline.nil?
|
|
10
|
+
'Error: no repo found.'
|
|
11
|
+
else
|
|
12
|
+
repo_timeline.add_event(event_string)
|
|
13
|
+
repo_timeline.watch_for_file_change_events
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
16
|
|
|
11
17
|
def current_commit_time(directory)
|
|
12
18
|
repo_timeline = RepoTimeline.load_or_initialize_for(directory)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
|
|
20
|
+
if repo_timeline.nil?
|
|
21
|
+
'Error: no repo found.'
|
|
22
|
+
else
|
|
23
|
+
time = repo_timeline.current_commit_time
|
|
24
|
+
Time.at(time).utc.strftime("%H:%M:%S")
|
|
25
|
+
end
|
|
17
26
|
end
|
|
18
27
|
|
|
19
28
|
def project_time(directory)
|
|
20
29
|
repo_timeline = RepoTimeline.load_or_initialize_for(directory)
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
if repo_timeline.nil?
|
|
32
|
+
'Error: no repo found.'
|
|
33
|
+
else
|
|
34
|
+
time = repo_timeline.project_time
|
|
35
|
+
Time.at(time).utc.strftime("%H:%M:%S")
|
|
36
|
+
end
|
|
25
37
|
end
|
|
26
38
|
end
|
|
27
39
|
end
|