sunspot_index_queue 1.1.2 → 1.1.3

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.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - rbx
5
+ - jruby
data/CHANGE_LOG.txt CHANGED
@@ -1,3 +1,7 @@
1
+ 1.1.3
2
+
3
+ - Fix mongo implementation to work properly with most recent versions.
4
+
1
5
  1.1.2
2
6
 
3
7
  - Optimization for ActiveRecord to eager load includes declared in sunspot_options for indexing.
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'rake/rdoctask'
4
3
 
5
4
  desc 'Default: run unit tests.'
6
5
  task :default => :test
@@ -16,20 +15,12 @@ rescue LoadError
16
15
  end
17
16
  end
18
17
 
19
- desc 'Generate documentation.'
20
- Rake::RDocTask.new(:rdoc) do |rdoc|
21
- rdoc.rdoc_dir = 'rdoc'
22
- rdoc.options << '--title' << 'Sunspot Index Queue' << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
23
- rdoc.rdoc_files.include('README.rdoc')
24
- rdoc.rdoc_files.include('lib/**/*.rb')
25
- end
26
-
27
18
  begin
28
19
  require 'jeweler'
29
20
  Jeweler::Tasks.new do |gem|
30
21
  gem.name = "sunspot_index_queue"
31
22
  gem.summary = %Q{Asynchronous Solr indexing support for the sunspot gem with an emphasis on reliablity and throughput.}
32
- gem.description = %Q(This gem provides asynchronous indexing to Solr for the sunspot gem. It uses a pluggable model for the backing queue and provides support for ActiveRecord and MongoDB out of the box.)
23
+ gem.description = %Q(This gem provides asynchronous indexing to Solr for the sunspot gem. It uses a pluggable model for the backing queue and provides support for ActiveRecord, DataMapper, and MongoDB out of the box.)
33
24
  gem.email = "brian@embellishedvisions.com"
34
25
  gem.homepage = "http://github.com/bdurand/sunspot_index_queue"
35
26
  gem.authors = ["Brian Durand"]
@@ -41,6 +32,7 @@ begin
41
32
  gem.add_development_dependency('dm-core', '>= 1.0.0')
42
33
  gem.add_development_dependency('dm-aggregates', '>=1.0.0')
43
34
  gem.add_development_dependency('dm-migrations', '>=1.0.0')
35
+ gem.add_development_dependency('dm-sqlite-adapter', '>=1.0.0')
44
36
  gem.add_development_dependency('mongo')
45
37
  gem.add_development_dependency('rspec', '>= 2.0.0')
46
38
  gem.add_development_dependency('jeweler')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
@@ -22,18 +22,18 @@ module Sunspot
22
22
  def connection=(*args)
23
23
  @connection = args.first.is_a?(Mongo::Connection) ? args.first : Mongo::Connection.new(*args)
24
24
  end
25
-
25
+
26
26
  # Get the connection currently in use.
27
27
  def connection
28
28
  @connection
29
29
  end
30
-
30
+
31
31
  # Set the name of the database which will contain the queue collection.
32
32
  def database_name=(name)
33
33
  @collection = nil
34
34
  @database_name = name
35
35
  end
36
-
36
+
37
37
  # Get the collection used to store the queue.
38
38
  def collection
39
39
  unless @collection
@@ -43,41 +43,41 @@ module Sunspot
43
43
  end
44
44
  @collection
45
45
  end
46
-
46
+
47
47
  # Create a new entry.
48
48
  def create(attributes)
49
49
  entry = new(attributes)
50
50
  entry.save
51
51
  entry
52
52
  end
53
-
53
+
54
54
  # Find one entry given a selector or object id.
55
55
  def find_one(spec_or_object_id=nil, opts={})
56
56
  doc = collection.find_one(spec_or_object_id, opts)
57
57
  doc ? new(doc) : nil
58
58
  end
59
-
59
+
60
60
  # Find an array of entries given a selector.
61
61
  def find(selector={}, opts={})
62
62
  collection.find(selector, opts).collect{|doc| new(doc)}
63
63
  end
64
-
64
+
65
65
  # Logger used to log errors.
66
66
  def logger
67
67
  @logger
68
68
  end
69
-
69
+
70
70
  # Set the logger used to log errors.
71
71
  def logger=(logger)
72
72
  @logger = logger
73
73
  end
74
-
74
+
75
75
  # Implementation of the total_count method.
76
76
  def total_count(queue)
77
77
  conditions = queue.class_names.empty? ? {} : {:record_class_name => {'$in' => queue.class_names}}
78
78
  collection.find(conditions).count
79
79
  end
80
-
80
+
81
81
  # Implementation of the ready_count method.
82
82
  def ready_count(queue)
83
83
  conditions = {:run_at => {'$lte' => Time.now.utc}}
@@ -110,7 +110,7 @@ module Sunspot
110
110
  conditions = queue.class_names.empty? ? {} : {:record_class_name => {'$in' => queue.class_names}}
111
111
  collection.update(conditions, {"$set" => {:run_at => Time.now.utc, :attempts => 0, :error => nil}}, :multi => true)
