freelancing-god-thinking-sphinx 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -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
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 2
4
+ :patch: 6
@@ -5,6 +5,7 @@ end
5
5
  require 'active_record'
6
6
  require 'riddle'
7
7
  require 'after_commit'
8
+ require 'yaml'
8
9
 
9
10
  require 'thinking_sphinx/core/string'
10
11
  require 'thinking_sphinx/property'
@@ -35,14 +36,6 @@ Merb::Plugins.add_rakefiles(
35
36
  ) if defined?(Merb)
36
37
 
37
38
  module ThinkingSphinx
38
- module Version #:nodoc:
39
- Major = 1
40
- Minor = 2
41
- Tiny = 5
42
-
43
- String = [Major, Minor, Tiny].join('.')
44
- end
45
-
46
39
  # A ConnectionError will get thrown when a connection to Sphinx can't be
47
40
  # made.
48
41
  class ConnectionError < StandardError
@@ -56,7 +49,16 @@ module ThinkingSphinx
56
49
  self.ids = ids
57
50
  end
58
51
  end
59
-
52
+
53
+ # The current version of Thinking Sphinx.
54
+ #
55
+ # @return [String] The version number as a string
56
+ #
57
+ def self.version
58
+ hash = YAML.load_file File.join(File.dirname(__FILE__), '../VERSION.yml')
59
+ [hash[:major], hash[:minor], hash[:patch]].join('.')
60
+ end
61
+
60
62
  # The collection of indexed models. Keep in mind that Rails lazily loads
61
63
  # its classes, so this may not actually be populated with _all_ the models
62
64
  # that have Sphinx indexes.
@@ -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)
@@ -12,7 +12,7 @@ namespace :thinking_sphinx do
12
12
 
13
13
  desc "Output the current Thinking Sphinx version"
14
14
  task :version => :app_env do
15
- puts "Thinking Sphinx v" + ThinkingSphinx::Version::String
15
+ puts "Thinking Sphinx v" + ThinkingSphinx.version
16
16
  end
17
17
 
18
18
  desc "Stop if running, then start a Sphinx searchd daemon using Thinking Sphinx's settings"
@@ -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,7 +32,43 @@ 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
61
+ before :each do
62
+ Alpha.sphinx_scope(:by_name) { |name|
63
+ {:conditions => {:name => name}}
64
+ }
65
+ Alpha.sphinx_scope(:ids_only) { {:ids_only => true} }
66
+ end
67
+
68
+ after :each do
69
+ Alpha.remove_sphinx_scopes
70
+ end
71
+
36
72
  it "should handle Array methods" do
37
73
  ThinkingSphinx::Search.new.private_methods.should be_an(Array)
38
74
  end
@@ -67,6 +67,16 @@ describe ThinkingSphinx do
67
67
  ThinkingSphinx.sphinx_running?.should be_true
68
68
  end
69
69
 
70
+ describe '.version' do
71
+ it "should return the version from the stored YAML file" do
72
+ version = Jeweler::VersionHelper.new(
73
+ File.join(File.dirname(__FILE__), '../..')
74
+ ).to_s
75
+
76
+ ThinkingSphinx.version.should == version
77
+ end
78
+ end
79
+
70
80
  describe "use_group_by_shortcut? method" do
71
81
  before :each do
72
82
  adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
@@ -1,41 +1,34 @@
1
- require 'rake/rdoctask'
2
- require 'rake/gempackagetask'
3
-
4
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
5
- require 'thinking_sphinx'
1
+ require 'yard'
2
+ require 'jeweler'
6
3
 
7
4
  desc 'Generate documentation'
