pixeltrix-thinking-sphinx 1.1.5 → 1.2.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.
- data/README.textile +147 -0
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +48 -0
- data/lib/thinking_sphinx/active_record/delta.rb +14 -1
- data/lib/thinking_sphinx/active_record/scopes.rb +37 -0
- data/lib/thinking_sphinx/active_record.rb +46 -12
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +9 -1
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +3 -2
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +12 -5
- data/lib/thinking_sphinx/association.rb +20 -0
- data/lib/thinking_sphinx/attribute.rb +187 -116
- data/lib/thinking_sphinx/class_facet.rb +15 -0
- data/lib/thinking_sphinx/configuration.rb +46 -14
- data/lib/thinking_sphinx/core/string.rb +3 -10
- data/lib/thinking_sphinx/deltas/datetime_delta.rb +3 -3
- data/lib/thinking_sphinx/deltas/default_delta.rb +9 -6
- data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +1 -1
- data/lib/thinking_sphinx/deltas/delayed_delta.rb +4 -2
- data/lib/thinking_sphinx/deltas.rb +14 -6
- data/lib/thinking_sphinx/deploy/capistrano.rb +98 -0
- data/lib/thinking_sphinx/excerpter.rb +22 -0
- data/lib/thinking_sphinx/facet.rb +68 -18
- data/lib/thinking_sphinx/facet_search.rb +134 -0
- data/lib/thinking_sphinx/field.rb +7 -97
- data/lib/thinking_sphinx/index/builder.rb +255 -201
- data/lib/thinking_sphinx/index.rb +28 -343
- data/lib/thinking_sphinx/property.rb +160 -0
- data/lib/thinking_sphinx/rails_additions.rb +7 -4
- data/lib/thinking_sphinx/search.rb +593 -587
- data/lib/thinking_sphinx/search_methods.rb +421 -0
- data/lib/thinking_sphinx/source/internal_properties.rb +46 -0
- data/lib/thinking_sphinx/source/sql.rb +128 -0
- data/lib/thinking_sphinx/source.rb +150 -0
- data/lib/thinking_sphinx/tasks.rb +45 -11
- data/lib/thinking_sphinx.rb +88 -14
- data/rails/init.rb +14 -0
- data/spec/{unit → lib}/thinking_sphinx/active_record/delta_spec.rb +7 -7
- data/spec/{unit → lib}/thinking_sphinx/active_record/has_many_association_spec.rb +0 -0
- data/spec/lib/thinking_sphinx/active_record/scopes_spec.rb +92 -0
- data/spec/{unit → lib}/thinking_sphinx/active_record_spec.rb +115 -42
- data/spec/{unit → lib}/thinking_sphinx/association_spec.rb +4 -5
- data/spec/lib/thinking_sphinx/attribute_spec.rb +465 -0
- data/spec/{unit → lib}/thinking_sphinx/configuration_spec.rb +118 -7
- data/spec/{unit → lib}/thinking_sphinx/core/string_spec.rb +0 -0
- data/spec/lib/thinking_sphinx/excerpter_spec.rb +49 -0
- data/spec/lib/thinking_sphinx/facet_search_spec.rb +176 -0
- data/spec/lib/thinking_sphinx/facet_spec.rb +302 -0
- data/spec/{unit → lib}/thinking_sphinx/field_spec.rb +26 -17
- data/spec/lib/thinking_sphinx/index/builder_spec.rb +355 -0
- data/spec/{unit → lib}/thinking_sphinx/index/faux_column_spec.rb +0 -0
- data/spec/{unit → lib}/thinking_sphinx/index_spec.rb +3 -12
- data/spec/lib/thinking_sphinx/rails_additions_spec.rb +191 -0
- data/spec/lib/thinking_sphinx/search_methods_spec.rb +152 -0
- data/spec/lib/thinking_sphinx/search_spec.rb +887 -0
- data/spec/lib/thinking_sphinx/source_spec.rb +217 -0
- data/spec/{unit → lib}/thinking_sphinx_spec.rb +30 -8
- data/tasks/distribution.rb +20 -1
- data/tasks/testing.rb +7 -15
- data/vendor/after_commit/init.rb +3 -0
- data/vendor/after_commit/lib/after_commit/active_record.rb +27 -4
- data/vendor/after_commit/lib/after_commit/connection_adapters.rb +1 -1
- data/vendor/after_commit/lib/after_commit.rb +4 -1
- data/vendor/riddle/lib/riddle/client/message.rb +4 -3
- data/vendor/riddle/lib/riddle/client.rb +3 -0
- data/vendor/riddle/lib/riddle/configuration/section.rb +8 -2
- data/vendor/riddle/lib/riddle/controller.rb +1 -1
- data/vendor/riddle/lib/riddle.rb +1 -1
- metadata +75 -39
- data/README +0 -107
- data/lib/thinking_sphinx/active_record/search.rb +0 -57
- data/lib/thinking_sphinx/collection.rb +0 -142
- data/lib/thinking_sphinx/facet_collection.rb +0 -44
- data/spec/unit/thinking_sphinx/active_record/search_spec.rb +0 -107
- data/spec/unit/thinking_sphinx/attribute_spec.rb +0 -212
- data/spec/unit/thinking_sphinx/collection_spec.rb +0 -14
- data/spec/unit/thinking_sphinx/index/builder_spec.rb +0 -5
- data/spec/unit/thinking_sphinx/search_spec.rb +0 -59
@@ -0,0 +1,217 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe ThinkingSphinx::Source do
|
4
|
+
before :each do
|
5
|
+
@index = ThinkingSphinx::Index.new(Person)
|
6
|
+
@source = ThinkingSphinx::Source.new(@index, :sql_range_step => 1000)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should generate the name from the model" do
|
10
|
+
@source.name.should == "person"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should handle namespaced models for name generation" do
|
14
|
+
index = ThinkingSphinx::Index.new(Admin::Person)
|
15
|
+
source = ThinkingSphinx::Source.new(index)
|
16
|
+
source.name.should == "admin_person"
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#to_riddle_for_core" do
|
20
|
+
before :each do
|
21
|
+
config = ThinkingSphinx::Configuration.instance
|
22
|
+
config.source_options[:sql_ranged_throttle] = 100
|
23
|
+
|
24
|
+
ThinkingSphinx::Field.new(
|
25
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:first_name)
|
26
|
+
)
|
27
|
+
ThinkingSphinx::Field.new(
|
28
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:last_name)
|
29
|
+
)
|
30
|
+
|
31
|
+
ThinkingSphinx::Attribute.new(
|
32
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:id), :as => :internal_id
|
33
|
+
)
|
34
|
+
ThinkingSphinx::Attribute.new(
|
35
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:birthday)
|
36
|
+
)
|
37
|
+
ThinkingSphinx::Attribute.new(
|
38
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:tags, :id), :as => :tag_ids
|
39
|
+
)
|
40
|
+
ThinkingSphinx::Attribute.new(
|
41
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:contacts, :id),
|
42
|
+
:as => :contact_ids, :source => :query
|
43
|
+
)
|
44
|
+
|
45
|
+
@source.conditions << "`birthday` <= NOW()"
|
46
|
+
@source.groupings << "`first_name`"
|
47
|
+
|
48
|
+
@index.local_options[:group_concat_max_len] = 1024
|
49
|
+
|
50
|
+
@riddle = @source.to_riddle_for_core(1, 0)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should generate a Riddle Source object" do
|
54
|
+
@riddle.should be_a_kind_of(Riddle::Configuration::SQLSource)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should use the index and name its own name" do
|
58
|
+
@riddle.name.should == "person_core_0"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should use the model's database connection to determine type" do
|
62
|
+
@riddle.type.should == "mysql"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should match the model's database settings" do
|
66
|
+
config = Person.connection.instance_variable_get(:@config)
|
67
|
+
@riddle.sql_db.should == config[:database]
|
68
|
+
@riddle.sql_user.should == config[:username]
|
69
|
+
@riddle.sql_pass.should == config[:password].to_s
|
70
|
+
@riddle.sql_host.should == config[:host]
|
71
|
+
@riddle.sql_port.should == config[:port]
|
72
|
+
@riddle.sql_sock.should == config[:socket]
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should assign attributes" do
|
76
|
+
# 3 internal attributes plus the one requested
|
77
|
+
@riddle.sql_attr_uint.length.should == 4
|
78
|
+
@riddle.sql_attr_uint.last.should == :internal_id
|
79
|
+
|
80
|
+
@riddle.sql_attr_timestamp.length.should == 1
|
81
|
+
@riddle.sql_attr_timestamp.first.should == :birthday
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should set Sphinx Source options" do
|
85
|
+
@riddle.sql_range_step.should == 1000
|
86
|
+
@riddle.sql_ranged_throttle.should == 100
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#sql_query" do
|
90
|
+
before :each do
|
91
|
+
@query = @riddle.sql_query
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should select data from the model table" do
|
95
|
+
@query.should match(/FROM `people`/)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should select each of the fields" do
|
99
|
+
@query.should match(/`first_name`.+FROM/)
|
100
|
+
@query.should match(/`last_name`.+FROM/)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should select each of the attributes" do
|
104
|
+
@query.should match(/`id` AS `internal_id`.+FROM/)
|
105
|
+
@query.should match(/`birthday`.+FROM/)
|
106
|
+
@query.should match(/`tags`.`id`.+ AS `tag_ids`.+FROM/)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should not match the sourced MVA attribute" do
|
110
|
+
@query.should_not match(/contact_ids/)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should include joins for required associations" do
|
114
|
+
@query.should match(/LEFT OUTER JOIN `tags`/)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should not include joins for the sourced MVA attribute" do
|
118
|
+
@query.should_not match(/LEFT OUTER JOIN `contacts`/)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should include any defined conditions" do
|
122
|
+
@query.should match(/WHERE.+`birthday` <= NOW()/)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should include any defined groupings" do
|
126
|
+
@query.should match(/GROUP BY.+`first_name`/)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "#sql_query_range" do
|
131
|
+
before :each do
|
132
|
+
@query = @riddle.sql_query_range
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should select data from the model table" do
|
136
|
+
@query.should match(/FROM `people`/)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should select the minimum and the maximum ids" do
|
140
|
+
@query.should match(/SELECT.+MIN.+MAX.+FROM/)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#sql_query_info" do
|
145
|
+
before :each do
|
146
|
+
@query = @riddle.sql_query_info
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should select all fields from the model table" do
|
150
|
+
@query.should match(/SELECT \* FROM `people`/)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should filter the primary key with the offset" do
|
154
|
+
model_count = ThinkingSphinx.indexed_models.size
|
155
|
+
@query.should match(/WHERE `id` = \(\(\$id - 1\) \/ #{model_count}\)/)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#sql_query_pre" do
|
160
|
+
before :each do
|
161
|
+
@queries = @riddle.sql_query_pre
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should default to just the UTF8 statement" do
|
165
|
+
@queries.detect { |query|
|
166
|
+
query == "SET NAMES utf8"
|
167
|
+
}.should_not be_nil
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should set the group_concat_max_len session value for MySQL if requested" do
|
171
|
+
@queries.detect { |query|
|
172
|
+
query == "SET SESSION group_concat_max_len = 1024"
|
173
|
+
}.should_not be_nil
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "#to_riddle_for_core with range disabled" do
|
179
|
+
before :each do
|
180
|
+
ThinkingSphinx::Field.new(
|
181
|
+
@source, ThinkingSphinx::Index::FauxColumn.new(:first_name)
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "set per-index" do
|
186
|
+
before :each do
|
187
|
+
@index.local_options[:disable_range] = true
|
188
|
+
@riddle = @source.to_riddle_for_core(1, 0)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should not have the range in the sql_query" do
|
192
|
+
@riddle.sql_query.should_not match(/`people`.`id` >= \$start/)
|
193
|
+
@riddle.sql_query.should_not match(/`people`.`id` <= \$end/)
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should not have a sql_query_range" do
|
197
|
+
@riddle.sql_query_range.should be_nil
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "set globally" do
|
202
|
+
before :each do
|
203
|
+
ThinkingSphinx::Configuration.instance.index_options[:disable_range] = true
|
204
|
+
@riddle = @source.to_riddle_for_core(1, 0)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should not have the range in the sql_query" do
|
208
|
+
@riddle.sql_query.should_not match(/`people`.`id` >= \$start/)
|
209
|
+
@riddle.sql_query.should_not match(/`people`.`id` <= \$end/)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should not have a sql_query_range" do
|
213
|
+
@riddle.sql_query_range.should be_nil
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -51,15 +51,33 @@ describe ThinkingSphinx do
|
|
51
51
|
ThinkingSphinx.updates_enabled?.should be_true
|
52
52
|
end
|
53
53
|
|
54
|
+
it "should always say Sphinx is running if flagged as being on a remote machine" do
|
55
|
+
ThinkingSphinx.remote_sphinx = true
|
56
|
+
ThinkingSphinx.stub_method(:sphinx_running_by_pid? => false)
|
57
|
+
|
58
|
+
ThinkingSphinx.sphinx_running?.should be_true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should actually pay attention to Sphinx if not on a remote machine" do
|
62
|
+
ThinkingSphinx.remote_sphinx = false
|
63
|
+
ThinkingSphinx.stub_method(:sphinx_running_by_pid? => false)
|
64
|
+
ThinkingSphinx.sphinx_running?.should be_false
|
65
|
+
|
66
|
+
ThinkingSphinx.stub_method(:sphinx_running_by_pid? => true)
|
67
|
+
ThinkingSphinx.sphinx_running?.should be_true
|
68
|
+
end
|
69
|
+
|
54
70
|
describe "use_group_by_shortcut? method" do
|
55
71
|
before :each do
|
56
|
-
|
72
|
+
adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
|
73
|
+
unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
|
57
74
|
pending "No MySQL"
|
58
75
|
return
|
59
76
|
end
|
60
77
|
|
61
|
-
@connection = ::ActiveRecord::ConnectionAdapters
|
62
|
-
:select_all => true
|
78
|
+
@connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance(
|
79
|
+
:select_all => true,
|
80
|
+
:config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'}
|
63
81
|
)
|
64
82
|
::ActiveRecord::Base.stub_method(
|
65
83
|
:connection => @connection
|
@@ -103,12 +121,16 @@ describe ThinkingSphinx do
|
|
103
121
|
|
104
122
|
describe "if not using MySQL" do
|
105
123
|
before :each do
|
106
|
-
|
124
|
+
adapter = defined?(JRUBY_VERSION) ? 'JdbcAdapter' : 'PostgreSQLAdapter'
|
125
|
+
unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
|
107
126
|
pending "No PostgreSQL"
|
108
127
|
return
|
109
128
|
end
|
110
|
-
|
111
|
-
|
129
|
+
|
130
|
+
@connection = stub(adapter).as_null_object
|
131
|
+
@connection.stub!(
|
132
|
+
:select_all => true,
|
133
|
+
:config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcpostgresql' : 'postgresql'}
|
112
134
|
)
|
113
135
|
::ActiveRecord::Base.stub_method(
|
114
136
|
:connection => @connection
|
@@ -120,9 +142,9 @@ describe ThinkingSphinx do
|
|
120
142
|
end
|
121
143
|
|
122
144
|
it "should not call select_all" do
|
123
|
-
|
145
|
+
@connection.should_not_receive(:select_all)
|
124
146
|
|
125
|
-
|
147
|
+
ThinkingSphinx.use_group_by_shortcut?
|
126
148
|
end
|
127
149
|
end
|
128
150
|
end
|
data/tasks/distribution.rb
CHANGED
@@ -27,13 +27,32 @@ spec = Gem::Specification.new do |s|
|
|
27
27
|
s.rubyforge_project = "thinking-sphinx"
|
28
28
|
s.test_files = FileList["spec/**/*_spec.rb"]
|
29
29
|
s.files = FileList[
|
30
|
+
"rails/*.rb",
|
30
31
|
"lib/**/*.rb",
|
31
32
|
"LICENCE",
|
32
|
-
"README",
|
33
|
+
"README.textile",
|
33
34
|
"tasks/**/*.rb",
|
34
35
|
"tasks/**/*.rake",
|
35
36
|
"vendor/**/*"
|
36
37
|
]
|
38
|
+
s.post_install_message = <<-MESSAGE
|
39
|
+
With the release of Thinking Sphinx 1.1.18, there is one important change to
|
40
|
+
note: previously, the default morphology for indexing was 'stem_en'. The new
|
41
|
+
default is nil, to avoid any unexpected behavior. If you wish to keep the old
|
42
|
+
value though, you will need to add the following settings to your
|
43
|
+
config/sphinx.yml file:
|
44
|
+
|
45
|
+
development:
|
46
|
+
morphology: stem_en
|
47
|
+
test:
|
48
|
+
morphology: stem_en
|
49
|
+
production:
|
50
|
+
morphology: stem_en
|
51
|
+
|
52
|
+
To understand morphologies/stemmers better, visit the following link:
|
53
|
+
http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
|
54
|
+
|
55
|
+
MESSAGE
|
37
56
|
end
|
38
57
|
|
39
58
|
Rake::GemPackageTask.new(spec) do |p|
|
data/tasks/testing.rb
CHANGED
@@ -20,13 +20,7 @@ namespace :features do
|
|
20
20
|
def add_task(name, description)
|
21
21
|
Cucumber::Rake::Task.new(name, description) do |t|
|
22
22
|
t.cucumber_opts = "--format pretty"
|
23
|
-
t.
|
24
|
-
"features/support/env",
|
25
|
-
"features/support/db/#{name}",
|
26
|
-
"features/support/db/active_record",
|
27
|
-
"features/support/post_database",
|
28
|
-
"features/step_definitions/**.rb"
|
29
|
-
]
|
23
|
+
t.profile = name
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
@@ -46,13 +40,7 @@ namespace :rcov do
|
|
46
40
|
def add_task(name, description)
|
47
41
|
Cucumber::Rake::Task.new(name, description) do |t|
|
48
42
|
t.cucumber_opts = "--format pretty"
|
49
|
-
t.
|
50
|
-
"features/support/env",
|
51
|
-
"features/support/db/#{name}",
|
52
|
-
"features/support/db/active_record",
|
53
|
-
"features/support/post_database",
|
54
|
-
"features/step_definitions/**.rb"
|
55
|
-
]
|
43
|
+
t.profile = name
|
56
44
|
t.rcov = true
|
57
45
|
t.rcov_opts = [
|
58
46
|
'--exclude', 'spec',
|
@@ -80,7 +68,11 @@ task :cucumber_defaults do
|
|
80
68
|
"--require #{path}"
|
81
69
|
}.join(" ")
|
82
70
|
|
71
|
+
features = FileList["features/*.feature"].join(" ")
|
72
|
+
|
83
73
|
File.open('cucumber.yml', 'w') { |f|
|
84
|
-
f.write "default: \"#{default_requires} #{step_definitions}\""
|
74
|
+
f.write "default: \"#{default_requires} #{step_definitions}\"\n\n"
|
75
|
+
f.write "mysql: \"#{default_requires} #{step_definitions} #{features}\"\n\n"
|
76
|
+
f.write "postgresql: \"#{default_requires.gsub(/mysql/, 'postgresql')} #{step_definitions} #{features}\""
|
85
77
|
}
|
86
78
|
end
|
data/vendor/after_commit/init.rb
CHANGED
@@ -3,3 +3,6 @@ ActiveRecord::Base.send(:include, AfterCommit::ActiveRecord)
|
|
3
3
|
Object.subclasses_of(ActiveRecord::ConnectionAdapters::AbstractAdapter).each do |klass|
|
4
4
|
klass.send(:include, AfterCommit::ConnectionAdapters)
|
5
5
|
end
|
6
|
+
if defined?(JRUBY_VERSION) and defined?(JdbcSpec::MySQL)
|
7
|
+
JdbcSpec::MySQL.send :include, AfterCommit::ConnectionAdapters
|
8
|
+
end
|
@@ -71,19 +71,42 @@ module AfterCommit
|
|
71
71
|
# after_commit callback can be made from the ConnectionAdapters when
|
72
72
|
# the commit for the transaction has finally succeeded.
|
73
73
|
def after_commit_callback
|
74
|
-
|
74
|
+
call_after_commit_callback :after_commit
|
75
75
|
end
|
76
76
|
|
77
77
|
def after_commit_on_create_callback
|
78
|
-
|
78
|
+
call_after_commit_callback :after_commit_on_create
|
79
79
|
end
|
80
80
|
|
81
81
|
def after_commit_on_update_callback
|
82
|
-
|
82
|
+
call_after_commit_callback :after_commit_on_update
|
83
83
|
end
|
84
84
|
|
85
85
|
def after_commit_on_destroy_callback
|
86
|
-
|
86
|
+
call_after_commit_callback :after_commit_on_destroy
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def call_after_commit_callback(call)
|
92
|
+
if can_call_after_commit call
|
93
|
+
callback call
|
94
|
+
clear_after_commit_call call
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def can_call_after_commit(call)
|
99
|
+
@calls ||= {}
|
100
|
+
@calls[call] ||= false
|
101
|
+
if @calls[call]
|
102
|
+
return false
|
103
|
+
else
|
104
|
+
@calls[call] = true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def clear_after_commit_call(call)
|
109
|
+
@calls[call] = false
|
87
110
|
end
|
88
111
|
end
|
89
112
|
end
|
@@ -7,7 +7,7 @@ module AfterCommit
|
|
7
7
|
# override it so that after this happens, any records that were saved
|
8
8
|
# or destroyed within this transaction now get their after_commit
|
9
9
|
# callback fired.
|
10
|
-
def commit_db_transaction_with_callback
|
10
|
+
def commit_db_transaction_with_callback
|
11
11
|
commit_db_transaction_without_callback
|
12
12
|
trigger_after_commit_callbacks
|
13
13
|
trigger_after_commit_on_create_callbacks
|
@@ -39,4 +39,7 @@ ActiveRecord::Base.send(:include, AfterCommit::ActiveRecord)
|
|
39
39
|
|
40
40
|
Object.subclasses_of(ActiveRecord::ConnectionAdapters::AbstractAdapter).each do |klass|
|
41
41
|
klass.send(:include, AfterCommit::ConnectionAdapters)
|
42
|
-
end
|
42
|
+
end
|
43
|
+
if defined?(JRUBY_VERSION) and defined?(JdbcSpec::MySQL)
|
44
|
+
JdbcSpec::MySQL.send :include, AfterCommit::ConnectionAdapters
|
45
|
+
end
|
@@ -10,14 +10,15 @@ module Riddle
|
|
10
10
|
|
11
11
|
# Append raw data (only use if you know what you're doing)
|
12
12
|
def append(*args)
|
13
|
-
return if args.length == 0
|
14
|
-
|
15
13
|
args.each { |arg| @message << arg }
|
16
14
|
end
|
17
15
|
|
18
16
|
# Append a string's length, then the string itself
|
19
17
|
def append_string(str)
|
20
|
-
|
18
|
+
string = string.respond_to?(:force_encoding) ?
|
19
|
+
str.force_encoding('ASCII-8BIT') : str
|
20
|
+
|
21
|
+
@message << [string.send(@size_method)].pack('N') + string
|
21
22
|
end
|
22
23
|
|
23
24
|
# Append an integer
|
@@ -21,7 +21,7 @@ module Riddle
|
|
21
21
|
conf = " #{setting} = "
|
22
22
|
else
|
23
23
|
conf = setting_to_array(setting).collect { |set|
|
24
|
-
" #{setting} = #{set}"
|
24
|
+
" #{setting} = #{set}"
|
25
25
|
}
|
26
26
|
end
|
27
27
|
conf.length == 0 ? nil : conf
|
@@ -30,7 +30,13 @@ module Riddle
|
|
30
30
|
|
31
31
|
def setting_to_array(setting)
|
32
32
|
value = send(setting)
|
33
|
-
|
33
|
+
case value
|
34
|
+
when Array then value
|
35
|
+
when TrueClass then [1]
|
36
|
+
when FalseClass then [0]
|
37
|
+
else
|
38
|
+
[value]
|
39
|
+
end
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
data/vendor/riddle/lib/riddle.rb
CHANGED
@@ -18,7 +18,7 @@ module Riddle #:nodoc:
|
|
18
18
|
Rev = 1533
|
19
19
|
# Release number to mark my own fixes, beyond feature parity with
|
20
20
|
# Sphinx itself.
|
21
|
-
Release =
|
21
|
+
Release = 6
|
22
22
|
|
23
23
|
String = [Major, Minor, Tiny].join('.')
|
24
24
|
GemVersion = [Major, Minor, Tiny, Rev, Release].join('.')
|