one_inch_punch 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.2.2 2008-12-01
2
+
3
+ * 1 enhancement:
4
+ * Getting list or total for a punched-in project and using the :before option no longer causes an exception
5
+ (thanks to Rick Bradley for finding this problem)
6
+
1
7
  == 0.2.1 2008-11-20
2
8
 
3
9
  * 1 enhancement:
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'] > options[:after] } if options[:after]
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
@@ -2,7 +2,7 @@ class Punch
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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.1
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-11-20 00:00:00 -06:00
12
+ date: 2008-12-01 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency