model_iterator 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # Iterates over large models, storing state in Redis.
2
2
  class ModelIterator
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
 
5
5
  class MaxIterations < StandardError
6
6
  attr_reader :iterator
@@ -104,14 +104,13 @@ class ModelIterator
104
104
  @max = @options[:max].to_i
105
105
  @joins = @options[:joins]
106
106
  @clause = "#{@id_clause} #{op} ?"
107
- if @options[:conditions]
108
- conditions = Array(@options[:conditions])
109
- @clause += " AND (#{conditions.first})"
110
- @clause_args = conditions[1..-1]
111
- elsif !args.empty?
112
- @clause += " AND (#{args.shift})"
113
- @clause_args = args
107
+
108
+ if !(conditions = Array(@options[:conditions] || args)).empty?
109
+ @clause += " AND (#{conditions.shift})"
114
110
  end
111
+
112
+ @clause_args = conditions
113
+
115
114
  @current_id = @options[:start_id]
116
115
  @limit = @options[:limit] || 100
117
116
  @job = @prefix = @key = nil
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  ## If your rubyforge_project name is different, then edit it and comment out
13
13
  ## the sub! line in the Rakefile
14
14
  s.name = 'model_iterator'
15
- s.version = '1.0.3'
15
+ s.version = '1.0.4'
16
16
  s.date = '2013-05-01'
17
17
  s.rubyforge_project = 'model_iterator'
18
18
 
data/test/iterate_test.rb CHANGED
@@ -32,7 +32,7 @@ class IterateTest < ModelIterator::TestCase
32
32
  assert_equal 3, iter.current_id
33
33
  end
34
34
 
35
- def test_loops_through_all_sets
35
+ def test_loops_through_all_sets_with_null_redis
36
36
  names = []
37
37
  redis = ModelIterator::NullRedis.new
38
38
  iter = ModelIterator.new Model, :redis => redis, :limit => 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_iterator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  segments:
76
76
  - 0
77
- hash: 2632868807396715918
77
+ hash: 1098997578076474898
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  none: false
80
80
  requirements: