timerage 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0365b44846200c067bdec2f0f12e0c37f6619896
4
- data.tar.gz: 6c2b0ea9a6fe86a7f163914ab1b4b4879c21f0dd
3
+ metadata.gz: 91d9b9ff2e0b26e78e0c666e25f0e43ed2d7e63f
4
+ data.tar.gz: 41b7873004e11a260af8280958e0353647473681
5
5
  SHA512:
6
- metadata.gz: 73b6ee091ef7fc1994aa0436b277daaada95ed0f1f07360e4c3eda3da8311ff0005661534993dfdf614b1a86441a47fac41f824d81c1537c085c57c0cc8de0a2
7
- data.tar.gz: be398eac47d357eba8e1aa05c584aa872924fb639bf462745db0f6a6f19a014ca9e1549904cb9cdaa8f9ac1d33060464f699eae3c8e634535f503fa96f59ba24
6
+ metadata.gz: 842c1c4c4c6b4172de92d1f77d10a79f487596bd4334088dc239d8afefad62cacc82b2ad361de1cd69b3c0bd710691ccb19574ae4319a62919ecfa9bacab16a0
7
+ data.tar.gz: d3b1a9f064a1d73ddb4ea54fe10b9fd1f31f2fffa965206f5bccc60fa053e7103b62ce6f8a0f913faecbce2b0d0e307b6435571d49b0ecceacf53ad74cb50a72
@@ -41,8 +41,8 @@ module Timerage
41
41
  # that adding a duration times a number to a time results in
42
42
  # Timely incorrect results. So we do it the hard way.
43
43
  def time_enumerator(step)
44
- count = (self.end - self.begin).div(step)
45
- count += 1 if !exclude_end? and (self.end - self.begin) % step == 0
44
+ count = (self.end - self.begin).div(step) + 1
45
+ count -= 1 if exclude_end? and (self.end - self.begin) % step == 0
46
46
  # We've included our end if it should be
47
47
 
48
48
  Enumerator.new do |y|
@@ -1,3 +1,3 @@
1
1
  module Timerage
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -1,6 +1,9 @@
1
1
  require_relative "../spec_helper"
2
2
 
3
3
  describe Timerage::TimeInterval do
4
+ let(:now) { Time.now }
5
+ let(:duration) { 3600 }
6
+
4
7
  describe "creation" do
5
8
  specify { expect(described_class.new(now-1..now)).to be_kind_of described_class }
6
9
  specify { expect(described_class.new(now-1, now)).to be_kind_of described_class }
@@ -30,6 +33,10 @@ describe Timerage::TimeInterval do
30
33
  specify { expect{|b| interval.step(1200, &b) }
31
34
  .to yield_successive_args now-duration, now-(duration-1200), now-(duration-2400), now }
32
35
 
36
+ context "duration of non-integer steps" do
37
+ specify { expect{|b| interval.step(1000, &b) }
38
+ .to yield_successive_args now-duration, now-(duration-1000), now-(duration-2000), now-(duration-3000) }
39
+ end
33
40
  end
34
41
 
35
42
  context "interval exclude end" do
@@ -47,9 +54,6 @@ describe Timerage::TimeInterval do
47
54
 
48
55
  end
49
56
 
50
- let(:now) { Time.now }
51
- let(:duration) { 3600 }
52
-
53
57
  matcher :behave_like_a do |expected|
54
58
  match do |actual|
55
59
  Set[*expected.instance_methods].subset? Set[*actual.methods]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timerage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Williams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-08 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler