sunspot_index_queue 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGE_LOG.txt +4 -0
- data/VERSION +1 -1
- data/lib/sunspot/index_queue/entry.rb +6 -2
- data/spec/batch_spec.rb +15 -0
- data/spec/spec_helper.rb +12 -0
- data/sunspot_index_queue.gemspec +2 -14
- metadata +6 -15
data/CHANGE_LOG.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -99,13 +99,17 @@ module Sunspot
|
|
99
99
|
end
|
100
100
|
|
101
101
|
# Load all records in an array of entries. This can be faster than calling load on each DataAccessor
|
102
|
-
# depending on
|
102
|
+
# depending on the implementation
|
103
103
|
def load_all_records(entries)
|
104
104
|
classes = entries.collect{|entry| entry.record_class_name}.uniq.collect{|name| Sunspot::Util.full_const_get(name) rescue nil}.compact
|
105
105
|
map = entries.inject({}){|hash, entry| hash[entry.record_id.to_s] = entry; hash}
|
106
106
|
classes.each do |klass|
|
107
107
|
ids = entries.collect{|entry| entry.record_id}
|
108
|
-
Sunspot::Adapters::DataAccessor.create(klass)
|
108
|
+
adapter = Sunspot::Adapters::DataAccessor.create(klass)
|
109
|
+
if klass.respond_to?(:sunspot_options) && klass.sunspot_options && klass.sunspot_options[:include] && adapter.respond_to?(:include=)
|
110
|
+
adapter.include = klass.sunspot_options[:include]
|
111
|
+
end
|
112
|
+
adapter.load_all(ids).each do |record|
|
109
113
|
entry = map[Sunspot::Adapters::InstanceAdapter.adapt(record).id.to_s]
|
110
114
|
entry.instance_variable_set(:@record, record) if entry
|
111
115
|
end
|
data/spec/batch_spec.rb
CHANGED
@@ -30,6 +30,21 @@ describe Sunspot::IndexQueue::Batch do
|
|
30
30
|
entry_2.processed?.should == true
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should submit all entries in a batch to Solr using include options if they are supported on the model and data adapters" do
|
34
|
+
record = Sunspot::IndexQueue::Test::Searchable::IncludeClass.new(1)
|
35
|
+
entry = Sunspot::IndexQueue::Entry::MockImpl.new(:record => record, :delete => false)
|
36
|
+
entry.stub!(:record).and_return(record)
|
37
|
+
session.should_receive(:batch).and_yield
|
38
|
+
session.should_receive(:index).with(record)
|
39
|
+
session.should_receive(:commit)
|
40
|
+
adapter = Sunspot::Adapters::DataAccessor.create(Sunspot::IndexQueue::Test::Searchable::IncludeClass)
|
41
|
+
Sunspot::Adapters::DataAccessor.should_receive(:create).with(Sunspot::IndexQueue::Test::Searchable::IncludeClass).and_return(adapter)
|
42
|
+
Sunspot::IndexQueue::Entry.implementation.should_receive(:delete_entries).with([entry])
|
43
|
+
batch = Sunspot::IndexQueue::Batch.new(queue, [entry])
|
44
|
+
batch.submit!
|
45
|
+
adapter.include.should == :test
|
46
|
+
end
|
47
|
+
|
33
48
|
it "should submit all entries individually and commit them if the batch errors out" do
|
34
49
|
entry_1.stub!(:record).and_return(record_1)
|
35
50
|
session.should_receive(:batch).and_yield
|
data/spec/spec_helper.rb
CHANGED
@@ -81,10 +81,22 @@ module Sunspot
|
|
81
81
|
|
82
82
|
class Subclass < Searchable
|
83
83
|
end
|
84
|
+
|
85
|
+
# This class mocks out the behavior of ActiveRecord DataAccessor where an include can be attached for eager loading.
|
86
|
+
class IncludeClass < Searchable
|
87
|
+
def self.sunspot_options
|
88
|
+
{:include => :test}
|
89
|
+
end
|
90
|
+
|
91
|
+
class IncludeDataAccessor < DataAccessor
|
92
|
+
attr_accessor :include
|
93
|
+
end
|
94
|
+
end
|
84
95
|
end
|
85
96
|
|
86
97
|
Sunspot::Adapters::InstanceAdapter.register(Searchable::InstanceAdapter, Searchable)
|
87
98
|
Sunspot::Adapters::DataAccessor.register(Searchable::DataAccessor, Searchable)
|
99
|
+
Sunspot::Adapters::DataAccessor.register(Searchable::IncludeClass::IncludeDataAccessor, Searchable::IncludeClass)
|
88
100
|
Sunspot.setup(Searchable) do
|
89
101
|
string :value
|
90
102
|
end
|
data/sunspot_index_queue.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sunspot_index_queue}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.2"
|
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-
|
12
|
+
s.date = %q{2011-06-23}
|
13
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.}
|
14
14
|
s.email = %q{brian@embellishedvisions.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -46,18 +46,6 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.require_paths = ["lib"]
|
47
47
|
s.rubygems_version = %q{1.5.2}
|
48
48
|
s.summary = %q{Asynchronous Solr indexing support for the sunspot gem with an emphasis on reliablity and throughput.}
|
49
|
-
s.test_files = [
|
50
|
-
"spec/active_record_impl_spec.rb",
|
51
|
-
"spec/batch_spec.rb",
|
52
|
-
"spec/data_mapper_impl_spec.rb",
|
53
|
-
"spec/entry_impl_examples.rb",
|
54
|
-
"spec/entry_spec.rb",
|
55
|
-
"spec/index_queue_spec.rb",
|
56
|
-
"spec/integration_spec.rb",
|
57
|
-
"spec/mongo_impl_spec.rb",
|
58
|
-
"spec/session_proxy_spec.rb",
|
59
|
-
"spec/spec_helper.rb"
|
60
|
-
]
|
61
49
|
|
62
50
|
if s.respond_to? :specification_version then
|
63
51
|
s.specification_version = 3
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
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-
|
18
|
+
date: 2011-06-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -225,14 +225,5 @@ rubygems_version: 1.5.2
|
|
225
225
|
signing_key:
|
226
226
|
specification_version: 3
|
227
227
|
summary: Asynchronous Solr indexing support for the sunspot gem with an emphasis on reliablity and throughput.
|
228
|
-
test_files:
|
229
|
-
|
230
|
-
- spec/batch_spec.rb
|
231
|
-
- spec/data_mapper_impl_spec.rb
|
232
|
-
- spec/entry_impl_examples.rb
|
233
|
-
- spec/entry_spec.rb
|
234
|
-
- spec/index_queue_spec.rb
|
235
|
-
- spec/integration_spec.rb
|
236
|
-
- spec/mongo_impl_spec.rb
|
237
|
-
- spec/session_proxy_spec.rb
|
238
|
-
- spec/spec_helper.rb
|
228
|
+
test_files: []
|
229
|
+
|