skalee-thinking-sphinx 1.3.14.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE +20 -0
- data/README.textile +201 -0
- data/Rakefile +3 -0
- data/VERSION +1 -0
- data/contribute.rb +385 -0
- data/cucumber.yml +1 -0
- data/features/abstract_inheritance.feature +10 -0
- data/features/alternate_primary_key.feature +27 -0
- data/features/attribute_transformation.feature +22 -0
- data/features/attribute_updates.feature +51 -0
- data/features/deleting_instances.feature +67 -0
- data/features/direct_attributes.feature +11 -0
- data/features/excerpts.feature +13 -0
- data/features/extensible_delta_indexing.feature +9 -0
- data/features/facets.feature +82 -0
- data/features/facets_across_model.feature +29 -0
- data/features/handling_edits.feature +92 -0
- data/features/retry_stale_indexes.feature +24 -0
- data/features/searching_across_models.feature +20 -0
- data/features/searching_by_index.feature +40 -0
- data/features/searching_by_model.feature +175 -0
- data/features/searching_with_find_arguments.feature +56 -0
- data/features/sphinx_detection.feature +25 -0
- data/features/sphinx_scopes.feature +42 -0
- data/features/step_definitions/alpha_steps.rb +16 -0
- data/features/step_definitions/beta_steps.rb +7 -0
- data/features/step_definitions/common_steps.rb +188 -0
- data/features/step_definitions/extensible_delta_indexing_steps.rb +7 -0
- data/features/step_definitions/facet_steps.rb +96 -0
- data/features/step_definitions/find_arguments_steps.rb +36 -0
- data/features/step_definitions/gamma_steps.rb +15 -0
- data/features/step_definitions/scope_steps.rb +15 -0
- data/features/step_definitions/search_steps.rb +89 -0
- data/features/step_definitions/sphinx_steps.rb +35 -0
- data/features/sti_searching.feature +19 -0
- data/features/support/database.example.yml +3 -0
- data/features/support/db/.gitignore +1 -0
- data/features/support/db/fixtures/alphas.rb +10 -0
- data/features/support/db/fixtures/authors.rb +1 -0
- data/features/support/db/fixtures/betas.rb +10 -0
- data/features/support/db/fixtures/boxes.rb +9 -0
- data/features/support/db/fixtures/categories.rb +1 -0
- data/features/support/db/fixtures/cats.rb +3 -0
- data/features/support/db/fixtures/comments.rb +24 -0
- data/features/support/db/fixtures/developers.rb +29 -0
- data/features/support/db/fixtures/dogs.rb +3 -0
- data/features/support/db/fixtures/extensible_betas.rb +10 -0
- data/features/support/db/fixtures/foxes.rb +3 -0
- data/features/support/db/fixtures/gammas.rb +10 -0
- data/features/support/db/fixtures/music.rb +4 -0
- data/features/support/db/fixtures/people.rb +1001 -0
- data/features/support/db/fixtures/posts.rb +6 -0
- data/features/support/db/fixtures/robots.rb +14 -0
- data/features/support/db/fixtures/tags.rb +27 -0
- data/features/support/db/migrations/create_alphas.rb +8 -0
- data/features/support/db/migrations/create_animals.rb +5 -0
- data/features/support/db/migrations/create_authors.rb +3 -0
- data/features/support/db/migrations/create_authors_posts.rb +6 -0
- data/features/support/db/migrations/create_betas.rb +5 -0
- data/features/support/db/migrations/create_boxes.rb +5 -0
- data/features/support/db/migrations/create_categories.rb +3 -0
- data/features/support/db/migrations/create_comments.rb +10 -0
- data/features/support/db/migrations/create_developers.rb +9 -0
- data/features/support/db/migrations/create_extensible_betas.rb +5 -0
- data/features/support/db/migrations/create_gammas.rb +3 -0
- data/features/support/db/migrations/create_genres.rb +3 -0
- data/features/support/db/migrations/create_music.rb +6 -0
- data/features/support/db/migrations/create_people.rb +13 -0
- data/features/support/db/migrations/create_posts.rb +5 -0
- data/features/support/db/migrations/create_robots.rb +4 -0
- data/features/support/db/migrations/create_taggings.rb +5 -0
- data/features/support/db/migrations/create_tags.rb +4 -0
- data/features/support/env.rb +21 -0
- data/features/support/lib/generic_delta_handler.rb +8 -0
- data/features/support/models/alpha.rb +22 -0
- data/features/support/models/animal.rb +5 -0
- data/features/support/models/author.rb +3 -0
- data/features/support/models/beta.rb +8 -0
- data/features/support/models/box.rb +8 -0
- data/features/support/models/cat.rb +3 -0
- data/features/support/models/category.rb +4 -0
- data/features/support/models/comment.rb +10 -0
- data/features/support/models/developer.rb +16 -0
- data/features/support/models/dog.rb +3 -0
- data/features/support/models/extensible_beta.rb +9 -0
- data/features/support/models/fox.rb +5 -0
- data/features/support/models/gamma.rb +5 -0
- data/features/support/models/genre.rb +3 -0
- data/features/support/models/medium.rb +5 -0
- data/features/support/models/music.rb +8 -0
- data/features/support/models/person.rb +23 -0
- data/features/support/models/post.rb +21 -0
- data/features/support/models/robot.rb +12 -0
- data/features/support/models/tag.rb +3 -0
- data/features/support/models/tagging.rb +4 -0
- data/ginger_scenarios.rb +28 -0
- data/init.rb +5 -0
- data/install.rb +5 -0
- data/lib/cucumber/thinking_sphinx/external_world.rb +8 -0
- data/lib/cucumber/thinking_sphinx/internal_world.rb +126 -0
- data/lib/cucumber/thinking_sphinx/sql_logger.rb +20 -0
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +19 -0
- data/lib/thinking_sphinx/active_record/delta.rb +47 -0
- data/lib/thinking_sphinx/active_record/has_many_association.rb +29 -0
- data/lib/thinking_sphinx/active_record/scopes.rb +75 -0
- data/lib/thinking_sphinx/active_record.rb +348 -0
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +42 -0
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +54 -0
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +143 -0
- data/lib/thinking_sphinx/association.rb +164 -0
- data/lib/thinking_sphinx/attribute.rb +362 -0
- data/lib/thinking_sphinx/auto_version.rb +22 -0
- data/lib/thinking_sphinx/class_facet.rb +15 -0
- data/lib/thinking_sphinx/configuration.rb +300 -0
- data/lib/thinking_sphinx/context.rb +68 -0
- data/lib/thinking_sphinx/core/array.rb +7 -0
- data/lib/thinking_sphinx/core/string.rb +15 -0
- data/lib/thinking_sphinx/deltas/default_delta.rb +62 -0
- data/lib/thinking_sphinx/deltas.rb +28 -0
- data/lib/thinking_sphinx/deploy/capistrano.rb +100 -0
- data/lib/thinking_sphinx/excerpter.rb +22 -0
- data/lib/thinking_sphinx/facet.rb +125 -0
- data/lib/thinking_sphinx/facet_search.rb +136 -0
- data/lib/thinking_sphinx/field.rb +82 -0
- data/lib/thinking_sphinx/index/builder.rb +296 -0
- data/lib/thinking_sphinx/index/faux_column.rb +110 -0
- data/lib/thinking_sphinx/index.rb +157 -0
- data/lib/thinking_sphinx/property.rb +162 -0
- data/lib/thinking_sphinx/rails_additions.rb +150 -0
- data/lib/thinking_sphinx/search.rb +769 -0
- data/lib/thinking_sphinx/search_methods.rb +439 -0
- data/lib/thinking_sphinx/source/internal_properties.rb +46 -0
- data/lib/thinking_sphinx/source/sql.rb +130 -0
- data/lib/thinking_sphinx/source.rb +153 -0
- data/lib/thinking_sphinx/tasks.rb +131 -0
- data/lib/thinking_sphinx/test.rb +52 -0
- data/lib/thinking_sphinx.rb +225 -0
- data/rails/init.rb +16 -0
- data/recipes/thinking_sphinx.rb +3 -0
- data/spec/fixtures/data.sql +32 -0
- data/spec/fixtures/database.yml.default +3 -0
- data/spec/fixtures/models.rb +145 -0
- data/spec/fixtures/structure.sql +125 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/sphinx_helper.rb +81 -0
- data/spec/thinking_sphinx/active_record/delta_spec.rb +128 -0
- data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +55 -0
- data/spec/thinking_sphinx/active_record/scopes_spec.rb +177 -0
- data/spec/thinking_sphinx/active_record_spec.rb +622 -0
- data/spec/thinking_sphinx/association_spec.rb +239 -0
- data/spec/thinking_sphinx/attribute_spec.rb +570 -0
- data/spec/thinking_sphinx/auto_version_spec.rb +39 -0
- data/spec/thinking_sphinx/configuration_spec.rb +234 -0
- data/spec/thinking_sphinx/context_spec.rb +119 -0
- data/spec/thinking_sphinx/core/array_spec.rb +9 -0
- data/spec/thinking_sphinx/core/string_spec.rb +9 -0
- data/spec/thinking_sphinx/excerpter_spec.rb +57 -0
- data/spec/thinking_sphinx/facet_search_spec.rb +176 -0
- data/spec/thinking_sphinx/facet_spec.rb +333 -0
- data/spec/thinking_sphinx/field_spec.rb +154 -0
- data/spec/thinking_sphinx/index/builder_spec.rb +479 -0
- data/spec/thinking_sphinx/index/faux_column_spec.rb +30 -0
- data/spec/thinking_sphinx/index_spec.rb +183 -0
- data/spec/thinking_sphinx/rails_additions_spec.rb +203 -0
- data/spec/thinking_sphinx/search_methods_spec.rb +152 -0
- data/spec/thinking_sphinx/search_spec.rb +1181 -0
- data/spec/thinking_sphinx/source_spec.rb +235 -0
- data/spec/thinking_sphinx_spec.rb +204 -0
- data/tasks/distribution.rb +41 -0
- data/tasks/rails.rake +1 -0
- data/tasks/testing.rb +72 -0
- data/vendor/after_commit/.gitignore +1 -0
- data/vendor/after_commit/lib/after_commit/active_record.rb +122 -0
- data/vendor/after_commit/lib/after_commit/connection_adapters.rb +168 -0
- data/vendor/after_commit/lib/after_commit/test_bypass.rb +30 -0
- data/vendor/after_commit/lib/after_commit.rb +70 -0
- data/vendor/riddle/lib/riddle/0.9.8.rb +1 -0
- data/vendor/riddle/lib/riddle/0.9.9/client/filter.rb +22 -0
- data/vendor/riddle/lib/riddle/0.9.9/client.rb +49 -0
- data/vendor/riddle/lib/riddle/0.9.9/configuration/searchd.rb +28 -0
- data/vendor/riddle/lib/riddle/0.9.9.rb +7 -0
- data/vendor/riddle/lib/riddle/auto_version.rb +11 -0
- data/vendor/riddle/lib/riddle/client/filter.rb +62 -0
- data/vendor/riddle/lib/riddle/client/message.rb +70 -0
- data/vendor/riddle/lib/riddle/client/response.rb +94 -0
- data/vendor/riddle/lib/riddle/client.rb +745 -0
- data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +49 -0
- data/vendor/riddle/lib/riddle/configuration/index.rb +149 -0
- data/vendor/riddle/lib/riddle/configuration/indexer.rb +20 -0
- data/vendor/riddle/lib/riddle/configuration/remote_index.rb +17 -0
- data/vendor/riddle/lib/riddle/configuration/searchd.rb +28 -0
- data/vendor/riddle/lib/riddle/configuration/section.rb +43 -0
- data/vendor/riddle/lib/riddle/configuration/source.rb +23 -0
- data/vendor/riddle/lib/riddle/configuration/sql_source.rb +53 -0
- data/vendor/riddle/lib/riddle/configuration/xml_source.rb +29 -0
- data/vendor/riddle/lib/riddle/configuration.rb +33 -0
- data/vendor/riddle/lib/riddle/controller.rb +78 -0
- data/vendor/riddle/lib/riddle.rb +51 -0
- metadata +312 -0
data/LICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Pat Allan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
h1. Slightly modified version of Thinking Sphinx
|
2
|
+
|
3
|
+
h2. Performance improvements
|
4
|
+
|
5
|
+
This version uses MySQL ORDER BY FIELD(id,..) instruction to sort results returned by sphinx without using Ruby. It also means, that it will be incompatible with DBMS not supporting FIELD function.
|
6
|
+
|
7
|
+
h2. Removed automated includes
|
8
|
+
|
9
|
+
I this version, all of your models which use TS must manually include ThinkingSphinx modules. Example:
|
10
|
+
|
11
|
+
class Person
|
12
|
+
|
13
|
+
# Sphinx
|
14
|
+
include ThinkingSphinx::ActiveRecord::Scopes
|
15
|
+
include ThinkingSphinx::SearchMethods
|
16
|
+
include ThinkingSphinx::ActiveRecord::AttributeUpdates
|
17
|
+
include ThinkingSphinx::ActiveRecord::Delta
|
18
|
+
define_index do
|
19
|
+
...
|
20
|
+
end
|
21
|
+
|
22
|
+
...
|
23
|
+
end
|
24
|
+
|
25
|
+
Because of that, it is a lot easier to override default sphinx methods.
|
26
|
+
|
27
|
+
h2. Default behaviour in tests
|
28
|
+
|
29
|
+
One of the reason to create this fork is to ensure that Thinking Sphinx will behave in same way on both production and test enviroment.
|
30
|
+
|
31
|
+
h2. Extended overrides in sphinx.yml
|
32
|
+
|
33
|
+
In sphinx.yml you can use:
|
34
|
+
|
35
|
+
development:
|
36
|
+
place_delta_0:
|
37
|
+
sql_query_pre: [ 'SET NAMES utf8' ]
|
38
|
+
|
39
|
+
to add an option which is specific only to single section of sphinx configuration file.
|
40
|
+
|
41
|
+
h1. Thinking Sphinx
|
42
|
+
|
43
|
+
h2. Usage
|
44
|
+
|
45
|
+
First, if you haven't done so already, check out the main "usage":http://ts.freelancing-gods.com/usage.html page. Once you've done that, the next place to look for information is the specific method docs - ThinkingSphinx::Search and ThinkingSphinx::Index::Builder in particular.
|
46
|
+
|
47
|
+
Keep in mind that while Thinking Sphinx works for ActiveRecord with Merb, it doesn't yet support DataMapper (although that is planned).
|
48
|
+
|
49
|
+
h2. Contributing
|
50
|
+
|
51
|
+
Fork on GitHub and after you've committed tested patches, send a pull request.
|
52
|
+
|
53
|
+
To quickly see if your system is ready to run the thinking sphinx specs, run the contribute.rb script found in the project root directory. Use the following instructions to install any missing requirements.
|
54
|
+
|
55
|
+
To get the spec suite running, you will need to install the ginger gem:
|
56
|
+
|
57
|
+
<pre><code>sudo gem install ginger --source http://gemcutter.org</code></pre>
|
58
|
+
|
59
|
+
Then install the cucumber, yard, jeweler and rspec gems. Make sure you have a git install version 1.6.0.0 or higher, otherwise the jeweler gem won't install. Bluecloth is required for some of the yard documentation.
|
60
|
+
|
61
|
+
<pre>
|
62
|
+
sudo gem install bluecloth cucumber yard jeweler rspec
|
63
|
+
</pre>
|
64
|
+
|
65
|
+
Then set up your database:
|
66
|
+
|
67
|
+
<pre>
|
68
|
+
cp spec/fixtures/database.yml.default spec/fixtures/database.yml &&
|
69
|
+
mysqladmin -u root create thinking_sphinx
|
70
|
+
</pre>
|
71
|
+
|
72
|
+
This last step can be done automatically by the contribute.rb script if all dependencies are met.
|
73
|
+
|
74
|
+
Make sure you don't have another Sphinx daemon (searchd) running. If you do, quit it with "rake ts:stop"
|
75
|
+
in the app root.
|
76
|
+
|
77
|
+
You should now have a passing test suite from which to build your patch on.
|
78
|
+
|
79
|
+
<pre>
|
80
|
+
rake spec
|
81
|
+
</pre>
|
82
|
+
|
83
|
+
If you get the message "Failed to start searchd daemon", run the spec with sudo:
|
84
|
+
|
85
|
+
<pre>
|
86
|
+
sudo rake spec
|
87
|
+
</pre>
|
88
|
+
|
89
|
+
If you quit the spec suite before it's completed, you may be left with data in the test
|
90
|
+
database, causing the next run to have failures. Let that run complete and then try again.
|
91
|
+
|
92
|
+
h2. Contributors
|
93
|
+
|
94
|
+
Since I first released this library, there's been quite a few people who have submitted patches, to my immense gratitude. Others have suggested syntax changes and general improvements. So my thanks to the following people:
|
95
|
+
|
96
|
+
* Joost Hietbrink
|
97
|
+
* Jonathan Conway
|
98
|
+
* Gregory Mirzayantz
|
99
|
+
* Tung Nguyen
|
100
|
+
* Sean Cribbs
|
101
|
+
* Benoit Caccinolo
|
102
|
+
* John Barton
|
103
|
+
* Oliver Beddows
|
104
|
+
* Arthur Zapparoli
|
105
|
+
* Dusty Doris
|
106
|
+
* Marcus Crafter
|
107
|
+
* Patrick Lenz
|
108
|
+
* Björn Andreasson
|
109
|
+
* James Healy
|
110
|
+
* Jae-Jun Hwang
|
111
|
+
* Xavier Shay
|
112
|
+
* Jason Rust
|
113
|
+
* Gopal Patel
|
114
|
+
* Chris Heald
|
115
|
+
* Peter Vandenberk
|
116
|
+
* Josh French
|
117
|
+
* Andrew Bennett
|
118
|
+
* Jordan Fowler
|
119
|
+
* Seth Walker
|
120
|
+
* Joe Noon
|
121
|
+
* Wolfgang Postler
|
122
|
+
* Rick Olson
|
123
|
+
* Killian Murphy
|
124
|
+
* Morten Primdahl
|
125
|
+
* Ryan Bates
|
126
|
+
* David Eisinger
|
127
|
+
* Shay Arnett
|
128
|
+
* Minh Tran
|
129
|
+
* Jeremy Durham
|
130
|
+
* Piotr Sarnacki
|
131
|
+
* Matt Johnson
|
132
|
+
* Nicolas Blanco
|
133
|
+
* Max Lapshin
|
134
|
+
* Josh Natanson
|
135
|
+
* Philip Hallstrom
|
136
|
+
* Christian Rishøj
|
137
|
+
* Mike Flester
|
138
|
+
* Jim Remsik
|
139
|
+
* Kennon Ballou
|
140
|
+
* Henrik Nyh
|
141
|
+
* Emil Tin
|
142
|
+
* Doug Cole
|
143
|
+
* Ed Hickey
|
144
|
+
* Evan Weaver
|
145
|
+
* Thibaut Barrere
|
146
|
+
* Kristopher Chambers
|
147
|
+
* Dmitrij Smalko
|
148
|
+
* Aleksey Yeschenko
|
149
|
+
* Lachie Cox
|
150
|
+
* Lourens Naude
|
151
|
+
* Tom Davies
|
152
|
+
* Dan Pickett
|
153
|
+
* Alex Caudill
|
154
|
+
* Jim Benton
|
155
|
+
* John Aughey
|
156
|
+
* Keith Pitty
|
157
|
+
* Jeff Talbot
|
158
|
+
* Dana Contreras
|
159
|
+
* Menno van der Sman
|
160
|
+
* Bill Harding
|
161
|
+
* Isaac Feliu
|
162
|
+
* Andrei Bocan
|
163
|
+
* László Bácsi
|
164
|
+
* Peter Wagenet
|
165
|
+
* Max Lapshin
|
166
|
+
* Martin Emde
|
167
|
+
* David Wennergren
|
168
|
+
* Mark Lane
|
169
|
+
* Eric Lindvall
|
170
|
+
* Lawrence Pit
|
171
|
+
* Mike Bailey
|
172
|
+
* Bill Leeper
|
173
|
+
* Michael Reinsch
|
174
|
+
* Anderson Dias
|
175
|
+
* Jerome Riga
|
176
|
+
* Tien Dung
|
177
|
+
* Johannes Kaefer
|
178
|
+
* Paul Campbell
|
179
|
+
* Matthew Beale
|
180
|
+
* Tom Simnett
|
181
|
+
* Erik Ostrom
|
182
|
+
* Ole Riesenberg
|
183
|
+
* Josh Kalderimis
|
184
|
+
* J.D. Hollis
|
185
|
+
* Jeffrey Chupp
|
186
|
+
* Rob Anderton
|
187
|
+
* Zach Inglis
|
188
|
+
* Ward Bekker
|
189
|
+
* Brian Terlson
|
190
|
+
* Christian Aust
|
191
|
+
* Martin Sarasale
|
192
|
+
* Édouard Brière
|
193
|
+
* Steve Madsen
|
194
|
+
* Justin DeWind
|
195
|
+
* Chris Z
|
196
|
+
* Chris Roos
|
197
|
+
* Andrew Assarattanakul
|
198
|
+
* Jonas von Andrian
|
199
|
+
* Dimitri Krassovski
|
200
|
+
* Sergey Kojin
|
201
|
+
* Brad Sumersford
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.3.18
|
data/contribute.rb
ADDED
@@ -0,0 +1,385 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'yaml'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /mswin/
|
9
|
+
rescue LoadError
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'optparse'
|
13
|
+
|
14
|
+
options = {}
|
15
|
+
OptionParser.new do |opts|
|
16
|
+
opts.banner = "Usage: example.rb [options]"
|
17
|
+
|
18
|
+
opts.on("-g [NAME]", "--ginger [NAME]", "Ginger gem name") do |name|
|
19
|
+
options[:ginger] = name
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("-s [NAME]", "--sphinx [NAME]", "Sphinx daemon name") do |name|
|
23
|
+
options[:sphinx] = name
|
24
|
+
end
|
25
|
+
end.parse!
|
26
|
+
|
27
|
+
OPTIONS = options
|
28
|
+
|
29
|
+
module ContributeHelper; end
|
30
|
+
|
31
|
+
class Contribute
|
32
|
+
include ContributeHelper
|
33
|
+
|
34
|
+
def dependencies
|
35
|
+
[
|
36
|
+
Dependencies::Sphinx,
|
37
|
+
Dependencies::Mysql,
|
38
|
+
Dependencies::AR,
|
39
|
+
Dependencies::Rspec,
|
40
|
+
Dependencies::Cucumber,
|
41
|
+
Dependencies::Yard,
|
42
|
+
Dependencies::Jeweler,
|
43
|
+
Dependencies::Ginger,
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def show
|
48
|
+
show_welcome_screen
|
49
|
+
|
50
|
+
(
|
51
|
+
check_for_dependencies &&
|
52
|
+
create_database_yaml &&
|
53
|
+
check_mysql_is_working &&
|
54
|
+
create_test_database
|
55
|
+
) || exit(1)
|
56
|
+
|
57
|
+
show_done_screen
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
WELCOME_SCREEN = <<-EO_WELCOME
|
62
|
+
<banner>Thinking Sphinx Contribution</banner>
|
63
|
+
|
64
|
+
Thanks for contributing to Thinking Sphinx.
|
65
|
+
|
66
|
+
In this script we'll help you get setup to hack:
|
67
|
+
|
68
|
+
<b>1.</b> We'll check that you have the right software installed and running.
|
69
|
+
<b>2.</b> We'll set up the test database for specs to run against.
|
70
|
+
|
71
|
+
EO_WELCOME
|
72
|
+
|
73
|
+
DONE_SCREEN = <<-EO_DONE
|
74
|
+
<banner>Setup done!</banner>
|
75
|
+
|
76
|
+
All done! Now you can start hacking by running
|
77
|
+
|
78
|
+
<b>rake spec</b>
|
79
|
+
|
80
|
+
EO_DONE
|
81
|
+
|
82
|
+
REVIEW_YAML = <<-EO_REVIEW_YAML
|
83
|
+
|
84
|
+
Please review the database details in the yaml file details before continuing.
|
85
|
+
|
86
|
+
This file is used by the specs to connect to the database.
|
87
|
+
|
88
|
+
Current details:
|
89
|
+
EO_REVIEW_YAML
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
MYSQL_FAILED = <<-EO_MYSQL_FAILED
|
94
|
+
|
95
|
+
Looks like we couldn't successfully talk to the mysql database.
|
96
|
+
|
97
|
+
Don't worry though...
|
98
|
+
|
99
|
+
EO_MYSQL_FAILED
|
100
|
+
|
101
|
+
CREATE_DATABASE_FAILED = <<-EO_CREATE_DATABASE_FAILED
|
102
|
+
|
103
|
+
Looks like we couldn't create a test database to work against.
|
104
|
+
|
105
|
+
Don't worry though...
|
106
|
+
|
107
|
+
EO_CREATE_DATABASE_FAILED
|
108
|
+
|
109
|
+
def show_welcome_screen
|
110
|
+
colour_puts WELCOME_SCREEN
|
111
|
+
wait!
|
112
|
+
end
|
113
|
+
|
114
|
+
def show_done_screen
|
115
|
+
colour_puts DONE_SCREEN
|
116
|
+
end
|
117
|
+
|
118
|
+
# create database.yml
|
119
|
+
def create_database_yaml
|
120
|
+
colour_puts "<banner>creating database yaml</banner>"
|
121
|
+
puts
|
122
|
+
|
123
|
+
|
124
|
+
config = {
|
125
|
+
'username' => 'root',
|
126
|
+
'password' => nil,
|
127
|
+
'host' => 'localhost'
|
128
|
+
}
|
129
|
+
|
130
|
+
|
131
|
+
colour_print " * <b>#{db_yml}</b>... "
|
132
|
+
unless File.exist?(db_yml)
|
133
|
+
open(db_yml,'w') {|f| f << config.to_yaml}
|
134
|
+
colour_puts "<green>created</green>"
|
135
|
+
else
|
136
|
+
config = YAML.load_file(db_yml)
|
137
|
+
colour_puts "<green>already exists</green>"
|
138
|
+
end
|
139
|
+
|
140
|
+
colour_puts REVIEW_YAML
|
141
|
+
|
142
|
+
config.each do |(k,v)|
|
143
|
+
colour_puts " * <b>#{k}</b>: #{v}"
|
144
|
+
end
|
145
|
+
|
146
|
+
puts
|
147
|
+
|
148
|
+
wait!
|
149
|
+
true
|
150
|
+
end
|
151
|
+
|
152
|
+
def check_mysql_is_working
|
153
|
+
require 'activerecord'
|
154
|
+
colour_puts "<banner>check mysql is working</banner>"
|
155
|
+
puts
|
156
|
+
|
157
|
+
connect_to_db
|
158
|
+
|
159
|
+
print " * connecting to mysql... "
|
160
|
+
|
161
|
+
begin
|
162
|
+
ActiveRecord::Base.connection.select_value('select sysdate() from dual')
|
163
|
+
|
164
|
+
colour_puts "<green>successful</green>"
|
165
|
+
puts
|
166
|
+
|
167
|
+
return true
|
168
|
+
rescue defined?(JRUBY_VERSION) ? Java::JavaSql::SQLException : Mysql::Error
|
169
|
+
colour_puts "<red>failed</red>"
|
170
|
+
|
171
|
+
puts MYSQL_FAILED
|
172
|
+
end
|
173
|
+
|
174
|
+
false
|
175
|
+
end
|
176
|
+
|
177
|
+
# create test db
|
178
|
+
def create_test_database
|
179
|
+
colour_puts "<banner>create test database</banner>"
|
180
|
+
puts
|
181
|
+
|
182
|
+
connect_to_db
|
183
|
+
|
184
|
+
colour_print " * <b>creating thinking_sphinx database</b>... "
|
185
|
+
begin
|
186
|
+
ActiveRecord::Base.connection.create_database('thinking_sphinx')
|
187
|
+
colour_puts "<green>successful</green>"
|
188
|
+
puts
|
189
|
+
return true
|
190
|
+
rescue ActiveRecord::StatementInvalid
|
191
|
+
if $!.message[/database exists/]
|
192
|
+
colour_puts "<green>successful</green> (database already existed)"
|
193
|
+
puts
|
194
|
+
return true
|
195
|
+
else
|
196
|
+
colour_puts "<red>failed</red>"
|
197
|
+
colour_puts CREATE_DATABASE_FAILED
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
false
|
202
|
+
end
|
203
|
+
|
204
|
+
# project
|
205
|
+
def ts_root
|
206
|
+
File.expand_path(File.dirname(__FILE__))
|
207
|
+
end
|
208
|
+
|
209
|
+
def specs
|
210
|
+
ts_root / 'spec'
|
211
|
+
end
|
212
|
+
|
213
|
+
def db_yml
|
214
|
+
specs / 'fixtures' / 'database.yml'
|
215
|
+
end
|
216
|
+
|
217
|
+
def mysql_adapter
|
218
|
+
defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'
|
219
|
+
end
|
220
|
+
|
221
|
+
def connect_to_db
|
222
|
+
config = YAML.load_file(db_yml)
|
223
|
+
config.update(:adapter => mysql_adapter, :database => 'test')
|
224
|
+
config.symbolize_keys!
|
225
|
+
|
226
|
+
ActiveRecord::Base.establish_connection(config)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
class String
|
237
|
+
def /(other)
|
238
|
+
"#{self}/#{other}"
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
module ContributeHelper
|
243
|
+
class Dependency
|
244
|
+
def self.name(name=nil)
|
245
|
+
if name then @name = name else @name end
|
246
|
+
end
|
247
|
+
|
248
|
+
attr_reader :location
|
249
|
+
|
250
|
+
def initialize
|
251
|
+
@found = false
|
252
|
+
@location = nil
|
253
|
+
end
|
254
|
+
|
255
|
+
def name; self.class.name end
|
256
|
+
|
257
|
+
def check; false end
|
258
|
+
def check!
|
259
|
+
@found = check
|
260
|
+
end
|
261
|
+
|
262
|
+
def found?
|
263
|
+
@found
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
class Gem < Dependency
|
268
|
+
def gem_name; self.class.name end
|
269
|
+
def name; "#{super} gem" end
|
270
|
+
|
271
|
+
def check
|
272
|
+
::Gem.available? self.gem_name
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
def check_for_dependencies
|
278
|
+
colour_puts "<banner>Checking for required software</banner>"
|
279
|
+
puts
|
280
|
+
|
281
|
+
all_found = true
|
282
|
+
|
283
|
+
dependencies.each do |klass|
|
284
|
+
dep = klass.new
|
285
|
+
print " * #{dep.name}... "
|
286
|
+
dep.check!
|
287
|
+
|
288
|
+
if dep.found?
|
289
|
+
if dep.location
|
290
|
+
colour_puts "<green>found at #{dep.location}</green>"
|
291
|
+
else
|
292
|
+
colour_puts "<green>found</green>"
|
293
|
+
end
|
294
|
+
else
|
295
|
+
all_found &= false
|
296
|
+
colour_puts "<red>not found</red>"
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
puts
|
301
|
+
|
302
|
+
if !all_found
|
303
|
+
print "You may wish to try setting additional options. Use ./contribute.rb -h for details"
|
304
|
+
puts
|
305
|
+
end
|
306
|
+
|
307
|
+
all_found
|
308
|
+
end
|
309
|
+
|
310
|
+
def colourise_output?
|
311
|
+
@colourise_output = !!(RUBY_PLATFORM !~ /mswin/ || defined?(Win32::Console::ANSI)) if @colourise_output.nil?
|
312
|
+
@colourise_output
|
313
|
+
end
|
314
|
+
|
315
|
+
DEFAULT_TERMINAL_COLORS = "\e[0m\e[37m\e[40m"
|
316
|
+
MONOCHROME_OUTPUT = "\\1"
|
317
|
+
def subs_colour(data)
|
318
|
+
data = data.gsub(%r{<b>(.*?)</b>}m, colourise_output? ? "\e[1m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
|
319
|
+
data.gsub!(%r{<red>(.*?)</red>}m, colourise_output? ? "\e[1m\e[31m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
|
320
|
+
data.gsub!(%r{<green>(.*?)</green>}m, colourise_output? ? "\e[1m\e[32m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
|
321
|
+
data.gsub!(%r{<yellow>(.*?)</yellow>}m, colourise_output? ? "\e[1m\e[33m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
|
322
|
+
data.gsub!(%r{<banner>(.*?)</banner>}m, colourise_output? ? "\e[33m\e[44m\e[1m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
|
323
|
+
|
324
|
+
return data
|
325
|
+
end
|
326
|
+
|
327
|
+
def colour_puts(text)
|
328
|
+
puts subs_colour(text)
|
329
|
+
end
|
330
|
+
|
331
|
+
def colour_print(text)
|
332
|
+
print subs_colour(text)
|
333
|
+
end
|
334
|
+
|
335
|
+
|
336
|
+
def wait!
|
337
|
+
colour_puts "<b>Hit Enter to continue, or Ctrl-C to quit.</b>"
|
338
|
+
STDIN.readline
|
339
|
+
rescue Interrupt
|
340
|
+
exit!
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
module Dependencies
|
345
|
+
class Mysql < ContributeHelper::Gem
|
346
|
+
name(defined?(JRUBY_VERSION) ? 'jdbc-mysql' : 'mysql')
|
347
|
+
end
|
348
|
+
|
349
|
+
class Rspec < ContributeHelper::Gem
|
350
|
+
name 'rspec'
|
351
|
+
end
|
352
|
+
|
353
|
+
class Cucumber < ContributeHelper::Gem
|
354
|
+
name 'cucumber'
|
355
|
+
end
|
356
|
+
|
357
|
+
class Yard < ContributeHelper::Gem
|
358
|
+
name 'yard'
|
359
|
+
end
|
360
|
+
|
361
|
+
class Jeweler < ContributeHelper::Gem
|
362
|
+
name 'jeweler'
|
363
|
+
end
|
364
|
+
|
365
|
+
class AR < ContributeHelper::Gem
|
366
|
+
name 'activerecord'
|
367
|
+
end
|
368
|
+
|
369
|
+
class Ginger < ContributeHelper::Gem
|
370
|
+
name(OPTIONS.has_key?(:ginger) ? OPTIONS[:ginger] : 'ginger')
|
371
|
+
end
|
372
|
+
|
373
|
+
class Sphinx < ContributeHelper::Dependency
|
374
|
+
name 'sphinx'
|
375
|
+
|
376
|
+
def check
|
377
|
+
app_name = OPTIONS.has_key?(:sphinx) ? OPTIONS[:sphinx] : 'searchd'
|
378
|
+
app_name << '.exe' if RUBY_PLATFORM =~ /mswin/ && app_name[-4, 4] != '.exe'
|
379
|
+
|
380
|
+
!(@location = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| File.join(path, app_name) }.find { |path| File.file?(path) && File.executable?(path) }).nil?
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
Contribute.new.show
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: "--require features/support/env.rb --require features/step_definitions/alpha_steps.rb --require features/step_definitions/beta_steps.rb --require features/step_definitions/common_steps.rb --require features/step_definitions/extensible_delta_indexing_steps.rb --require features/step_definitions/facet_steps.rb --require features/step_definitions/find_arguments_steps.rb --require features/step_definitions/gamma_steps.rb --require features/step_definitions/scope_steps.rb --require features/step_definitions/search_steps.rb --require features/step_definitions/sphinx_steps.rb"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Abstract inheritance
|
2
|
+
In order to use Thinking Sphinx in complex situations
|
3
|
+
As a developer
|
4
|
+
I want to define indexes on subclasses of abstract models
|
5
|
+
|
6
|
+
Scenario: Searching on subclasses of abstract models
|
7
|
+
Given Sphinx is running
|
8
|
+
And I am searching on music
|
9
|
+
When I search
|
10
|
+
Then I should get 3 results
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: Searching on a single model
|
2
|
+
In order to use search models with non-integer primary keys
|
3
|
+
A developer
|
4
|
+
Should be able to search on a single model
|
5
|
+
|
6
|
+
Scenario: Searching using a basic query
|
7
|
+
Given Sphinx is running
|
8
|
+
And I am searching on robots
|
9
|
+
When I search for Sizzle
|
10
|
+
Then I should get 2 results
|
11
|
+
|
12
|
+
Scenario: Searching using another basic query
|
13
|
+
Given Sphinx is running
|
14
|
+
And I am searching on robots
|
15
|
+
When I search for fritz
|
16
|
+
Then I should get 1 result
|
17
|
+
|
18
|
+
Scenario: Deleting an instance
|
19
|
+
Given Sphinx is running
|
20
|
+
And I am searching on robots
|
21
|
+
When I search for Expendable
|
22
|
+
Then I should get 1 result
|
23
|
+
|
24
|
+
When I destroy robot Expendable
|
25
|
+
And I wait for Sphinx to catch up
|
26
|
+
And I search for Expendable
|
27
|
+
Then I should get 0 results
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: Handle not-quite-supported column types as attributes
|
2
|
+
In order for Thinking Sphinx to be more understanding with model structures
|
3
|
+
The plugin
|
4
|
+
Should be able to use translatable columns as attributes
|
5
|
+
|
6
|
+
Scenario: Decimals as floats
|
7
|
+
Given Sphinx is running
|
8
|
+
And I am searching on alphas
|
9
|
+
When I filter between 1.0 and 3.0 on cost
|
10
|
+
Then I should get 2 results
|
11
|
+
|
12
|
+
Scenario: Dates as Datetimes
|
13
|
+
Given Sphinx is running
|
14
|
+
And I am searching on alphas
|
15
|
+
When I filter between 1 and 3 days ago on created_on
|
16
|
+
Then I should get 2 results
|
17
|
+
|
18
|
+
Scenario: Timestamps as Datetimes
|
19
|
+
Given Sphinx is running
|
20
|
+
And I am searching on alphas
|
21
|
+
When I filter between 1 and 3 days ago on created_at
|
22
|
+
Then I should get 2 results
|