rworktracker 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/bin/rworktracker +5 -5
- data/lib/rworktracker.rb +12 -36
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -4,6 +4,11 @@ A simple tool to keep track of the time you spend working on your projects
|
|
4
4
|
|
5
5
|
This is mostly a simple app used to experiment a bit tdd, simple metaprogrammig etc..
|
6
6
|
|
7
|
+
UPDATE:
|
8
|
+
changed the really messy format I've choosen the first time..
|
9
|
+
sorry, no script to port old files to new version is present yet
|
10
|
+
had to change due to a very stupid bug :P
|
11
|
+
|
7
12
|
== How it works
|
8
13
|
|
9
14
|
$ rworktracker help
|
data/bin/rworktracker
CHANGED
@@ -7,12 +7,12 @@ CONFIGFILE = File.join(File.expand_path(ENV['HOME']),'.rworktracker.yaml')
|
|
7
7
|
|
8
8
|
cli = RworkTrackerCli.new(CONFIGFILE)
|
9
9
|
if ARGV[0]
|
10
|
-
begin
|
10
|
+
#begin
|
11
11
|
cli.send ARGV[0]
|
12
|
-
rescue Exception => e
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
#rescue Exception => e
|
13
|
+
# warn "command #{ARGV[0]} is not available"
|
14
|
+
# cli.help
|
15
|
+
#end
|
16
16
|
else
|
17
17
|
cli.projects
|
18
18
|
end
|
data/lib/rworktracker.rb
CHANGED
@@ -1,25 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'time'
|
3
|
-
|
4
|
-
# ugly monkeypatch
|
5
|
-
class Hash
|
6
|
-
def project(pro)
|
7
|
-
self[pro]
|
8
|
-
end
|
9
|
-
|
10
|
-
def month
|
11
|
-
self[Time.now.month] ||= Hash.new
|
12
|
-
end
|
13
|
-
def month= m
|
14
|
-
self[Time.now.month]=m
|
15
|
-
end
|
16
|
-
def day
|
17
|
-
self[Time.now.day] ||= []
|
18
|
-
end
|
19
|
-
def day= d
|
20
|
-
self[Time.now.day]=d
|
21
|
-
end
|
22
|
-
end
|
3
|
+
require 'date'
|
23
4
|
|
24
5
|
class RworkTrackerCli
|
25
6
|
|
@@ -132,6 +113,7 @@ class RworkTracker
|
|
132
113
|
f = false
|
133
114
|
end
|
134
115
|
@wdata = ( f == false) ? Hash.new : f
|
116
|
+
#check_status
|
135
117
|
end
|
136
118
|
|
137
119
|
def writeYaml
|
@@ -145,14 +127,12 @@ class RworkTracker
|
|
145
127
|
end
|
146
128
|
|
147
129
|
def addProject(pro)
|
148
|
-
@wdata[pro] ||=
|
130
|
+
@wdata[pro] ||= []
|
149
131
|
end
|
150
132
|
|
151
133
|
def started?(pro)
|
152
134
|
begin
|
153
|
-
|
154
|
-
ld = @wdata[pro][lm].keys.sort.last
|
155
|
-
if @wdata[pro][lm][ld].last['stop'] == nil
|
135
|
+
if @wdata[pro].last['stop'] == nil
|
156
136
|
return true
|
157
137
|
else
|
158
138
|
return false
|
@@ -164,14 +144,14 @@ class RworkTracker
|
|
164
144
|
|
165
145
|
def start(pro)
|
166
146
|
return false unless @wdata[pro]
|
167
|
-
@wdata[pro]
|
147
|
+
@wdata[pro] << { 'start' => @time.to_s }
|
168
148
|
return true
|
169
149
|
end
|
170
150
|
|
171
151
|
def stop(pro)
|
172
152
|
return false unless @wdata[pro]
|
173
|
-
if @wdata[pro].
|
174
|
-
@wdata[pro].
|
153
|
+
if @wdata[pro].last.has_key?('start') and !@wdata[pro].last.has_key?('stop')
|
154
|
+
@wdata[pro].last.merge!({ 'stop' => @time.to_s })
|
175
155
|
return true
|
176
156
|
else
|
177
157
|
return false
|
@@ -181,15 +161,11 @@ class RworkTracker
|
|
181
161
|
def elapsed(pro)
|
182
162
|
return false unless @wdata[pro]
|
183
163
|
total = 0
|
184
|
-
@wdata[pro].
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
elsif started?(pro)
|
190
|
-
total += Time.now - Time.parse(e['start'])
|
191
|
-
end
|
192
|
-
end
|
164
|
+
@wdata[pro].each do |e|
|
165
|
+
if e['stop']
|
166
|
+
total += Time.parse(e['stop']) - Time.parse(e['start'])
|
167
|
+
elsif started?(pro)
|
168
|
+
total += Time.now - Time.parse(e['start'])
|
193
169
|
end
|
194
170
|
end
|
195
171
|
return total
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rworktracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- ghedamat
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-22 00:00:00 +01:00
|
14
14
|
default_executable: rworktracker
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
93
|
+
hash: -796031187
|
94
94
|
segments:
|
95
95
|
- 0
|
96
96
|
version: "0"
|