thinking-sphinx 1.4.13 → 1.4.14
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/README.textile +1 -0
- data/lib/thinking_sphinx.rb +1 -0
- data/lib/thinking_sphinx/active_record.rb +2 -3
- data/lib/thinking_sphinx/active_record/delta.rb +11 -9
- data/lib/thinking_sphinx/auto_version.rb +1 -1
- data/lib/thinking_sphinx/configuration.rb +1 -1
- data/lib/thinking_sphinx/facet.rb +8 -1
- data/lib/thinking_sphinx/search.rb +2 -2
- data/lib/thinking_sphinx/version.rb +1 -1
- data/spec/thinking_sphinx/active_record/delta_spec.rb +0 -6
- data/spec/thinking_sphinx/active_record_spec.rb +0 -19
- data/spec/thinking_sphinx/search_spec.rb +3 -3
- metadata +29 -28
data/README.textile
CHANGED
data/lib/thinking_sphinx.rb
CHANGED
@@ -25,6 +25,7 @@ require 'thinking_sphinx/rails_additions'
|
|
25
25
|
require 'thinking_sphinx/search'
|
26
26
|
require 'thinking_sphinx/search_methods'
|
27
27
|
require 'thinking_sphinx/deltas'
|
28
|
+
require 'thinking_sphinx/version'
|
28
29
|
|
29
30
|
require 'thinking_sphinx/adapters/abstract_adapter'
|
30
31
|
require 'thinking_sphinx/adapters/mysql_adapter'
|
@@ -274,14 +274,13 @@ module ThinkingSphinx
|
|
274
274
|
end
|
275
275
|
|
276
276
|
def delete_in_index(index, document_id)
|
277
|
-
return unless ThinkingSphinx.sphinx_running?
|
278
|
-
search_for_id(document_id, index)
|
277
|
+
return unless ThinkingSphinx.sphinx_running?
|
279
278
|
|
280
279
|
ThinkingSphinx::Configuration.instance.client.update(
|
281
280
|
index, ['sphinx_deleted'], {document_id => [1]}
|
282
281
|
)
|
283
282
|
rescue Riddle::ConnectionError, Riddle::ResponseError,
|
284
|
-
ThinkingSphinx::SphinxError, Errno::ETIMEDOUT
|
283
|
+
ThinkingSphinx::SphinxError, Errno::ETIMEDOUT, Timeout::Error
|
285
284
|
# Not the end of the world if Sphinx isn't running.
|
286
285
|
end
|
287
286
|
|
@@ -3,7 +3,7 @@ module ThinkingSphinx
|
|
3
3
|
# This module contains all the delta-related code for models. There isn't
|
4
4
|
# really anything you need to call manually in here - except perhaps
|
5
5
|
# index_delta, but not sure what reason why.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
module Delta
|
8
8
|
# Code for after_commit callback is written by Eli Miller:
|
9
9
|
# http://elimiller.blogspot.com/2007/06/proper-cache-expiry-with-aftercommit.html
|
@@ -18,38 +18,40 @@ module ThinkingSphinx
|
|
18
18
|
def index_delta(instance = nil)
|
19
19
|
delta_objects.each { |obj| obj.index(self, instance) }
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def delta_objects
|
23
23
|
self.sphinx_indexes.collect(&:delta_object).compact
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def toggled_delta?
|
28
28
|
self.class.delta_objects.any? { |obj| obj.toggled(self) }
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
private
|
32
|
-
|
32
|
+
|
33
33
|
# Set the delta value for the model to be true.
|
34
34
|
def toggle_delta
|
35
35
|
self.class.delta_objects.each { |obj|
|
36
36
|
obj.toggle(self)
|
37
37
|
} if should_toggle_delta?
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
# Build the delta index for the related model. This won't be called
|
41
41
|
# if running in the test environment.
|
42
|
-
#
|
42
|
+
#
|
43
43
|
def index_delta
|
44
44
|
self.class.index_delta(self) if self.class.delta_objects.any? { |obj|
|
45
45
|
obj.toggled(self)
|
46
46
|
}
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def should_toggle_delta?
|
50
|
+
return fire_delta? if respond_to?(:fire_delta?)
|
51
|
+
|
50
52
|
self.new_record? || indexed_data_changed?
|
51
53
|
end
|
52
|
-
|
54
|
+
|
53
55
|
def indexed_data_changed?
|
54
56
|
sphinx_indexes.any? { |index|
|
55
57
|
index.fields.any? { |field| field.changed?(self) } ||
|
@@ -14,7 +14,7 @@ module ThinkingSphinx
|
|
14
14
|
else
|
15
15
|
documentation_link = %Q{
|
16
16
|
For more information, read the documentation:
|
17
|
-
http://
|
17
|
+
http://pat.github.com/ts/en/advanced_config.html
|
18
18
|
}
|
19
19
|
|
20
20
|
if version.nil? || version.empty?
|
@@ -53,7 +53,7 @@ module ThinkingSphinx
|
|
53
53
|
|
54
54
|
SourceOptions = Riddle::Configuration::SQLSource.settings.map { |setting|
|
55
55
|
setting.to_s
|
56
|
-
} - %w( type
|
56
|
+
} - %w( type sql_query sql_joined_field sql_file_field
|
57
57
|
sql_query_range sql_attr_uint sql_attr_bool sql_attr_bigint sql_query_info
|
58
58
|
sql_attr_timestamp sql_attr_str2ordinal sql_attr_float sql_attr_multi
|
59
59
|
sql_attr_string sql_attr_str2wordcount sql_column_buffers sql_field_string
|
@@ -104,7 +104,14 @@ module ThinkingSphinx
|
|
104
104
|
method = value_source || column.__name
|
105
105
|
object = objects.one? ? objects.first : objects.detect { |item|
|
106
106
|
result = item.send(method)
|
107
|
-
|
107
|
+
case result
|
108
|
+
when String
|
109
|
+
result.to_crc32 == attribute_value
|
110
|
+
when NilClass
|
111
|
+
false
|
112
|
+
else
|
113
|
+
result == attribute_value
|
114
|
+
end
|
108
115
|
}
|
109
116
|
|
110
117
|
object ? object.send(method) : nil
|
@@ -12,7 +12,7 @@ module ThinkingSphinx
|
|
12
12
|
instance_of? instance_values instance_variable_defined?
|
13
13
|
instance_variable_get instance_variable_set instance_variables is_a?
|
14
14
|
kind_of? member? method methods nil? object_id respond_to?
|
15
|
-
respond_to_missing? send should type )
|
15
|
+
respond_to_missing? send should tap type )
|
16
16
|
SafeMethods = %w( partition private_methods protected_methods
|
17
17
|
public_methods send class )
|
18
18
|
|
@@ -347,7 +347,7 @@ module ThinkingSphinx
|
|
347
347
|
client.excerpts(
|
348
348
|
{
|
349
349
|
:docs => [string.to_s],
|
350
|
-
:words =>
|
350
|
+
:words => query,
|
351
351
|
:index => index.split(',').first.strip
|
352
352
|
}.merge(options[:excerpt_options] || {})
|
353
353
|
).first
|
@@ -112,12 +112,6 @@ describe "ThinkingSphinx::ActiveRecord::Delta" do
|
|
112
112
|
@person.send(:index_delta)
|
113
113
|
end
|
114
114
|
|
115
|
-
it "shouldn't update the deleted attribute if not in the index" do
|
116
|
-
@client.should_not_receive(:update)
|
117
|
-
|
118
|
-
@person.send(:index_delta)
|
119
|
-
end
|
120
|
-
|
121
115
|
it "should update the deleted attribute if in the core index" do
|
122
116
|
Person.stub!(:search_for_id => true)
|
123
117
|
@client.should_receive(:update)
|
@@ -273,7 +273,6 @@ describe ThinkingSphinx::ActiveRecord do
|
|
273
273
|
|
274
274
|
@configuration.stub!(:client => @client)
|
275
275
|
Person.sphinx_indexes.each { |index| index.stub!(:delta? => false) }
|
276
|
-
Person.stub!(:search_for_id => true)
|
277
276
|
end
|
278
277
|
|
279
278
|
it "should update the core index's deleted flag if in core index" do
|
@@ -284,19 +283,9 @@ describe ThinkingSphinx::ActiveRecord do
|
|
284
283
|
@person.toggle_deleted
|
285
284
|
end
|
286
285
|
|
287
|
-
it "shouldn't update the core index's deleted flag if the record isn't in it" do
|
288
|
-
Person.stub!(:search_for_id => false)
|
289
|
-
@client.should_not_receive(:update).with(
|
290
|
-
"person_core", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
|
291
|
-
)
|
292
|
-
|
293
|
-
@person.toggle_deleted
|
294
|
-
end
|
295
|
-
|
296
286
|
it "shouldn't attempt to update the deleted flag if sphinx isn't running" do
|
297
287
|
ThinkingSphinx.stub!(:sphinx_running? => false)
|
298
288
|
@client.should_not_receive(:update)
|
299
|
-
Person.should_not_receive(:search_for_id)
|
300
289
|
|
301
290
|
@person.toggle_deleted
|
302
291
|
end
|
@@ -493,14 +482,6 @@ describe ThinkingSphinx::ActiveRecord do
|
|
493
482
|
@client = stub('client')
|
494
483
|
ThinkingSphinx.stub!(:sphinx_running? => true)
|
495
484
|
ThinkingSphinx::Configuration.instance.stub!(:client => @client)
|
496
|
-
Alpha.stub!(:search_for_id => true)
|
497
|
-
end
|
498
|
-
|
499
|
-
it "should not update if the document isn't in the given index" do
|
500
|
-
Alpha.stub!(:search_for_id => false)
|
501
|
-
@client.should_not_receive(:update)
|
502
|
-
|
503
|
-
Alpha.delete_in_index('alpha_core', 42)
|
504
485
|
end
|
505
486
|
|
506
487
|
it "should direct the update to the supplied index" do
|
@@ -1309,7 +1309,7 @@ describe ThinkingSphinx::Search do
|
|
1309
1309
|
:matches => [],
|
1310
1310
|
:words => {'one' => {}, 'two' => {}}
|
1311
1311
|
})
|
1312
|
-
@search = ThinkingSphinx::Search.new(:classes => [Alpha])
|
1312
|
+
@search = ThinkingSphinx::Search.new('reading comprehension', :classes => [Alpha])
|
1313
1313
|
end
|
1314
1314
|
|
1315
1315
|
it "should return the Sphinx excerpt value" do
|
@@ -1341,9 +1341,9 @@ describe ThinkingSphinx::Search do
|
|
1341
1341
|
@search.excerpt_for('string', Beta)
|
1342
1342
|
end
|
1343
1343
|
|
1344
|
-
it "should
|
1344
|
+
it "should use the query string" do
|
1345
1345
|
@client.should_receive(:excerpts) do |options|
|
1346
|
-
options[:words].should ==
|
1346
|
+
options[:words].should == 'reading comprehension'
|
1347
1347
|
end
|
1348
1348
|
|
1349
1349
|
@search.excerpt_for('string', Beta)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thinking-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 14
|
10
|
+
version: 1.4.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Allan
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-02 00:00:00 +11:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
type: :runtime
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
@@ -39,10 +39,10 @@ dependencies:
|
|
39
39
|
- 6
|
40
40
|
version: 1.15.6
|
41
41
|
version_requirements: *id001
|
42
|
-
prerelease: false
|
43
42
|
name: activerecord
|
44
|
-
|
43
|
+
prerelease: false
|
45
44
|
type: :runtime
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
46
|
requirement: &id002 !ruby/object:Gem::Requirement
|
47
47
|
none: false
|
48
48
|
requirements:
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
- 7
|
56
56
|
version: 1.0.7
|
57
57
|
version_requirements: *id002
|
58
|
-
prerelease: false
|
59
58
|
name: after_commit
|
60
|
-
|
59
|
+
prerelease: false
|
61
60
|
type: :runtime
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
62
|
requirement: &id003 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
@@ -71,10 +71,10 @@ dependencies:
|
|
71
71
|
- 3
|
72
72
|
version: 1.5.3
|
73
73
|
version_requirements: *id003
|
74
|
-
prerelease: false
|
75
74
|
name: riddle
|
75
|
+
prerelease: false
|
76
|
+
type: :runtime
|
76
77
|
- !ruby/object:Gem::Dependency
|
77
|
-
type: :development
|
78
78
|
requirement: &id004 !ruby/object:Gem::Requirement
|
79
79
|
none: false
|
80
80
|
requirements:
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
- 0
|
88
88
|
version: 0.4.0
|
89
89
|
version_requirements: *id004
|
90
|
-
prerelease: false
|
91
90
|
name: appraisal
|
92
|
-
|
91
|
+
prerelease: false
|
93
92
|
type: :development
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
94
|
requirement: &id005 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
@@ -103,10 +103,10 @@ dependencies:
|
|
103
103
|
- 2
|
104
104
|
version: 1.0.2
|
105
105
|
version_requirements: *id005
|
106
|
-
prerelease: false
|
107
106
|
name: cucumber
|
108
|
-
|
107
|
+
prerelease: false
|
109
108
|
type: :development
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
110
|
requirement: &id006 !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
@@ -119,10 +119,10 @@ dependencies:
|
|
119
119
|
- 1
|
120
120
|
version: 0.3.1
|
121
121
|
version_requirements: *id006
|
122
|
-
prerelease: false
|
123
122
|
name: faker
|
124
|
-
|
123
|
+
prerelease: false
|
125
124
|
type: :development
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
126
|
requirement: &id007 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
@@ -135,10 +135,10 @@ dependencies:
|
|
135
135
|
- 2
|
136
136
|
version: 0.9.2
|
137
137
|
version_requirements: *id007
|
138
|
-
prerelease: false
|
139
138
|
name: rake
|
140
|
-
|
139
|
+
prerelease: false
|
141
140
|
type: :development
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
142
|
requirement: &id008 !ruby/object:Gem::Requirement
|
143
143
|
none: false
|
144
144
|
requirements:
|
@@ -151,10 +151,10 @@ dependencies:
|
|
151
151
|
- 0
|
152
152
|
version: 2.6.0
|
153
153
|
version_requirements: *id008
|
154
|
-
prerelease: false
|
155
154
|
name: rspec
|
156
|
-
|
155
|
+
prerelease: false
|
157
156
|
type: :development
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
158
|
requirement: &id009 !ruby/object:Gem::Requirement
|
159
159
|
none: false
|
160
160
|
requirements:
|
@@ -167,10 +167,10 @@ dependencies:
|
|
167
167
|
- 15
|
168
168
|
version: 2.3.15
|
169
169
|
version_requirements: *id009
|
170
|
-
prerelease: false
|
171
170
|
name: will_paginate
|
172
|
-
|
171
|
+
prerelease: false
|
173
172
|
type: :development
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
174
|
requirement: &id010 !ruby/object:Gem::Requirement
|
175
175
|
none: false
|
176
176
|
requirements:
|
@@ -183,8 +183,9 @@ dependencies:
|
|
183
183
|
- 2
|
184
184
|
version: 0.7.2
|
185
185
|
version_requirements: *id010
|
186
|
-
prerelease: false
|
187
186
|
name: yard
|
187
|
+
prerelease: false
|
188
|
+
type: :development
|
188
189
|
description: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
|
189
190
|
email:
|
190
191
|
- pat@freelancing-gods.com
|
@@ -365,12 +366,13 @@ files:
|
|
365
366
|
- spec/thinking_sphinx/source_spec.rb
|
366
367
|
- spec/thinking_sphinx/test_spec.rb
|
367
368
|
- spec/thinking_sphinx_spec.rb
|
368
|
-
|
369
|
+
has_rdoc: true
|
370
|
+
homepage: http://pat.github.com/ts/en/
|
369
371
|
licenses: []
|
370
372
|
|
371
373
|
post_install_message: |+
|
372
374
|
If you're upgrading, you should read this:
|
373
|
-
http://
|
375
|
+
http://pat.github.com/ts/en/upgrading.html
|
374
376
|
|
375
377
|
rdoc_options: []
|
376
378
|
|
@@ -397,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
397
399
|
requirements: []
|
398
400
|
|
399
401
|
rubyforge_project: thinking-sphinx
|
400
|
-
rubygems_version: 1.
|
402
|
+
rubygems_version: 1.6.2
|
401
403
|
signing_key:
|
402
404
|
specification_version: 3
|
403
405
|
summary: ActiveRecord/Rails Sphinx library
|
@@ -525,4 +527,3 @@ test_files:
|
|
525
527
|
- spec/thinking_sphinx/source_spec.rb
|
526
528
|
- spec/thinking_sphinx/test_spec.rb
|
527
529
|
- spec/thinking_sphinx_spec.rb
|
528
|
-
has_rdoc:
|