one_inch_punch 0.2.1 → 0.2.2
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.
- data/History.txt +6 -0
- data/lib/punch.rb +2 -2
- data/lib/punch/version.rb +1 -1
- data/spec/punch_spec.rb +31 -0
- metadata +2 -2
data/History.txt
CHANGED
data/lib/punch.rb
CHANGED
@@ -125,8 +125,8 @@ class Punch
|
|
125
125
|
|
126
126
|
def do_list_single(project, options)
|
127
127
|
return nil unless project_data = data[project]
|
128
|
-
project_data = project_data.select { |t| t['in']
|
129
|
-
project_data = project_data.select { |t| t['out'] < options[:before] } if options[:before]
|
128
|
+
project_data = project_data.select { |t| t['in'] > options[:after] } if options[:after]
|
129
|
+
project_data = project_data.select { |t| (t['out'] || Time.now) < options[:before] } if options[:before]
|
130
130
|
project_data
|
131
131
|
end
|
132
132
|
|
data/lib/punch/version.rb
CHANGED
data/spec/punch_spec.rb
CHANGED
@@ -700,6 +700,25 @@ describe Punch do
|
|
700
700
|
it 'should restrict returned data to times only within a time range' do
|
701
701
|
Punch.list(@project, :after => @now - 2001, :before => @now - 999).should == Punch.data[@project][1, 1]
|
702
702
|
end
|
703
|
+
|
704
|
+
describe 'and is punched in' do
|
705
|
+
before :each do
|
706
|
+
@data[@project].push({ 'in' => @now - 25 })
|
707
|
+
Punch.data = @data
|
708
|
+
end
|
709
|
+
|
710
|
+
it 'should restrict returned data to times only after a certain time' do
|
711
|
+
Punch.list(@project, :after => @now - 501).should == Punch.data[@project].last(2)
|
712
|
+
end
|
713
|
+
|
714
|
+
it 'should restrict returned data to times only before a certain time' do
|
715
|
+
Punch.list(@project, :before => @now - 2499).should == Punch.data[@project].first(1)
|
716
|
+
end
|
717
|
+
|
718
|
+
it 'should restrict returned data to times only within a time range' do
|
719
|
+
Punch.list(@project, :after => @now - 2001, :before => @now - 999).should == Punch.data[@project][1, 1]
|
720
|
+
end
|
721
|
+
end
|
703
722
|
end
|
704
723
|
|
705
724
|
describe 'when the project does not exist' do
|
@@ -804,6 +823,18 @@ describe Punch do
|
|
804
823
|
it 'give the time spent until now' do
|
805
824
|
Punch.total(@project).should == 3925
|
806
825
|
end
|
826
|
+
|
827
|
+
it 'should restrict returned amount to times only after a certain time' do
|
828
|
+
Punch.total(@project, :after => @now - 501).should == 425
|
829
|
+
end
|
830
|
+
|
831
|
+
it 'should restrict returned amount to times only before a certain time' do
|
832
|
+
Punch.total(@project, :before => @now - 2499).should == 2500
|
833
|
+
end
|
834
|
+
|
835
|
+
it 'should restrict returned amount to times only within a time range' do
|
836
|
+
Punch.total(@project, :after => @now - 2001, :before => @now - 999).should == 1000
|
837
|
+
end
|
807
838
|
end
|
808
839
|
end
|
809
840
|
|
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.2.
|
4
|
+
version: 0.2.2
|
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: 2008-
|
12
|
+
date: 2008-12-01 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|