freelancing-god-thinking-sphinx 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -30,6 +30,10 @@ Alternatively, install the ginger gem directly from the freelancing-god github r
30
30
 
31
31
  sudo gem sources -a http://gems.github.com
32
32
  sudo gem install freelancing-god-ginger
33
+
34
+ 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.
35
+
36
+ sudo gem install cucumber yard jeweler rspec
33
37
 
34
38
  Then set up your database:
35
39
 
@@ -148,3 +152,6 @@ Since I first released this library, there's been quite a few people who have su
148
152
  * Jeffrey Chupp
149
153
  * Rob Anderton
150
154
  * Zach Inglis
155
+ * Ward Bekker
156
+ * Brian Terlson
157
+ * Christian Aust
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 2
4
- :patch: 7
4
+ :patch: 8
@@ -281,7 +281,7 @@ module ThinkingSphinx
281
281
  # @return [Integer] Unique record id for the purposes of Sphinx.
282
282
  #
283
283
  def primary_key_for_sphinx
284
- attributes[self.class.primary_key_for_sphinx.to_s]
284
+ read_attribute(self.class.primary_key_for_sphinx)
285
285
  end
286
286
 
287
287
  def sphinx_document_id
@@ -75,7 +75,9 @@ module ThinkingSphinx
75
75
  @crc = options[:crc]
76
76
 
77
77
  @type ||= :multi unless @query_source.nil?
78
- @type = :integer if @type == :string && @crc
78
+ if @type == :string && @crc
79
+ @type = is_many? ? :multi : :integer
80
+ end
79
81
 
80
82
  source.attributes << self
81
83
  end
@@ -91,8 +91,9 @@ DESC
91
91
 
92
92
  def rake(*tasks)
93
93
  rails_env = fetch(:rails_env, "production")
94
+ rake = fetch(:rake, "rake")
94
95
  tasks.each do |t|
95
- run "cd #{current_path} && rake #{t} RAILS_ENV=#{rails_env}"
96
+ run "cd #{current_path}; #{rake} RAILS_ENV=#{rails_env} #{t}"
96
97
  end
97
98
  end
98
99
  end
@@ -95,7 +95,9 @@ module ThinkingSphinx
95
95
  return nil unless object = object.send(method)
96
96
  }
97
97
  if object.is_a?(Array)
98
- object.collect { |item| item.send(column.__name) }
98
+ object.collect { |item| item.send(column.__name) }.detect { |item|
99
+ item.to_crc32 == attribute_value
100
+ }
99
101
  else
100
102
  object.send(column.__name)
101
103
  end
@@ -198,7 +198,6 @@ module ThinkingSphinx
198
198
  # set_property :delta => true
199
199
  # set_property :field_weights => {"name" => 100}
200
200
  # set_property :order => "name ASC"
201
- # set_property :include => :picture
202
201
  # set_property :select => 'name'
203
202
  #
204
203
  # Also, the following two properties are particularly relevant for
@@ -14,6 +14,8 @@ module ThinkingSphinx
14
14
  @faceted = options[:facet]
15
15
  @admin = options[:admin]
16
16
 
17
+ @alias = @alias.to_sym unless @alias.blank?
18
+
17
19
  @columns.each { |col|
18
20
  @associations[col] = association_stack(col.__stack.clone).each { |assoc|
19
21
  assoc.join_to(source.base)
@@ -18,7 +18,7 @@ describe "ThinkingSphinx::ActiveRecord::Delta" do
18
18
 
19
19
  @beta.should have_received(:toggle_delta)
20
20
  end
21
-
21
+
22
22
  describe "suspended_delta method" do
23
23
  before :each do
24
24
  ThinkingSphinx.stub_method(:deltas_enabled? => true)
@@ -53,6 +53,35 @@ describe ThinkingSphinx::Index::Builder do
53
53
  end
54
54
  end
55
55
 
56
+ describe 'aliased field' do
57
+ before :each do
58
+ @index = ThinkingSphinx::Index::Builder.generate(Person) do
59
+ indexes first_name, :as => 'name'
60
+ end
61
+
62
+ @source = @index.sources.first
63
+ end
64
+
65
+ it "should store the alias as a symbol for consistency" do
66
+ @source.fields.last.unique_name.should == :name
67
+ end
68
+ end
69
+
70
+ describe 'aliased attribute' do
71
+ before :each do
72
+ @index = ThinkingSphinx::Index::Builder.generate(Person) do
73
+ indexes first_name
74
+ has :id, :as => 'real_id'
75
+ end
76
+
77
+ @source = @index.sources.first
78
+ end
79
+
80
+ it "should store the alias as a symbol for consistency" do
81
+ @source.attributes.last.unique_name.should == :real_id
82
+ end
83
+ end
84
+
56
85
  describe "sortable field" do
57
86
  before :each do
58
87
  @index = ThinkingSphinx::Index::Builder.generate(Person) do
@@ -223,6 +252,77 @@ describe ThinkingSphinx::Index::Builder do
223
252
  end
224
253
  end
225
254
 
255
+ describe 'faceted manual MVA' do
256
+ before :each do
257
+ @index = ThinkingSphinx::Index::Builder.generate(Person) do
258
+ indexes first_name
259
+ has 'SQL STATEMENT', :type => :multi, :as => :sql, :facet => true
260
+ end
261
+
262
+ @source = @index.sources.first
263
+ end
264
+
265
+ after :each do
266
+ Person.sphinx_facets.delete_at(-1)
267
+ end
268
+
269
+ it "should have two attributes alongside the four internal ones" do
270
+ @source.attributes.length.should == 6
271
+ end
272
+
273
+ it "should set the facet attribute name to have the _facet suffix" do
274
+ @source.attributes.last.unique_name.should == :sql_facet
275
+ end
276
+
277
+ it "should keep the original attribute's name set as requested" do
278
+ @source.attributes[-2].unique_name.should == :sql
279
+ end
280
+
281
+ it "should set the attribute type to multi" do
282
+ @source.attributes.last.type.should == :multi
283
+ end
284
+
285
+ it "should set the attribute column to be the same as the field" do
286
+ @source.attributes.last.columns.length.should == 1
287
+ @source.attributes.last.columns.first.__name.should == 'SQL STATEMENT'
288
+ end
289
+ end
290
+
291
+ describe 'faceted MVA field' do
292
+ before :each do
293
+ @index = ThinkingSphinx::Index::Builder.generate(Person) do
294
+ indexes tags(:name), :as => :tags, :facet => true
295
+ end
296
+
297
+ @source = @index.sources.first
298
+ end
299
+
300
+ after :each do
301
+ Person.sphinx_facets.delete_at(-1)
302
+ end
303
+
304
+ it "should have one field" do
305
+ @source.fields.length.should == 1
306
+ end
307
+
308
+ it "should have one attribute alongside the four internal ones" do
309
+ @source.attributes.length.should == 5
310
+ end
311
+
312
+ it "should set the attribute name to have the _facet suffix" do
313
+ @source.attributes.last.unique_name.should == :tags_facet
314
+ end
315
+
316
+ it "should set the attribute type to multi" do
317
+ @source.attributes.last.type.should == :multi
318
+ end
319
+
320
+ it "should set the attribute column to be the same as the field" do
321
+ @source.attributes.last.columns.length.should == 1
322
+ @source.attributes.last.columns.first.__name.should == :name
323
+ end
324
+ end
325
+
226
326
  describe "no fields" do
227
327
  it "should raise an exception" do
228
328
  lambda {
@@ -158,10 +158,10 @@ describe ThinkingSphinx::Search do
158
158
  @alpha_a, @alpha_b = Alpha.new, Alpha.new
159
159
  @beta_a, @beta_b = Beta.new, Beta.new
160
160
 
161
- @alpha_a.stub! :id => 1, :attributes => {'id' => 1}
162
- @alpha_b.stub! :id => 2, :attributes => {'id' => 2}
163
- @beta_a.stub! :id => 1, :attributes => {'id' => 1}
164
- @beta_b.stub! :id => 2, :attributes => {'id' => 2}
161
+ @alpha_a.stub! :id => 1, :read_attribute => 1
162
+ @alpha_b.stub! :id => 2, :read_attribute => 2
163
+ @beta_a.stub! :id => 1, :read_attribute => 1
164
+ @beta_b.stub! :id => 2, :read_attribute => 2
165
165
 
166
166
  @client.stub! :query => {
167
167
  :matches => minimal_result_hashes(@alpha_a, @beta_b, @alpha_b, @beta_a)
@@ -805,7 +805,7 @@ describe ThinkingSphinx::Search do
805
805
  describe '.each_with_groupby_and_count' do
806
806
  before :each do
807
807
  @alpha = Alpha.new
808
- @alpha.stub!(:id => 1, :attributes => {'id' => 1})
808
+ @alpha.stub!(:id => 1, :read_attribute => 1)
809
809
 
810
810
  @client.stub! :query => {
811
811
  :matches => [{
@@ -833,7 +833,7 @@ describe ThinkingSphinx::Search do
833
833
  describe '.each_with_weighting' do
834
834
  before :each do
835
835
  @alpha = Alpha.new
836
- @alpha.stub!(:id => 1, :attributes => {'id' => 1})
836
+ @alpha.stub!(:id => 1, :read_attribute => 1)
837
837
 
838
838
  @client.stub! :query => {
839
839
  :matches => [{
@@ -858,7 +858,7 @@ describe ThinkingSphinx::Search do
858
858
  describe '.each_with_*' do
859
859
  before :each do
860
860
  @alpha = Alpha.new
861
- @alpha.stub!(:id => 1, :attributes => {'id' => 1})
861
+ @alpha.stub!(:id => 1, :read_attribute => 1)
862
862
 
863
863
  @client.stub! :query => {
864
864
  :matches => [{
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freelancing-god-thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-10 00:00:00 -07:00
12
+ date: 2009-08-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency