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 +4 -4
- data/lib/timerage/time_interval.rb +2 -2
- data/lib/timerage/version.rb +1 -1
- data/spec/timerage/time_interval_spec.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91d9b9ff2e0b26e78e0c666e25f0e43ed2d7e63f
|
4
|
+
data.tar.gz: 41b7873004e11a260af8280958e0353647473681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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|
|
data/lib/timerage/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|