thinking-sphinx 1.3.16 → 1.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/README.textile +4 -0
  2. data/VERSION +1 -1
  3. data/features/{support → thinking_sphinx}/database.example.yml +0 -0
  4. data/features/thinking_sphinx/database.yml +4 -0
  5. data/features/{support → thinking_sphinx}/db/fixtures/alphas.rb +0 -0
  6. data/features/{support → thinking_sphinx}/db/fixtures/authors.rb +0 -0
  7. data/features/{support → thinking_sphinx}/db/fixtures/betas.rb +0 -0
  8. data/features/{support → thinking_sphinx}/db/fixtures/boxes.rb +0 -0
  9. data/features/{support → thinking_sphinx}/db/fixtures/categories.rb +0 -0
  10. data/features/{support → thinking_sphinx}/db/fixtures/cats.rb +0 -0
  11. data/features/{support → thinking_sphinx}/db/fixtures/comments.rb +1 -1
  12. data/features/{support → thinking_sphinx}/db/fixtures/developers.rb +2 -0
  13. data/features/{support → thinking_sphinx}/db/fixtures/dogs.rb +0 -0
  14. data/features/{support → thinking_sphinx}/db/fixtures/extensible_betas.rb +0 -0
  15. data/features/{support → thinking_sphinx}/db/fixtures/foxes.rb +0 -0
  16. data/features/{support → thinking_sphinx}/db/fixtures/gammas.rb +0 -0
  17. data/features/{support → thinking_sphinx}/db/fixtures/music.rb +0 -0
  18. data/features/{support → thinking_sphinx}/db/fixtures/people.rb +0 -0
  19. data/features/{support → thinking_sphinx}/db/fixtures/posts.rb +0 -0
  20. data/features/{support → thinking_sphinx}/db/fixtures/robots.rb +0 -0
  21. data/features/{support → thinking_sphinx}/db/fixtures/tags.rb +0 -0
  22. data/features/{support → thinking_sphinx}/db/migrations/create_alphas.rb +0 -0
  23. data/features/{support → thinking_sphinx}/db/migrations/create_animals.rb +0 -0
  24. data/features/{support → thinking_sphinx}/db/migrations/create_authors.rb +0 -0
  25. data/features/{support → thinking_sphinx}/db/migrations/create_authors_posts.rb +0 -0
  26. data/features/{support → thinking_sphinx}/db/migrations/create_betas.rb +0 -0
  27. data/features/{support → thinking_sphinx}/db/migrations/create_boxes.rb +0 -0
  28. data/features/{support → thinking_sphinx}/db/migrations/create_categories.rb +0 -0
  29. data/features/{support → thinking_sphinx}/db/migrations/create_comments.rb +0 -0
  30. data/features/{support → thinking_sphinx}/db/migrations/create_developers.rb +0 -2
  31. data/features/{support → thinking_sphinx}/db/migrations/create_extensible_betas.rb +0 -0
  32. data/features/{support → thinking_sphinx}/db/migrations/create_gammas.rb +0 -0
  33. data/features/{support → thinking_sphinx}/db/migrations/create_genres.rb +0 -0
  34. data/features/{support → thinking_sphinx}/db/migrations/create_music.rb +0 -0
  35. data/features/{support → thinking_sphinx}/db/migrations/create_people.rb +0 -0
  36. data/features/{support → thinking_sphinx}/db/migrations/create_posts.rb +0 -0
  37. data/features/{support → thinking_sphinx}/db/migrations/create_robots.rb +0 -0
  38. data/features/{support → thinking_sphinx}/db/migrations/create_taggings.rb +0 -0
  39. data/features/{support → thinking_sphinx}/db/migrations/create_tags.rb +0 -0
  40. data/features/{support → thinking_sphinx}/models/alpha.rb +0 -0
  41. data/features/{support → thinking_sphinx}/models/animal.rb +0 -0
  42. data/features/{support → thinking_sphinx}/models/author.rb +0 -0
  43. data/features/{support → thinking_sphinx}/models/beta.rb +0 -0
  44. data/features/{support → thinking_sphinx}/models/box.rb +0 -0
  45. data/features/{support → thinking_sphinx}/models/cat.rb +0 -0
  46. data/features/{support → thinking_sphinx}/models/category.rb +0 -0
  47. data/features/{support → thinking_sphinx}/models/comment.rb +0 -0
  48. data/features/{support → thinking_sphinx}/models/developer.rb +2 -2
  49. data/features/{support → thinking_sphinx}/models/dog.rb +0 -0
  50. data/features/{support → thinking_sphinx}/models/extensible_beta.rb +1 -1
  51. data/features/{support → thinking_sphinx}/models/fox.rb +0 -0
  52. data/features/{support → thinking_sphinx}/models/gamma.rb +0 -0
  53. data/features/{support → thinking_sphinx}/models/genre.rb +0 -0
  54. data/features/{support → thinking_sphinx}/models/medium.rb +0 -0
  55. data/features/{support → thinking_sphinx}/models/music.rb +0 -0
  56. data/features/{support → thinking_sphinx}/models/person.rb +0 -0
  57. data/features/{support → thinking_sphinx}/models/post.rb +0 -0
  58. data/features/{support → thinking_sphinx}/models/robot.rb +0 -0
  59. data/features/{support → thinking_sphinx}/models/tag.rb +0 -0
  60. data/features/{support → thinking_sphinx}/models/tagging.rb +0 -0
  61. data/lib/cucumber/thinking_sphinx/internal_world.rb +4 -4
  62. data/lib/thinking_sphinx.rb +11 -1
  63. data/lib/thinking_sphinx/active_record.rb +12 -5
  64. data/lib/thinking_sphinx/context.rb +7 -4
  65. data/lib/thinking_sphinx/deltas/default_delta.rb +1 -1
  66. data/lib/thinking_sphinx/index/builder.rb +6 -6
  67. data/lib/thinking_sphinx/index/faux_column.rb +4 -0
  68. data/lib/thinking_sphinx/search.rb +3 -1
  69. data/lib/thinking_sphinx/source/internal_properties.rb +0 -1
  70. data/spec/thinking_sphinx/active_record/delta_spec.rb +1 -1
  71. data/spec/thinking_sphinx/active_record_spec.rb +6 -10
  72. data/spec/thinking_sphinx/index/builder_spec.rb +30 -30
  73. data/spec/thinking_sphinx/index/faux_column_spec.rb +7 -1
  74. data/spec/thinking_sphinx_spec.rb +27 -0
  75. data/tasks/distribution.rb +7 -0
  76. data/tasks/testing.rb +4 -0
  77. metadata +174 -75
  78. data/features/support/database.yml +0 -5
data/README.textile CHANGED
@@ -159,3 +159,7 @@ Since I first released this library, there's been quite a few people who have su
159
159
  * Dimitri Krassovski
160
160
  * Sergey Kojin
161
161
  * Brad Sumersford
162
+ * Amir Yalon
163
+ * Edgars Beigarts
164
+ * Ivan Ukhov
165
+ * Tomáš Pospíšek
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.16
1
+ 1.3.17
@@ -0,0 +1,4 @@
1
+ username: root
2
+ host: localhost
3
+ pool: 1
4
+ min_messages: warning
@@ -4,7 +4,7 @@ Comment.create(
4
4
  :content => "+1",
5
5
  :post_id => 1,
6
6
  :category_id => 1
7
- ).update_attribute(:created_at, Time.utc(2001, 01, 01))
7
+ ).update_attribute(:created_at, Time.utc(2001, 01, 01).getlocal)
8
8
 
9
9
  Comment.create(
10
10
  :name => "Menno",
@@ -1,3 +1,5 @@
1
+ require 'faker'
2
+
1
3
  Developer.create :name => "Pat Allan", :city => "Melbourne", :state => "Victoria", :country => "Australia", :age => 26
2
4
 
3
5
  2.times do
@@ -1,5 +1,3 @@
1
- require 'faker'
2
-
3
1
  ActiveRecord::Base.connection.create_table :developers, :force => true do |t|
4
2
  t.column :name, :string, :null => false
5
3
  t.column :city, :string
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- require 'features/support/models/tag'
2
- require 'features/support/models/tagging'
1
+ require 'features/thinking_sphinx/models/tag'
2
+ require 'features/thinking_sphinx/models/tagging'
3
3
 
4
4
  class Developer < ActiveRecord::Base
5
5
  has_many :taggings, :as => :taggable
File without changes
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "..", "lib", "generic_delta_handler")
1
+ require 'features/support/lib/generic_delta_handler'
2
2
 
3
3
  class ExtensibleBeta < ActiveRecord::Base
4
4
  define_index do
File without changes
File without changes
@@ -10,10 +10,10 @@ module Cucumber
10
10
 
11
11
  def initialize
12
12
  @temporary_directory = "#{Dir.pwd}/tmp"
13
- @migrations_directory = "features/support/db/migrations"
14
- @models_directory = "features/support/models"
15
- @fixtures_directory = "features/support/db/fixtures"
16
- @database_file = "features/support/database.yml"
13
+ @migrations_directory = "features/thinking_sphinx/db/migrations"
14
+ @models_directory = "features/thinking_sphinx/models"
15
+ @fixtures_directory = "features/thinking_sphinx/db/fixtures"
16
+ @database_file = "features/thinking_sphinx/database.yml"
17
17
 
18
18
  @adapter = ENV['DATABASE'] || 'mysql'
19
19
  @database = 'thinking_sphinx'
@@ -70,7 +70,7 @@ module ThinkingSphinx
70
70
  if @@context.nil?
71
71
  @@sphinx_mutex.synchronize do
72
72
  if @@context.nil?
73
- @@context = ThinkingSphinx::Context.new
73
+ set_context
74
74
  @@context.prepare