112
112
  end
113
-
113
+
114
114
  # Implementation of the next_batch! method.
115
115
  def next_batch!(queue)
116
116
  conditions = {:run_at => {'$lte' => Time.now.utc}}
@@ -122,6 +122,7 @@ module Sunspot
122
122
  begin
123
123
  lock = rand(0x7FFFFFFF)
124
124
  doc = collection.find_and_modify(:update => {"$set" => {:run_at => Time.now.utc + queue.retry_interval, :error => nil, :lock => lock}}, :query => conditions, :limit => queue.batch_size, :sort => [[:priority, Mongo::DESCENDING], [:run_at, Mongo::ASCENDING]])
125
+ break unless doc
125
126
  entries << new(doc)
126
127
  rescue Mongo::OperationFailure
127
128
  break
@@ -139,15 +140,15 @@ module Sunspot
139
140
  queue_entry.run_at = Time.now.utc
140
141
  queue_entry.save
141
142
  end
142
-
143
+
143
144
  # Implementation of the delete_entries method.
144
145
  def delete_entries(entries)
145
146
  collection.remove(:_id => {'$in' => entries.map(&:id)})
146
147
  end
147
148
  end
148
-
149
+
149
150
  attr_reader :doc
150
-
151
+
151
152
  # Create a new entry from a document hash.
152
153
  def initialize(attributes = {})
153
154
  @doc = {}
@@ -157,83 +158,83 @@ module Sunspot
157
158
  @doc['priority'] = 0 unless doc['priority']
158
159
  @doc['attempts'] = 0 unless doc['attempts']
159
160
  end
160
-
161
+
161
162
  # Get the entry id.
162
163
  def id
163
164
  doc['_id']
164
165
  end
165
-
166
+
166
167
  # Get the entry id.
167
168
  def record_class_name
168
169
  doc['record_class_name']
169
170
  end
170
-
171
+
171
172
  # Set the entry record_class_name.
172
173
  def record_class_name=(value)
173
174
  doc['record_class_name'] = value.nil? ? nil : value.to_s
174
175
  end
175
-
176
+
176
177
  # Get the entry id.
177
178
  def record_id
178
179
  doc['record_id']
179
180
  end
180
-
181
+
181
182
  # Set the entry record_id.
182
183
  def record_id=(value)
183
184
  doc['record_id'] = value
184
185
  end
185
-
186
+
186
187
  # Get the entry run_at time.
187
188
  def run_at
188
189
  doc['run_at']
189
190
  end
190
-
191
+
191
192
  # Set the entry run_at time.
192
193
  def run_at=(value)
193
194
  value = Time.parse(value.to_s) unless value.nil? || value.is_a?(Time)
194
195
  doc['run_at'] = value.nil? ? nil : value.utc
195
196
  end
196
-
197
+
197
198
  # Get the entry priority.
198
199
  def priority
199
200
  doc['priority']
200
201
  end
201
-
202
+
202
203
  # Set the entry priority.
203
204
  def priority=(value)
204
205
  doc['priority'] = value.to_i
205
206
  end
206
-
207
+
207
208
  # Get the entry attempts.
208
209
  def attempts
209
210
  doc['attempts'] || 0
210
211
  end
211
-
212
+
212
213
  # Set the entry attempts.
213
214
  def attempts=(value)
214
215
  doc['attempts'] = value.to_i
215
216
  end
216
-
217
+
217
218
  # Get the entry error.
218
219
  def error
219
220
  doc['error']
220
221
  end
221
-
222
+
222
223
  # Set the entry error.
223
224
  def error=(value)
224
225
  doc['error'] = value.nil? ? nil : value.to_s
225
226
  end
226
-
227
+
227
228
  # Get the entry delete entry flag.
228
229
  def is_delete?
229
230
  doc['is_delete']
230
231
  end
231
-
232
+
232
233
  # Set the entry delete entry flag.
233
234
  def is_delete=(value)
234
235
  doc['is_delete'] = !!value
235
236
  end
236
-
237
+
237
238
  # Save the entry to the database.
238
239
  def save
239
240
  id = self.class.collection.save(doc)
@@ -266,7 +267,7 @@ module Sunspot
266
267
  self.class.logger.warn(e) if self.class.logger
267
268
  end
268
269
  end
269
-
270
+
270
271
  def == (value)
271
272
  value.is_a?(self.class) && ((id && id == value.id) || (doc == value.doc))
272
273
  end
