DrMark-thinking-sphinx 1.2.5 → 1.2.6

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.
@@ -147,3 +147,4 @@ Since I first released this library, there's been quite a few people who have su
147
147
  * J.D. Hollis
148
148
  * Jeffrey Chupp
149
149
  * Rob Anderton
150
+ * Zach Inglis
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 2
4
- :patch: 5
4
+ :patch: 6
@@ -157,7 +157,9 @@ module ThinkingSphinx
157
157
  # messy dependencies issues).
158
158
  #
159
159
  def load_models
160
- return if defined?(Rails) && Rails.configuration.cache_classes
160
+ return if defined?(Rails) &&
161
+ Rails.configuration.cache_classes &&
162
+ Rails::VERSION::STRING.to_f > 2.1
161
163
 
162
164
  self.model_directories.each do |base|
163
165
  Dir["#{base}**/*.rb"].each do |file|
@@ -25,7 +25,7 @@ module ThinkingSphinx
25
25
  HashOptions = [:conditions, :with, :without, :with_all]
26
26
  ArrayOptions = [:classes, :without_ids]
27
27
 
28
- attr_reader :args, :options, :results
28
+ attr_reader :args, :options
29
29
 
30
30
  # Deprecated. Use ThinkingSphinx.search
31
31
  def self.search(*args)
@@ -68,6 +68,24 @@ module ThinkingSphinx
68
68
  @array
69
69
  end
70
70
 
71
+ # Indication of whether the request has been made to Sphinx for the search
72
+ # query.
73
+ #
74
+ # @return [Boolean] true if the results have been requested.
75
+ #
76
+ def populated?
77
+ !!@populated
78
+ end
79
+
80
+ # The query result hash from Riddle.
81
+ #
82
+ # @return [Hash] Raw Sphinx results
83
+ #
84
+ def results
85
+ populate
86
+ @results
87
+ end
88
+
71
89
  def method_missing(method, *args, &block)
72
90
  if is_scope?(method)
73
91
  add_scope(method, *args, &block)
@@ -43,11 +43,14 @@ namespace :thinking_sphinx do
43
43
 
44
44
  desc "Stop Sphinx using Thinking Sphinx's settings"
45
45
  task :stop => :app_env do
46
- raise RuntimeError, "searchd is not running." unless sphinx_running?
47
- config = ThinkingSphinx::Configuration.instance
48
- pid = sphinx_pid
49
- system! "#{config.bin_path}#{config.searchd_binary_name} --stop --config \"#{config.config_file}\""
50
- puts "Stopped search daemon (pid #{pid})."
46
+ unless sphinx_running?
47
+ puts "searchd is not running"
48
+ else
49
+ config = ThinkingSphinx::Configuration.instance
50
+ pid = sphinx_pid
51
+ system! "#{config.bin_path}#{config.searchd_binary_name} --stop --config \"#{config.config_file}\""
52
+ puts "Stopped search daemon (pid #{pid})."
53
+ end
51
54
  end
52
55
 
53
56
  desc "Restart Sphinx"
@@ -32,6 +32,31 @@ describe ThinkingSphinx::Search do
32
32
  end
33
33
  end
34
34
 
35
+ describe '#populated?' do
36
+ before :each do
37
+ @search = ThinkingSphinx::Search.new
38
+ end
39
+
40
+ it "should be false if the client request has not been made" do
41
+ @search.populated?.should be_false
42
+ end
43
+
44
+ it "should be true once the client request has been made" do
45
+ @search.first
46
+ @search.populated?.should be_true
47
+ end
48
+ end
49
+
50
+ describe '#results' do
51
+ it "should populate search results before returning" do
52
+ @search = ThinkingSphinx::Search.new
53
+ @search.populated?.should be_false
54
+
55
+ @search.results
56
+ @search.populated?.should be_true
57
+ end
58
+ end
59
+
35
60
  describe '#method_missing' do
36
61
  before :each do
37
62
  Alpha.sphinx_scope(:by_name) { |name|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: DrMark-thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
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-02 00:00:00 -07:00
12
+ date: 2009-08-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency