freelancing-god-thinking-sphinx 1.1.19 → 1.1.20

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -131,3 +131,4 @@ Since I first released this library, there's been quite a few people who have su
131
131
  * Jerome Riga
132
132
  * Tien Dung
133
133
  * Johannes Kaefer
134
+ * Paul Campbell
@@ -37,7 +37,7 @@ module ThinkingSphinx
37
37
  module Version #:nodoc:
38
38
  Major = 1
39
39
  Minor = 1
40
- Tiny = 19
40
+ Tiny = 20
41
41
 
42
42
  String = [Major, Minor, Tiny].join('.')
43
43
  end
@@ -225,7 +225,7 @@ module ThinkingSphinx
225
225
  conf = YAML::load(ERB.new(IO.read(path)).result)[environment]
226
226
 
227
227
  conf.each do |key,value|
228
- self.send("#{key}=", value) if self.methods.include?("#{key}=")
228
+ self.send("#{key}=", value) if self.respond_to?("#{key}=")
229
229
 
230
230
  set_sphinx_setting self.source_options, key, value, SourceOptions
231
231
  set_sphinx_setting self.index_options, key, value, IndexOptions
@@ -246,8 +246,8 @@ module ThinkingSphinx
246
246
  if object.is_a?(Hash)
247
247
  object[key.to_sym] = value if allowed.include?(key.to_s)
248
248
  else
249
- object.send("#{key}=", value) if object.methods.include?("#{key}")
250
- send("#{key}=", value) if self.methods.include?("#{key}")
249
+ object.send("#{key}=", value) if object.respond_to?("#{key}")
250
+ send("#{key}=", value) if self.respond_to?("#{key}")
251
251
  end
252
252
  end
253
253
  end
@@ -222,6 +222,10 @@ module ThinkingSphinx
222
222
  # * <tt>:group_by</tt> determines the field which is used for grouping
223
223
  # * <tt>:group_clause</tt> determines the sorting order
224
224
  #
225
+ # As a convenience, you can also use
226
+ # * <tt>:group</tt>
227
+ # which sets :group_by and defaults to :group_function of :attr
228
+ #
225
229
  # === group_function
226
230
  #
227
231
  # Valid values for :group_function are
@@ -508,6 +512,12 @@ module ThinkingSphinx
508
512
  end
509
513
  end
510
514
 
515
+ # Group by defaults using :group
516
+ if options[:group]
517
+ options[:group_by] = options[:group].to_s
518
+ options[:group_function] ||= :attr
519
+ end
520
+
511
521
  [
512
522
  :max_matches, :match_mode, :sort_mode, :sort_by, :id_range,
513
523
  :group_by, :group_function, :group_clause, :group_distinct, :cut_off,
@@ -2,7 +2,11 @@ require 'fileutils'
2
2
 
3
3
  namespace :thinking_sphinx do
4
4
  task :app_env do
5
- Rake::Task[:environment].invoke if defined?(RAILS_ROOT)
5
+ if defined?(RAILS_ROOT)
6
+ Rake::Task[:environment].invoke
7
+ Rails.configuration.cache_classes = false
8
+ end
9
+
6
10
  Rake::Task[:merb_env].invoke if defined?(Merb)
7
11
  end
8
12
 
@@ -86,6 +86,20 @@ describe ThinkingSphinx::Search do
86
86
  end
87
87
  end
88
88
 
89
+ describe "grouping" do
90
+ before :each do
91
+ @client = Riddle::Client.new
92
+ @client.stub_method(:query => {:matches => []})
93
+ Riddle::Client.stub_method(:new => @client)
94
+ end
95
+
96
+ it "should convert group into group_by and group_function" do
97
+ ThinkingSphinx::Search.search "foo", :group => :edition
98
+ @client.group_function.should == :attr
99
+ @client.group_by.should == "edition"
100
+ end
101
+ end
102
+
89
103
  describe ":comment option" do
90
104
  before :each do
91
105
  @client = Riddle::Client.new
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.1.19
4
+ version: 1.1.20
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-06-01 00:00:00 -07:00
12
+ date: 2009-06-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15