@@ -5,17 +5,18 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sunspot_index_queue}
8
- s.version = "1.1.2"
8
+ s.version = "1.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Durand"]
12
- s.date = %q{2011-06-23}
13
- s.description = %q{This gem provides asynchronous indexing to Solr for the sunspot gem. It uses a pluggable model for the backing queue and provides support for ActiveRecord and MongoDB out of the box.}
12
+ s.date = %q{2012-02-12}
13
+ s.description = %q{This gem provides asynchronous indexing to Solr for the sunspot gem. It uses a pluggable model for the backing queue and provides support for ActiveRecord, DataMapper, and MongoDB out of the box.}
14
14
  s.email = %q{brian@embellishedvisions.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
18
18
  s.files = [
19
+ ".travis.yml",
19
20
  "CHANGE_LOG.txt",
20
21
  "MIT_LICENSE",
21
22
  "README.rdoc",
@@ -57,6 +58,7 @@ Gem::Specification.new do |s|
57
58
  s.add_development_dependency(%q<dm-core>, [">= 1.0.0"])
58
59
  s.add_development_dependency(%q<dm-aggregates>, [">= 1.0.0"])
59
60
  s.add_development_dependency(%q<dm-migrations>, [">= 1.0.0"])
61
+ s.add_development_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
60
62
  s.add_development_dependency(%q<mongo>, [">= 0"])
61
63
  s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
62
64
  s.add_development_dependency(%q<jeweler>, [">= 0"])
@@ -67,6 +69,7 @@ Gem::Specification.new do |s|
67
69
  s.add_dependency(%q<dm-core>, [">= 1.0.0"])
68
70
  s.add_dependency(%q<dm-aggregates>, [">= 1.0.0"])
69
71
  s.add_dependency(%q<dm-migrations>, [">= 1.0.0"])
72
+ s.add_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
70
73
  s.add_dependency(%q<mongo>, [">= 0"])
71
74
  s.add_dependency(%q<rspec>, [">= 2.0.0"])
72
75
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -78,6 +81,7 @@ Gem::Specification.new do |s|
78
81
  s.add_dependency(%q<dm-core>, [">= 1.0.0"])
79
82
  s.add_dependency(%q<dm-aggregates>, [">= 1.0.0"])
80
83
  s.add_dependency(%q<dm-migrations>, [">= 1.0.0"])
84
+ s.add_dependency(%q<dm-sqlite-adapter>, [">= 1.0.0"])
81
85
  s.add_dependency(%q<mongo>, [">= 0"])
82
86
  s.add_dependency(%q<rspec>, [">= 2.0.0"])
83
87
  s.add_dependency(%q<jeweler>, [">= 0"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_index_queue
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 2
10
- version: 1.1.2
9
+ - 3
10
+ version: 1.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Durand
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-23 00:00:00 -05:00
18
+ date: 2012-02-12 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -112,9 +112,25 @@ dependencies:
112
112
  type: :development
113
113
  version_requirements: *id006
114
114
  - !ruby/object:Gem::Dependency
115
- name: mongo
115
+ name: dm-sqlite-adapter
116
116
  prerelease: false
117
117
  requirement: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 23
123
+ segments:
124
+ - 1
125
+ - 0
126
+ - 0
127
+ version: 1.0.0
128
+ type: :development
129
+ version_requirements: *id007
130
+ - !ruby/object:Gem::Dependency
131
+ name: mongo
132
+ prerelease: false
133
+ requirement: &id008 !ruby/object:Gem::Requirement
118
134
  none: false
119
135
  requirements:
120
136
  - - ">="
@@ -124,11 +140,11 @@ dependencies:
124
140
  - 0
125
141
  version: "0"
126
142
  type: :development
127
- version_requirements: *id007
143
+ version_requirements: *id008
128
144
  - !ruby/object:Gem::Dependency
129
145
  name: rspec
130
146
  prerelease: false
131
- requirement: &id008 !ruby/object:Gem::Requirement
147
+ requirement: &id009 !ruby/object:Gem::Requirement
132
148
  none: false
133
149
  requirements:
134
150
  - - ">="
@@ -140,11 +156,11 @@ dependencies:
140
156
  - 0
141
157
  version: 2.0.0
142
158
  type: :development
143
- version_requirements: *id008
159
+ version_requirements: *id009
144
160
  - !ruby/object:Gem::Dependency
145
161
  name: jeweler
146
162
  prerelease: false
147
- requirement: &id009 !ruby/object:Gem::Requirement
163
+ requirement: &id010 !ruby/object:Gem::Requirement
148
164
  none: false
149
165
  requirements:
150
166
  - - ">="
@@ -154,8 +170,8 @@ dependencies:
154
170
  - 0
155
171
  version: "0"
156
172
  type: :development
157
- version_requirements: *id009
158
- description: This gem provides asynchronous indexing to Solr for the sunspot gem. It uses a pluggable model for the backing queue and provides support for ActiveRecord and MongoDB out of the box.
173
+ version_requirements: *id010
174
+ description: This gem provides asynchronous indexing to Solr for the sunspot gem. It uses a pluggable model for the backing queue and provides support for ActiveRecord, DataMapper, and MongoDB out of the box.
159
175
  email: brian@embellishedvisions.com
160
176
  executables: []
161
177
 
@@ -164,6 +180,7 @@ extensions: []
164
180
  extra_rdoc_files:
165
181
  - README.rdoc
166
182
  files:
183
+ - .travis.yml
167
184
  - CHANGE_LOG.txt
168
185
  - MIT_LICENSE
169
186
  - README.rdoc