one_inch_punch 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/punch.rb +1 -0
- data/lib/punch/version.rb +1 -1
- data/spec/punch_spec.rb +23 -1
- metadata +2 -2
data/History.txt
CHANGED
data/lib/punch.rb
CHANGED
@@ -154,6 +154,7 @@ class Punch
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def do_total_time(list_data, options)
|
157
|
+
return nil unless list_data
|
157
158
|
total = list_data.collect { |t| ((t['out'] || Time.now) - t['in']).to_i }.inject(0) { |sum, t| sum + t }
|
158
159
|
return total unless options[:format]
|
159
160
|
total.elapsed_time
|
data/lib/punch/version.rb
CHANGED
data/spec/punch_spec.rb
CHANGED
@@ -1145,7 +1145,29 @@ describe Punch do
|
|
1145
1145
|
Punch.total(@projects['parent'], :after => @now - 21).should == total_data
|
1146
1146
|
end
|
1147
1147
|
|
1148
|
-
|
1148
|
+
it 'should handle a non-existent parent project' do
|
1149
|
+
@data.delete(@projects['parent'])
|
1150
|
+
Punch.data = @data
|
1151
|
+
total_data = { @projects['parent'] => nil, @projects['child'] => 10 }
|
1152
|
+
Punch.total(@projects['parent']).should == total_data
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
it 'should handle an empty parent project' do
|
1156
|
+
@data[@projects['parent']] = []
|
1157
|
+
Punch.data = @data
|
1158
|
+
total_data = { @projects['parent'] => 0, @projects['child'] => 10 }
|
1159
|
+
Punch.total(@projects['parent']).should == total_data
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
it 'should handle an empty child project' do
|
1163
|
+
@projects['other_child'] = @projects['parent'] + '/button'
|
1164
|
+
@data[@projects['other_child']] = []
|
1165
|
+
Punch.data = @data
|
1166
|
+
total_data = { @projects['parent'] => 50, @projects['child'] => 10, @projects['other_child'] => 0 }
|
1167
|
+
Punch.total(@projects['parent']).should == total_data
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
describe 'when no project is given' do
|
1149
1171
|
before do
|
1150
1172
|
@extra_projects = ['test project', 'out project', 'other project']
|
1151
1173
|
@data[@extra_projects[0]] = [ {'in' => @now - 50, 'out' => @now - 25} ]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: one_inch_punch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yossef Mendelssohn
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-06 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|