time-iterator 0.1.0 → 0.1.1

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.
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ rvm: [ 1.9.2, 1.9.3, 2.0.0 ]
data/Gemfile CHANGED
@@ -1,4 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+
4
+ group :test do
5
+ gem 'coveralls', :require => false
6
+ gem 'simplecov', :require => false
7
+ end
8
+
3
9
  # Specify your gem's dependencies in time_iterator.gemspec
4
10
  gemspec
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.1.1 (2013-05-18)
2
+
3
+ * Fix high to low iteration.
4
+
5
+
1
6
  ### 0.1.0 (2013-05-17)
2
7
 
3
8
  * Initial release.
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # TimeIterator
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/time-iterator.png)](http://badge.fury.io/rb/time-iterator)
4
+ [![Build Status](https://secure.travis-ci.org/vid-io/time-iterator.png)](http://travis-ci.org/vid-io/time-iterator)
5
+ [![Dependency Status](https://gemnasium.com/vid-io/time-iterator.png)](https://gemnasium.com/vid-io/time-iterator)
6
+ [![Code Climate](https://codeclimate.com/github/vid-io/time-iterator.png)](https://codeclimate.com/github/vid-io/time-iterator)
7
+ [![Coverage Status](https://coveralls.io/repos/vid-io/time-iterator/badge.png)](https://coveralls.io/r/vid-io/time-iterator)
8
+
9
+
3
10
  Utility class to iterate through times with a given step size.
4
11
 
5
12
 
@@ -32,17 +32,15 @@ class TimeIterator
32
32
  # @yield [time]
33
33
  # @return [TimeIterator]
34
34
  def each &block
35
- if @start < @stop
36
- curr = @start + 0
35
+ curr = @start + 0
37
36
 
37
+ if @start < @stop
38
38
  while curr <= @stop
39
39
  yield curr
40
40
  curr += @step
41
41
  end
42
42
  else
43
- curr = @stop + 0
44
-
45
- while curr >= @start
43
+ while curr >= @stop
46
44
  yield curr
47
45
  curr -= @step
48
46
  end
@@ -1,3 +1,3 @@
1
1
  class TimeIterator
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -3,21 +3,32 @@ require "spec_helper"
3
3
 
4
4
  describe TimeIterator do
5
5
 
6
- let(:start) { Time.now - 60 }
7
- let(:stop) { start + 60 }
8
- let(:iter) { TimeIterator.new start, stop, 30 }
9
-
10
-
11
6
  it "should include Enumerable" do
12
- iter.should be_kind_of Enumerable
7
+ TimeIterator.new(Time.now, Time.now).should be_kind_of Enumerable
13
8
  end
14
9
 
15
10
 
16
11
  context "#each" do
17
- it "should yield Time steps" do
18
- lambda{ |b| iter.each(&b) }
19
- .should yield_successive_args(start, start + 30, start + 60)
12
+ let(:pivot) { Time.utc(1970, 1, 1) }
13
+
14
+ context "when since < till" do
15
+ let(:iter) { TimeIterator.new pivot, pivot + 60, 30 }
16
+
17
+ it "should yield every Time stop ascending" do
18
+ lambda{ |b| iter.each(&b) }
19
+ .should yield_successive_args(pivot, pivot + 30, pivot + 60)
20
+ end
20
21
  end
22
+
23
+ context "when since > till" do
24
+ let(:iter) { TimeIterator.new pivot + 60, pivot, 30 }
25
+
26
+ it "should yield every Time stop descending" do
27
+ lambda{ |b| iter.each(&b) }
28
+ .should yield_successive_args(pivot + 60, pivot + 30, pivot)
29
+ end
30
+ end
31
+
21
32
  end
22
33
 
23
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time-iterator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-16 00:00:00.000000000 Z
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -70,6 +70,7 @@ extra_rdoc_files: []
70
70
  files:
71
71
  - .gitignore
72
72
  - .rspec
73
+ - .travis.yml
73
74
  - Gemfile
74
75
  - Guardfile
75
76
  - HISTORY.md
@@ -108,7 +109,7 @@ rubyforge_project:
108
109
  rubygems_version: 1.8.23
109
110
  signing_key:
110
111
  specification_version: 3
111
- summary: time-iterator-0.1.0
112
+ summary: time-iterator-0.1.1
112
113
  test_files:
113
114
  - spec/lib/time_iterator/core_ext_spec.rb
114
115
  - spec/lib/time_iterator_spec.rb