75
75
  end
76
76
  end
@@ -78,12 +78,22 @@ module ThinkingSphinx
78
78
 
79
79
  @@context
80
80
  end
81
+
82
+ def self.set_context(*classes)
83
+ @@context = ThinkingSphinx::Context.new(*classes)
84
+ end
81
85
 
82
86
  def self.reset_context!
83
87
  @@sphinx_mutex.synchronize do
84
88
  @@context = nil
85
89
  end
86
90
  end
91
+
92
+ def self.indexed_models=(classes = [])
93
+ @@sphinx_mutex.synchronize do
94
+ set_context *classes
95
+ end
96
+ end
87
97
 
88
98
  def self.unique_id_expression(offset = nil)
89
99
  "* #{context.indexed_models.size} + #{offset || 0}"
@@ -154,9 +154,7 @@ module ThinkingSphinx
154
154
  end
155
155
 
156
156
  self.sphinx_index_blocks << lambda {
157
- index = ThinkingSphinx::Index::Builder.generate self, name, &block
158
- add_sphinx_callbacks_and_extend(index.delta?)
159
- add_sphinx_index index
157
+ add_sphinx_index name, &block
160
158
  }
161
159
 
162
160
  include ThinkingSphinx::ActiveRecord::Scopes
@@ -188,9 +186,18 @@ module ThinkingSphinx
188
186
  end
189
187
  end
190
188
 
191
- def add_sphinx_index(index)
189
+ def add_sphinx_index(name, &block)
190
+ index = ThinkingSphinx::Index::Builder.generate self, name, &block
191
+
192
+ unless sphinx_indexes.any? { |i| i.name == index.name }
193
+ add_sphinx_callbacks_and_extend(index.delta?)
194
+ insert_sphinx_index index
195
+ end
196
+ end
197
+
198
+ def insert_sphinx_index(index)
192
199
  self.sphinx_indexes << index
193
- subclasses.each { |klass| klass.add_sphinx_index(index) }
200
+ subclasses.each { |klass| klass.insert_sphinx_index(index) }
194
201
  end
195
202
 
196
203
  def has_sphinx_indexes?
@@ -1,8 +1,11 @@
1
1
  class ThinkingSphinx::Context
2
2
  attr_reader :indexed_models
3
3
 
4
- def initialize
4
+ def initialize(*models)
5
5
  @indexed_models = []
6
+ models.each do |model|
7
+ add_indexed_model model
8
+ end
6
9
  end
7
10
 
8
11
  def prepare
@@ -47,12 +50,12 @@ class ThinkingSphinx::Context
47
50
  ThinkingSphinx::Configuration.instance.model_directories.each do |base|
48
51
  Dir["#{base}**/*.rb"].each do |file|
49
52
  model_name = file.gsub(/^#{base}([\w_\/\\]+)\.rb/, '\1')
50
-
53
+
51
54
  next if model_name.nil?
52
55
  next if ::ActiveRecord::Base.send(:subclasses).detect { |model|
53
- model.name == model_name
56
+ model.name == model_name.camelize
54
57
  }
55
-
58
+
56
59
  begin
57
60
  model_name.camelize.constantize
58
61
  rescue LoadError
@@ -44,7 +44,7 @@ module ThinkingSphinx
44
44
  config = ThinkingSphinx::Configuration.instance
45
45
  rotate = ThinkingSphinx.sphinx_running? ? "--rotate" : ""
46
46
 
47
- output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} #{rotate} #{model.delta_index_names.join(' ')}`
47
+ output = `#{config.bin_path}#{config.indexer_binary_name} --config '#{config.config_file}' #{rotate} #{model.delta_index_names.join(' ')}`
48
48
  puts(output) unless ThinkingSphinx.suppress_delta_output?
49
49
  end
50
50
 
@@ -119,13 +119,13 @@ module ThinkingSphinx
119
119
  # database.
120
120
  #
121
121
  # Attributes are limited to the following types: integers, floats,
122
- # datetimes (converted to timestamps), booleans and strings. Don't
123
- # forget that Sphinx converts string attributes to integers, which are
124
- # useful for sorting, but that's about it.
122
+ # datetimes (converted to timestamps), booleans, strings and MVAs
123
+ # (:multi). Don't forget that Sphinx converts string attributes to
124
+ # integers, which are useful for sorting, but that's about it.
125
125
  #
126
- # You can also have a collection of integers for multi-value attributes
127
- # (MVAs). Generally these would be through a has_many relationship,
128
- # like in this example:
126
+ # Collection of integers are known as multi-value attributes (MVAs).
127
+ # Generally these would be through a has_many relationship, like in this
128
+ # example:
129
129
  #
130
130
  # has posts(:id), :as => :post_ids
131
131
  #
@@ -50,6 +50,10 @@ module ThinkingSphinx
50
50
  @name.is_a?(String) && @stack.empty?
51
51
  end
