rworktracker 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. data/README.rdoc +2 -0
  2. data/lib/rworktracker.rb +25 -9
  3. metadata +3 -3
data/README.rdoc CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A simple tool to keep track of the time you spend working on your projects
4
4
 
5
+ This is mostly a simple app used to experiment a bit tdd, simple metaprogrammig etc..
6
+
5
7
  == How it works
6
8
 
7
9
  $ rworktracker help
data/lib/rworktracker.rb CHANGED
@@ -1,5 +1,26 @@
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
23
+
3
24
  class RworkTrackerCli
4
25
 
5
26
  def initialize(file)
@@ -89,6 +110,7 @@ class RworkTrackerCli
89
110
  end
90
111
 
91
112
  end
113
+
92
114
  class RworkTracker
93
115
  def initialize(yamlfile = nil)
94
116
  @yamlfile = yamlfile
@@ -136,26 +158,20 @@ class RworkTracker
136
158
  return false
137
159
  end
138
160
  rescue
139
- #warn "Ill formed yaml file"
140
- #exit
141
161
  return false
142
162
  end
143
163
  end
144
164
 
145
165
  def start(pro)
146
166
  return false unless @wdata[pro]
147
- @wdata[pro][@time.month] ||= Hash.new
148
- @wdata[pro][@time.month][@time.day] ||= []
149
- @wdata[pro][@time.month][@time.day] << { 'start' => @time.to_s }
167
+ @wdata[pro].month.day << { 'start' => @time.to_s }
150
168
  return true
151
169
  end
152
170
 
153
171
  def stop(pro)
154
172
  return false unless @wdata[pro]
155
- @wdata[pro][@time.month] ||= Hash.new
156
- @wdata[pro][@time.month][@time.day] ||= []
157
- if @wdata[pro][@time.month][@time.day].last.has_key?('start') and @wdata[pro][@time.month][@time.day].last.has_key?('stop') == false
158
- @wdata[pro][@time.month][@time.day].last.merge!({ 'stop' => @time.to_s })
173
+ if @wdata[pro].month.day.last.has_key?('start') and @wdata[pro].month.day.last.has_key?('stop') == false
174
+ @wdata[pro].month.day.last.merge!({ 'stop' => @time.to_s })
159
175
  return true
160
176
  else
161
177
  return false
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rworktracker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
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-02-17 00:00:00 +01:00
13
+ date: 2011-02-18 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: 12421135
93
+ hash: 596120463
94
94
  segments:
95
95
  - 0
96
96
  version: "0"