8
- Rake::RDocTask.new(:rdoc) do |rdoc|
9
- rdoc.rdoc_dir = 'rdoc'
10
- rdoc.title = 'Thinking Sphinx - ActiveRecord Sphinx Plugin'
11
- rdoc.options << '--line-numbers' << '--inline-source'
12
- rdoc.rdoc_files.include('README')
13
- rdoc.rdoc_files.include('lib/**/*.rb')
5
+ YARD::Rake::YardocTask.new do |t|
6
+ # t.title = 'Thinking Sphinx - ActiveRecord Sphinx Plugin'
14
7
  end
15
8
 
16
- spec = Gem::Specification.new do |s|
17
- s.name = "thinking-sphinx"
18
- s.version = ThinkingSphinx::Version::String
19
- s.summary = "A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching."
20
- s.description = "A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching."
21
- s.author = "Pat Allan"
22
- s.email = "pat@freelancing-gods.com"
23
- s.homepage = "http://ts.freelancing-gods.com"
24
- s.has_rdoc = true
25
- s.rdoc_options << "--title" << "Thinking Sphinx -- Rails/Merb Sphinx Plugin" <<
26
- "--line-numbers"
27
- s.rubyforge_project = "thinking-sphinx"
28
- s.test_files = FileList["spec/**/*_spec.rb"]
29
- s.files = FileList[
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "thinking-sphinx"
11
+ gem.summary = "A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching."
12
+ gem.author = "Pat Allan"
13
+ gem.email = "pat@freelancing-gods.com"
14
+ gem.homepage = "http://ts.freelancing-gods.com"
15
+
16
+ # s.rubyforge_project = "thinking-sphinx"
17
+ gem.files = FileList[
30
18
  "rails/*.rb",
31
19
  "lib/**/*.rb",
32
20
  "LICENCE",
33
21
  "README.textile",
34
22
  "tasks/**/*.rb",
35
23
  "tasks/**/*.rake",
36
- "vendor/**/*"
24
+ "vendor/**/*",
25
+ "VERSION.yml"
37
26
  ]
38
- s.post_install_message = <<-MESSAGE
27
+ gem.test_files = FileList["spec/**/*_spec.rb"]
28
+
29
+ gem.add_dependency 'activerecord', '>= 1.15.6'
30
+
31
+ gem.post_install_message = <<-MESSAGE
39
32
  With the release of Thinking Sphinx 1.1.18, there is one important change to
40
33
  note: previously, the default morphology for indexing was 'stem_en'. The new
41
34
  default is nil, to avoid any unexpected behavior. If you wish to keep the old
@@ -54,14 +47,3 @@ http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
54
47
 
55
48
  MESSAGE
56
49
  end
57
-
58
- Rake::GemPackageTask.new(spec) do |p|
59
- p.gem_spec = spec
60
- p.need_tar = true
61
- p.need_zip = true
62
- end
63
-
64
- desc "Build gemspec file"
65
- task :build do
66
- File.open('thinking-sphinx.gemspec', 'w') { |f| f.write spec.to_ruby }
67
- end
@@ -15,8 +15,12 @@ module Riddle
15
15
  return if running?
16
16
 
17
17
  cmd = "searchd --pidfile --config #{@path}"
18
- cmd = "start /B #{cmd}" if RUBY_PLATFORM =~ /mswin/
19
- `#{cmd}`
18
+
19
+ if RUBY_PLATFORM =~ /mswin/
20
+ system("start /B #{cmd} 1> NUL 2>&1")
21
+ else
22
+ `#{cmd}`
23
+ end
20
24
 
21
25
  sleep(1)
22
26
 
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.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,25 +9,37 @@ 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
- dependencies: []
15
-
16
- description: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activerecord
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.15.6
24
+ version:
25
+ description:
17
26
  email: pat@freelancing-gods.com
18
27
  executables: []
19
28
 
20
29
  extensions: []
21
30
 
22
- extra_rdoc_files: []
23
-
31
+ extra_rdoc_files:
32
+ - README.textile
24
33
  files:
25
- - rails/init.rb
34
+ - LICENCE
35
+ - README.textile
36
+ - VERSION.yml
37
+ - lib/thinking_sphinx.rb
38
+ - lib/thinking_sphinx/active_record.rb
26
39
  - lib/thinking_sphinx/active_record/attribute_updates.rb
27
40
  - lib/thinking_sphinx/active_record/delta.rb
28
41
  - lib/thinking_sphinx/active_record/has_many_association.rb
29
42
  - lib/thinking_sphinx/active_record/scopes.rb
30
- - lib/thinking_sphinx/active_record.rb
31
43
  - lib/thinking_sphinx/adapters/abstract_adapter.rb
32
44
  - lib/thinking_sphinx/adapters/mysql_adapter.rb
33
45
  - lib/thinking_sphinx/adapters/postgresql_adapter.rb
@@ -36,63 +48,51 @@ files:
36
48
  - lib/thinking_sphinx/class_facet.rb
37
49
  - lib/thinking_sphinx/configuration.rb
38
50
  - lib/thinking_sphinx/core/string.rb
51
+ - lib/thinking_sphinx/deltas.rb
39
52
  - lib/thinking_sphinx/deltas/datetime_delta.rb
40
53
  - lib/thinking_sphinx/deltas/default_delta.rb
54
+ - lib/thinking_sphinx/deltas/delayed_delta.rb
41
55
  - lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb
42
56
  - lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb
43
57
  - lib/thinking_sphinx/deltas/delayed_delta/job.rb
44
- - lib/thinking_sphinx/deltas/delayed_delta.rb
45
- - lib/thinking_sphinx/deltas.rb
46
58
  - lib/thinking_sphinx/deploy/capistrano.rb
47
59
  - lib/thinking_sphinx/excerpter.rb
48
60
  - lib/thinking_sphinx/facet.rb
49
61
  - lib/thinking_sphinx/facet_search.rb
50
62
  - lib/thinking_sphinx/field.rb
63
+ - lib/thinking_sphinx/index.rb
51
64
  - lib/thinking_sphinx/index/builder.rb
52
65
  - lib/thinking_sphinx/index/faux_column.rb
53
- - lib/thinking_sphinx/index.rb
54
66
  - lib/thinking_sphinx/property.rb
55
67
  - lib/thinking_sphinx/rails_additions.rb
56
68
  - lib/thinking_sphinx/search.rb
57
69
  - lib/thinking_sphinx/search_methods.rb
70
+ - lib/thinking_sphinx/source.rb
58
71
  - lib/thinking_sphinx/source/internal_properties.rb
59
72
  - lib/thinking_sphinx/source/sql.rb
60
- - lib/thinking_sphinx/source.rb
61
73
  - lib/thinking_sphinx/tasks.rb
62
- - lib/thinking_sphinx.rb
63
- - LICENCE
64
- - README.textile
74
+ - rails/init.rb
65
75
  - tasks/distribution.rb
66
- - tasks/testing.rb
67
76
  - tasks/rails.rake
68
- - vendor/after_commit
77
+ - tasks/testing.rb
78
+ - vendor/after_commit/LICENSE
79
+ - vendor/after_commit/README
80
+ - vendor/after_commit/Rakefile
69
81
  - vendor/after_commit/init.rb
70
- - vendor/after_commit/lib
71
- - vendor/after_commit/lib/after_commit
82
+ - vendor/after_commit/lib/after_commit.rb
72
83
  - vendor/after_commit/lib/after_commit/active_record.rb
73
84
  - vendor/after_commit/lib/after_commit/connection_adapters.rb
74
- - vendor/after_commit/lib/after_commit.rb
75
- - vendor/after_commit/LICENSE
76
- - vendor/after_commit/Rakefile
77
- - vendor/after_commit/README
78
- - vendor/after_commit/test
79
85
  - vendor/after_commit/test/after_commit_test.rb
80
- - vendor/delayed_job
81
- - vendor/delayed_job/lib
82
- - vendor/delayed_job/lib/delayed
83
86
  - vendor/delayed_job/lib/delayed/job.rb
84
87
  - vendor/delayed_job/lib/delayed/message_sending.rb
85
88
  - vendor/delayed_job/lib/delayed/performable_method.rb
86
89
  - vendor/delayed_job/lib/delayed/worker.rb
87
- - vendor/riddle
88
- - vendor/riddle/lib
89
- - vendor/riddle/lib/riddle
90
- - vendor/riddle/lib/riddle/client
90
+ - vendor/riddle/lib/riddle.rb
91
+ - vendor/riddle/lib/riddle/client.rb
91
92
  - vendor/riddle/lib/riddle/client/filter.rb
92
93
  - vendor/riddle/lib/riddle/client/message.rb
93
94
  - vendor/riddle/lib/riddle/client/response.rb
94
- - vendor/riddle/lib/riddle/client.rb
95
- - vendor/riddle/lib/riddle/configuration
95
+ - vendor/riddle/lib/riddle/configuration.rb
96
96
  - vendor/riddle/lib/riddle/configuration/distributed_index.rb
97
97
  - vendor/riddle/lib/riddle/configuration/index.rb
98
98
  - vendor/riddle/lib/riddle/configuration/indexer.rb
@@ -102,29 +102,7 @@ files:
102
102
  - vendor/riddle/lib/riddle/configuration/source.rb
103
103
  - vendor/riddle/lib/riddle/configuration/sql_source.rb
104
104
  - vendor/riddle/lib/riddle/configuration/xml_source.rb
105
- - vendor/riddle/lib/riddle/configuration.rb
106
105
  - vendor/riddle/lib/riddle/controller.rb
107
- - vendor/riddle/lib/riddle.rb
108
- - spec/lib/thinking_sphinx/active_record/delta_spec.rb
109
- - spec/lib/thinking_sphinx/active_record/has_many_association_spec.rb
110
- - spec/lib/thinking_sphinx/active_record/scopes_spec.rb
111
- - spec/lib/thinking_sphinx/active_record_spec.rb
112
- - spec/lib/thinking_sphinx/association_spec.rb
113
- - spec/lib/thinking_sphinx/attribute_spec.rb
114
- - spec/lib/thinking_sphinx/configuration_spec.rb
115
- - spec/lib/thinking_sphinx/core/string_spec.rb
116
- - spec/lib/thinking_sphinx/excerpter_spec.rb
117
- - spec/lib/thinking_sphinx/facet_search_spec.rb
118
- - spec/lib/thinking_sphinx/facet_spec.rb
119
- - spec/lib/thinking_sphinx/field_spec.rb
120
- - spec/lib/thinking_sphinx/index/builder_spec.rb
121
- - spec/lib/thinking_sphinx/index/faux_column_spec.rb
122
- - spec/lib/thinking_sphinx/index_spec.rb
123
- - spec/lib/thinking_sphinx/rails_additions_spec.rb
124
- - spec/lib/thinking_sphinx/search_methods_spec.rb
125
- - spec/lib/thinking_sphinx/search_spec.rb
126
- - spec/lib/thinking_sphinx/source_spec.rb
127
- - spec/lib/thinking_sphinx_spec.rb
128
106
  has_rdoc: true
129
107
  homepage: http://ts.freelancing-gods.com
130
108
  licenses:
@@ -146,9 +124,7 @@ post_install_message: |+
146
124
  http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
147
125
 
148
126
  rdoc_options:
149
- - --title
150
- - Thinking Sphinx -- Rails/Merb Sphinx Plugin
151
- - --line-numbers
127
+ - --charset=UTF-8
152
128
  require_paths:
153
129
  - lib
154
130
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -165,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
141
  version:
166
142
  requirements: []
167
143
 
168
- rubyforge_project: thinking-sphinx
144
+ rubyforge_project:
169
145
  rubygems_version: 1.3.5
170
146
  signing_key:
171
147
  specification_version: 2