52
52
 
53
+ def to_ary
54
+ [self]
55
+ end
56
+
53
57
  # This handles any 'invalid' method calls and sets them as the name,
54
58
  # and pushing the previous name into the stack. The object returns
55
59
  # itself.
@@ -210,7 +210,9 @@ module ThinkingSphinx
210
210
  return options[:index] if options[:index]
211
211
  return '*' if classes.empty?
212
212
 
213
- classes.collect { |klass| klass.sphinx_index_names }.flatten.join(',')
213
+ classes.collect { |klass|
214
+ klass.sphinx_index_names
215
+ }.flatten.uniq.join(',')
214
216
  end
215
217
 
216
218
  def each_with_groupby_and_count(&block)
@@ -5,7 +5,6 @@ module ThinkingSphinx
5
5
  add_internal_attribute :sphinx_internal_id, nil,
6
6
  @model.primary_key_for_sphinx.to_sym
7
7
  add_internal_attribute :class_crc, :integer, crc_column, true
8
- add_internal_attribute :subclass_crcs, :multi, subclasses_to_s
9
8
  add_internal_attribute :sphinx_deleted, :integer, "0"
10
9
 
11
10
  add_internal_facet :class_crc
@@ -106,7 +106,7 @@ describe "ThinkingSphinx::ActiveRecord::Delta" do
106
106
 
107
107
  it "should call indexer for the delta index" do
108
108
  Person.sphinx_indexes.first.delta_object.should_receive(:`).with(
109
- "#{ThinkingSphinx::Configuration.instance.bin_path}indexer --config #{ThinkingSphinx::Configuration.instance.config_file} --rotate person_delta"
109
+ "#{ThinkingSphinx::Configuration.instance.bin_path}indexer --config '#{ThinkingSphinx::Configuration.instance.config_file}' --rotate person_delta"
110
110
  )
111
111
 
112
112
  @person.send(:index_delta)
@@ -149,7 +149,7 @@ describe ThinkingSphinx::ActiveRecord do
149
149
  Beta.should_receive(:before_save).with(:toggle_delta).once
150
150
 
151
151
  Beta.define_index { indexes :name }
152
- Beta.define_index {
152
+ Beta.define_index('foo') {
153
153
  indexes :name
154
154
  set_property :delta => true
155
155
  }
@@ -193,7 +193,7 @@ describe ThinkingSphinx::ActiveRecord do
193
193
  Beta.should_receive(:after_commit).with(:index_delta).once
194
194
 
195
195
  Beta.define_index { indexes :name }
196
- Beta.define_index {
196
+ Beta.define_index('foo') {
197
197
  indexes :name
198
198
  set_property :delta => true
199
199
  }
@@ -541,11 +541,9 @@ describe ThinkingSphinx::ActiveRecord do
541
541
 
542
542
  describe '.core_index_names' do
543
543
  it "should return each index's core name" do
544
- Alpha.define_index { indexes :name }
545
- Alpha.define_index { indexes :name }
544
+ Alpha.define_index('foo') { indexes :name }
545
+ Alpha.define_index('bar') { indexes :name }
546
546
  Alpha.define_indexes
547
- Alpha.sphinx_indexes.first.name = 'foo'
548
- Alpha.sphinx_indexes.last.name = 'bar'
549
547
 
550
548
  Alpha.core_index_names.should == ['foo_core', 'bar_core']
551
549
  end
@@ -553,12 +551,10 @@ describe ThinkingSphinx::ActiveRecord do
553
551
 
554
552
  describe '.delta_index_names' do
555
553
  it "should return index delta names, for indexes with deltas enabled" do
556
- Alpha.define_index { indexes :name }
557
- Alpha.define_index { indexes :name }
554
+ Alpha.define_index('foo') { indexes :name }
555
+ Alpha.define_index('bar') { indexes :name }
558
556
  Alpha.define_indexes
559
- Alpha.sphinx_indexes.first.name = 'foo'
560
557
  Alpha.sphinx_indexes.first.delta_object = stub('delta')
561
- Alpha.sphinx_indexes.last.name = 'bar'
562
558
 
563
559
  Alpha.delta_index_names.should == ['foo_delta']
564
560
  end
@@ -31,10 +31,10 @@ describe ThinkingSphinx::Index::Builder do
31
31
  @source.fields[1].unique_name.should == :last_name
32
32
  end
33
33
 
34
- it "should have two attributes alongside the four internal ones" do
35
- @source.attributes.length.should == 6
36
- @source.attributes[4].unique_name.should == :birthday
37
- @source.attributes[5].unique_name.should == :internal_id
34
+ it "should have two attributes alongside the three internal ones" do
35
+ @source.attributes.length.should == 5
36
+ @source.attributes[3].unique_name.should == :birthday
37
+ @source.attributes[4].unique_name.should == :internal_id
38
38
  end
39
39
 
40
40
  it "should have one condition" do
@@ -95,8 +95,8 @@ describe ThinkingSphinx::Index::Builder do
95
95
  @source.fields.length.should == 1
96
96
  end
97
97
 
98
- it "should have one attribute alongside the four internal ones" do
99
- @source.attributes.length.should == 5
98
+ it "should have one attribute alongside the three internal ones" do
99
+ @source.attributes.length.should == 4
100
100
  end
101
101
 
102
102
  it "should set the attribute name to have the _sort suffix" do
@@ -126,8 +126,8 @@ describe ThinkingSphinx::Index::Builder do
126
126
  @source.fields.length.should == 1
127
127
  end
128
128
 
129
- it "should have one attribute alongside the four internal ones" do
130
- @source.attributes.length.should == 5
129
+ it "should have one attribute alongside the three internal ones" do
130
+ @source.attributes.length.should == 4
131
131
  end
132
132
 
133
133
  it "should set the attribute name to have the _facet suffix" do
@@ -158,8 +158,8 @@ describe ThinkingSphinx::Index::Builder do
158
158
  Alpha.sphinx_facets.delete_at(-1)
159
159
  end
160
160
 
161
- it "should have just one attribute alongside the four internal ones" do
162
- @source.attributes.length.should == 5
161
+ it "should have just one attribute alongside the three internal ones" do
162
+ @source.attributes.length.should == 4
163
163
  end
164
164
  end
165
165
 
@@ -177,8 +177,8 @@ describe ThinkingSphinx::Index::Builder do
177
177
  Person.sphinx_facets.delete_at(-1)
178
178
  end
179
179
 
180
- it "should have just one attribute alongside the four internal ones" do
181
- @source.attributes.length.should == 5
180
+ it "should have just one attribute alongside the three internal ones" do
181
+ @source.attributes.length.should == 4
182
182
  end
183
183
  end
184
184
 
@@ -196,8 +196,8 @@ describe ThinkingSphinx::Index::Builder do
196
196
  Beta.sphinx_facets.delete_at(-1)
197
197
  end
198
198
 
199
- it "should have just one attribute alongside the four internal ones" do
200
- @source.attributes.length.should == 5
199
+ it "should have just one attribute alongside the three internal ones" do
200
+ @source.attributes.length.should == 4
201
201
  end
202
202
  end
203
203
 
@@ -215,8 +215,8 @@ describe ThinkingSphinx::Index::Builder do
215
215
  Alpha.sphinx_facets.delete_at(-1)
216
216
  end
217
217
 
218
- it "should have just one attribute alongside the four internal ones" do
219
- @source.attributes.length.should == 5
218
+ it "should have just one attribute alongside the three internal ones" do
219
+ @source.attributes.length.should == 4
220
220
  end
221
221
  end
222
222
 
@@ -234,8 +234,8 @@ describe ThinkingSphinx::Index::Builder do
234
234
  Person.sphinx_facets.delete_at(-1)
235
235
  end
236
236
 
237
- it "should have two attributes alongside the four internal ones" do
238
- @source.attributes.length.should == 6
237
+ it "should have two attributes alongside the three internal ones" do
238
+ @source.attributes.length.should == 5
239
239
  end
240
240
 
241
241
  it "should set the facet attribute name to have the _facet suffix" do
@@ -266,8 +266,8 @@ describe ThinkingSphinx::Index::Builder do
266
266
  Person.sphinx_facets.delete_at(-1)
267
267
  end
268
268
 
269
- it "should have two attributes alongside the four internal ones" do
270
- @source.attributes.length.should == 6
269
+ it "should have two attributes alongside the three internal ones" do
270
+ @source.attributes.length.should == 5
271
271
  end
272
272
 
273
273
  it "should set the facet attribute name to have the _facet suffix" do
@@ -305,8 +305,8 @@ describe ThinkingSphinx::Index::Builder do
305
305
  @source.fields.length.should == 1
306
306
  end
307
307
 
308
- it "should have one attribute alongside the four internal ones" do
309
- @source.attributes.length.should == 5
308
+ it "should have one attribute alongside the three internal ones" do
309
+ @source.attributes.length.should == 4
310
310
  end
311
311
 
312
312
  it "should set the attribute name to have the _facet suffix" do
@@ -365,10 +365,10 @@ describe ThinkingSphinx::Index::Builder do
365
365
  @source.fields[1].unique_name.should == :last_name
366
366
  end
367
367
 
368
- it "should have two attributes alongside the four internal ones" do
369
- @source.attributes.length.should == 6
370
- @source.attributes[4].unique_name.should == :birthday
371
- @source.attributes[5].unique_name.should == :internal_id
368
+ it "should have two attributes alongside the three internal ones" do
369
+ @source.attributes.length.should == 5
370
+ @source.attributes[3].unique_name.should == :birthday
371
+ @source.attributes[4].unique_name.should == :internal_id
372
372
  end
373
373
  end
374
374
 
@@ -401,13 +401,13 @@ describe ThinkingSphinx::Index::Builder do
401
401
  end
402
402
  end
403
403
 
404
- it "should have two attributes alongside the eight internal ones" do
405
- @index.attributes.length.should == 10
404
+ it "should have two attributes alongside the six internal ones" do
405
+ @index.attributes.length.should == 8
406
406
  end
407
407
 
408
- it "should have one attribute in each source alongside the four internal ones" do
408
+ it "should have one attribute in each source alongside the three internal ones" do
409
409
  @index.sources.each do |source|
410
- source.attributes.length.should == 5
410
+ source.attributes.length.should == 4
411
411
  end
412
412
  end
413
413
  end
@@ -27,4 +27,10 @@ describe ThinkingSphinx::Index::FauxColumn do
27
27
  ]
28
28
  end
29
29
  end
30
- end
30
+
31
+ describe '#to_ary' do
32
+ it "should return an array with the instance inside it" do
33
+ subject.to_ary.should == [subject]
34
+ end
35
+ end
36
+ end
@@ -16,6 +16,22 @@ describe ThinkingSphinx do
16
16
  end
17
17
  end
18
18
 
19
+ describe '.set_context' do
20
+ before :each do
21
+ ThinkingSphinx.reset_context!
22
+ end
23
+
24
+ it "should set the context instance" do
25
+ ThinkingSphinx.set_context
26
+ ThinkingSphinx.context.should be_a(ThinkingSphinx::Context)
27
+ end
28
+
29
+ it "should pass through any given arguments to the initialiser" do
30
+ ThinkingSphinx::Context.should_receive(:new).with(Alpha, Beta)
31
+ ThinkingSphinx.set_context Alpha, Beta
32
+ end
33
+ end
34
+
19
35
  describe '.reset_context!' do
20
36
  it "should remove the existing Context instance" do
21
37
  existing = ThinkingSphinx.context
@@ -27,6 +43,17 @@ describe ThinkingSphinx do
27
43
  end
28
44
  end
29
45
 
46
+ describe '.indexed_models=' do
47
+ before :each do
48
+ ThinkingSphinx.reset_context!
49
+ end
50
+
51
+ it "should set the indexed models for the context" do
52
+ ThinkingSphinx.indexed_models = [Alpha, Beta]
53
+ ThinkingSphinx.context.indexed_models.should == ['Alpha', 'Beta']
54
+ end
55
+ end
56
+
30
57
  describe '.define_indexes?' do
31
58
  it "should define indexes by default" do
32
59
  ThinkingSphinx.define_indexes?.should be_true
@@ -31,6 +31,13 @@ Jeweler::Tasks.new do |gem|
31
31
  gem.add_dependency 'riddle', '>= 1.0.10'
32
32
  gem.add_dependency 'after_commit', '>= 1.0.6'
33
33
 
34
+ gem.add_development_dependency "yard", ">= 0"
35
+ gem.add_development_dependency "rspec", ">= 1.2.9"
36
+ gem.add_development_dependency "cucumber", ">= 0"
37
+ gem.add_development_dependency "will_paginate", "2.3.11"
38
+ gem.add_development_dependency "ginger", "1.2.0"
39
+ gem.add_development_dependency "faker", "0.3.1"
40
+
34
41
  gem.post_install_message = <<-MESSAGE
35
42
  If you're upgrading, you should read this:
36
43
  http://freelancing-god.github.com/ts/en/upgrading.html
data/tasks/testing.rb CHANGED
@@ -7,6 +7,7 @@ Spec::Rake::SpecTask.new do |t|
7
7
  t.spec_files = FileList['spec/**/*_spec.rb']
8
8
  t.spec_opts << "-c"
9
9
  end
10
+ task :spec => :check_dependencies
10
11
 
11
12
  desc "Run all feature-set configurations"
12
13
  task :features do |t|
@@ -26,6 +27,9 @@ namespace :features do
26
27
 
27
28
  add_task :mysql, "Run feature-set against MySQL"
28
29
  add_task :postgresql, "Run feature-set against PostgreSQL"
30
+
31
+ task :mysql => :check_dependencies
32
+ task :postgresql => :check_dependencies
29
33
  end
30
34
 
31
35
  desc "Generate RCov reports"
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.16
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 3
8
+ - 17
9
+ version: 1.3.17
5
10
  platform: ruby
6
11
  authors:
7
12
  - Pat Allan
@@ -9,39 +14,131 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-16 00:00:00 +11:00
17
+ date: 2010-06-05 00:00:00 +10:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: activerecord
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 15
30
+ - 6
23
31
  version: 1.15.6
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: riddle
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 0
44
+ - 10
33
45
  version: 1.0.10
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: after_commit
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 0
58
+ - 6
43
59
  version: 1.0.6
44
- version:
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: yard
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ type: :development
73
+ version_requirements: *id004
74
+ - !ruby/object:Gem::Dependency
75
+ name: rspec
76
+ prerelease: false
77
+ requirement: &id005 !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 1
83
+ - 2
84
+ - 9
85
+ version: 1.2.9
86
+ type: :development
87
+ version_requirements: *id005
88
+ - !ruby/object:Gem::Dependency
89
+ name: cucumber
90
+ prerelease: false
91
+ requirement: &id006 !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ type: :development
99
+ version_requirements: *id006
100
+ - !ruby/object:Gem::Dependency
101
+ name: will_paginate
102
+ prerelease: false
103
+ requirement: &id007 !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "="
106
+ - !ruby/object:Gem::Version
107
+ segments:
108
+ - 2
109
+ - 3
110
+ - 11
111
+ version: 2.3.11
112
+ type: :development
113
+ version_requirements: *id007
114
+ - !ruby/object:Gem::Dependency
115
+ name: ginger
116
+ prerelease: false
117
+ requirement: &id008 !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 1
123
+ - 2
124
+ - 0
125
+ version: 1.2.0
126
+ type: :development
127
+ version_requirements: *id008
128
+ - !ruby/object:Gem::Dependency
129
+ name: faker
130
+ prerelease: false
131
+ requirement: &id009 !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "="
134
+ - !ruby/object:Gem::Version
135
+ segments:
136
+ - 0
137
+ - 3
138
+ - 1
139
+ version: 0.3.1
140
+ type: :development
141
+ version_requirements: *id009
45
142
  description: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
46
143
  email: pat@freelancing-gods.com
47
144
  executables: []
@@ -113,18 +210,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
210
  requirements:
114
211
  - - ">="
115
212
  - !ruby/object:Gem::Version
213
+ segments:
214
+ - 0
116
215
  version: "0"
117
- version:
118
216
  required_rubygems_version: !ruby/object:Gem::Requirement
119
217
  requirements:
120
218
  - - ">="
121
219
  - !ruby/object:Gem::Version
220
+ segments:
221
+ - 0
122
222
  version: "0"
123
- version:
124
223
  requirements: []
125
224
 
126
225
  rubyforge_project:
127
- rubygems_version: 1.3.5
226
+ rubygems_version: 1.3.6
128
227
  signing_key:
129
228
  specification_version: 3
130
229
  summary: ActiveRecord/Rails Sphinx library
@@ -158,66 +257,66 @@ test_files:
158
257
  - features/step_definitions/search_steps.rb
159
258
  - features/step_definitions/sphinx_steps.rb
160
259
  - features/sti_searching.feature
161
- - features/support/database.example.yml
162
- - features/support/database.yml
163
- - features/support/db/fixtures/alphas.rb
164
- - features/support/db/fixtures/authors.rb
165
- - features/support/db/fixtures/betas.rb
166
- - features/support/db/fixtures/boxes.rb
167
- - features/support/db/fixtures/categories.rb
168
- - features/support/db/fixtures/cats.rb
169
- - features/support/db/fixtures/comments.rb
170
- - features/support/db/fixtures/developers.rb
171
- - features/support/db/fixtures/dogs.rb
172
- - features/support/db/fixtures/extensible_betas.rb
173
- - features/support/db/fixtures/foxes.rb
174
- - features/support/db/fixtures/gammas.rb
175
- - features/support/db/fixtures/music.rb
176
- - features/support/db/fixtures/people.rb
177
- - features/support/db/fixtures/posts.rb
178
- - features/support/db/fixtures/robots.rb
179
- - features/support/db/fixtures/tags.rb
180
- - features/support/db/migrations/create_alphas.rb
181
- - features/support/db/migrations/create_animals.rb
182
- - features/support/db/migrations/create_authors.rb
183
- - features/support/db/migrations/create_authors_posts.rb
184
- - features/support/db/migrations/create_betas.rb
185
- - features/support/db/migrations/create_boxes.rb
186
- - features/support/db/migrations/create_categories.rb
187
- - features/support/db/migrations/create_comments.rb
188
- - features/support/db/migrations/create_developers.rb
189
- - features/support/db/migrations/create_extensible_betas.rb
190
- - features/support/db/migrations/create_gammas.rb
191
- - features/support/db/migrations/create_genres.rb
192
- - features/support/db/migrations/create_music.rb
193
- - features/support/db/migrations/create_people.rb
194
- - features/support/db/migrations/create_posts.rb
195
- - features/support/db/migrations/create_robots.rb
196
- - features/support/db/migrations/create_taggings.rb
197
- - features/support/db/migrations/create_tags.rb
198
260
  - features/support/env.rb
199
261
  - features/support/lib/generic_delta_handler.rb
200
- - features/support/models/alpha.rb
201
- - features/support/models/animal.rb
202
- - features/support/models/author.rb
203
- - features/support/models/beta.rb
204
- - features/support/models/box.rb
205
- - features/support/models/cat.rb
206
- - features/support/models/category.rb
207
- - features/support/models/comment.rb
208
- - features/support/models/developer.rb
209
- - features/support/models/dog.rb
210
- - features/support/models/extensible_beta.rb
211
- - features/support/models/fox.rb
212
- - features/support/models/gamma.rb
213
- - features/support/models/genre.rb
214
- - features/support/models/medium.rb
215
- - features/support/models/music.rb
216
- - features/support/models/person.rb
217
- - features/support/models/post.rb
218
- - features/support/models/robot.rb
219
- - features/support/models/tag.rb
220
- - features/support/models/tagging.rb
262
+ - features/thinking_sphinx/database.example.yml
263
+ - features/thinking_sphinx/database.yml
264
+ - features/thinking_sphinx/db/fixtures/alphas.rb
265
+ - features/thinking_sphinx/db/fixtures/authors.rb
266
+ - features/thinking_sphinx/db/fixtures/betas.rb
267
+ - features/thinking_sphinx/db/fixtures/boxes.rb
268
+ - features/thinking_sphinx/db/fixtures/categories.rb
269
+ - features/thinking_sphinx/db/fixtures/cats.rb
270
+ - features/thinking_sphinx/db/fixtures/comments.rb
271
+ - features/thinking_sphinx/db/fixtures/developers.rb
272
+ - features/thinking_sphinx/db/fixtures/dogs.rb
273
+ - features/thinking_sphinx/db/fixtures/extensible_betas.rb
274
+ - features/thinking_sphinx/db/fixtures/foxes.rb
275
+ - features/thinking_sphinx/db/fixtures/gammas.rb
276
+ - features/thinking_sphinx/db/fixtures/music.rb
277
+ - features/thinking_sphinx/db/fixtures/people.rb
278
+ - features/thinking_sphinx/db/fixtures/posts.rb
279
+ - features/thinking_sphinx/db/fixtures/robots.rb
280
+ - features/thinking_sphinx/db/fixtures/tags.rb
281
+ - features/thinking_sphinx/db/migrations/create_alphas.rb
282
+ - features/thinking_sphinx/db/migrations/create_animals.rb
283
+ - features/thinking_sphinx/db/migrations/create_authors.rb
284
+ - features/thinking_sphinx/db/migrations/create_authors_posts.rb
285
+ - features/thinking_sphinx/db/migrations/create_betas.rb
286
+ - features/thinking_sphinx/db/migrations/create_boxes.rb
287
+ - features/thinking_sphinx/db/migrations/create_categories.rb
288
+ - features/thinking_sphinx/db/migrations/create_comments.rb
289
+ - features/thinking_sphinx/db/migrations/create_developers.rb
290
+ - features/thinking_sphinx/db/migrations/create_extensible_betas.rb
291
+ - features/thinking_sphinx/db/migrations/create_gammas.rb
292
+ - features/thinking_sphinx/db/migrations/create_genres.rb
293
+ - features/thinking_sphinx/db/migrations/create_music.rb
294
+ - features/thinking_sphinx/db/migrations/create_people.rb
295
+ - features/thinking_sphinx/db/migrations/create_posts.rb
296
+ - features/thinking_sphinx/db/migrations/create_robots.rb
297
+ - features/thinking_sphinx/db/migrations/create_taggings.rb
298
+ - features/thinking_sphinx/db/migrations/create_tags.rb
299
+ - features/thinking_sphinx/models/alpha.rb
300
+ - features/thinking_sphinx/models/animal.rb
301
+ - features/thinking_sphinx/models/author.rb
302
+ - features/thinking_sphinx/models/beta.rb
303
+ - features/thinking_sphinx/models/box.rb
304
+ - features/thinking_sphinx/models/cat.rb
305
+ - features/thinking_sphinx/models/category.rb
306
+ - features/thinking_sphinx/models/comment.rb
307
+ - features/thinking_sphinx/models/developer.rb
308
+ - features/thinking_sphinx/models/dog.rb
309
+ - features/thinking_sphinx/models/extensible_beta.rb
310
+ - features/thinking_sphinx/models/fox.rb
311
+ - features/thinking_sphinx/models/gamma.rb
312
+ - features/thinking_sphinx/models/genre.rb
313
+ - features/thinking_sphinx/models/medium.rb
314
+ - features/thinking_sphinx/models/music.rb
315
+ - features/thinking_sphinx/models/person.rb
316
+ - features/thinking_sphinx/models/post.rb
317
+ - features/thinking_sphinx/models/robot.rb
318
+ - features/thinking_sphinx/models/tag.rb
319
+ - features/thinking_sphinx/models/tagging.rb
221
320
  - spec/thinking_sphinx/active_record/delta_spec.rb
222
321
  - spec/thinking_sphinx/active_record/has_many_association_spec.rb
223
322
  - spec/thinking_sphinx/active_record/scopes_spec.rb
@@ -1,5 +0,0 @@
1
- username: thinking_sphinx
2
- host: localhost
3
- password: thinking_sphinx
4
- pool: 1
5
- min_messages: warning