ultrasphinx 1 → 1.5

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.
@@ -4,12 +4,12 @@ ENV['RAILS_ENV'] ||= "development"
4
4
  namespace :ultrasphinx do
5
5
 
6
6
  desc "Bootstrap a full Sphinx environment"
7
- task :bootstrap => [:environment, :configure, :index, :start] do
7
+ task :bootstrap => [:environment, :configure, :index, :"daemon:restart"] do
8
8
  end
9
9
 
10
10
  desc "Rebuild the configuration file for this particular environment."
11
11
  task :configure => :environment do
12
- Ultrasphinx::configure
12
+ Ultrasphinx::Configure.run
13
13
  end
14
14
 
15
15
  desc "Reindex the database and send an update signal to the search daemon."
@@ -22,12 +22,12 @@ namespace :ultrasphinx do
22
22
  system cmd
23
23
  end
24
24
 
25
+
25
26
  namespace :daemon do
26
27
  desc "Start the search daemon"
27
28
  task :start => :environment do
29
+ FileUtils.mkdir_p File.dirname(Ultrasphinx::DAEMON_SETTINGS["log"]) rescue nil
28
30
  raise Ultrasphinx::DaemonError, "Already running" if ultrasphinx_daemon_running?
29
- # remove lockfiles
30
- Dir[Ultrasphinx::PLUGIN_SETTINGS["path"] + "*spl"].each {|file| File.delete(file)}
31
31
  system "searchd --config #{Ultrasphinx::CONF_PATH}"
32
32
  sleep(2) # give daemon a chance to write the pid file
33
33
  if ultrasphinx_daemon_running?
@@ -45,23 +45,10 @@ namespace :ultrasphinx do
45
45
  end
46
46
 
47
47
  desc "Restart the search daemon"
48
- task :restart => [:environment, :stop, :start] do
49
- end
50
-
51
- desc "Tail queries in the log"
52
- task :tail => :environment do
53
- require 'file/tail'
54
- puts "Tailing #{filename = Ultrasphinx::DAEMON_SETTINGS['query_log']}"
55
- File.open(filename) do |log|
56
- log.extend(File::Tail)
57
- log.interval = 1
58
- log.backward(10)
59
- last = nil
60
- log.tail do |line|
61
- current = line[/\[\*\](.*)$/, 1]
62
- last = current and puts current unless current == last
63
- end
64
- end
48
+ task :restart => [:environment] do
49
+ Rake::Task["ultrasphinx:daemon:stop"].invoke if ultrasphinx_daemon_running?
50
+ sleep(3)
51
+ Rake::Task["ultrasphinx:daemon:start"].invoke
65
52
  end
66
53
 
67
54
  desc "Check if the search daemon is running"
@@ -73,11 +60,10 @@ namespace :ultrasphinx do
73
60
  end
74
61
  end
75
62
  end
76
-
77
-
63
+
78
64
 
79
65
  namespace :spelling do
80
- desc "Rebuild custom spelling dictionary"
66
+ desc "Rebuild the custom spelling dictionary. You may need to use 'sudo' if your Aspell folder is not writable by the app user."
81
67
  task :build => :environment do
82
68
  ENV['OPTS'] = "--buildstops #{Ultrasphinx::STOPWORDS_PATH} #{Ultrasphinx::MAX_WORDS} --buildfreqs"
83
69
  Rake::Task["ultrasphinx:index"].invoke
@@ -106,6 +92,7 @@ namespace :us do
106
92
  task :start => ["ultrasphinx:daemon:start"]
107
93
  task :restart => ["ultrasphinx:daemon:restart"]
108
94
  task :stop => ["ultrasphinx:daemon:stop"]
95
+ task :stat => ["ultrasphinx:daemon:status"]
109
96
  task :in => ["ultrasphinx:index"]
110
97
  task :spell => ["ultrasphinx:spelling:build"]
111
98
  task :conf => ["ultrasphinx:configure"]
@@ -121,5 +108,11 @@ def ultrasphinx_daemon_pid
121
108
  end
122
109
 
123
110
  def ultrasphinx_daemon_running?
124
- ultrasphinx_daemon_pid and `ps #{ultrasphinx_daemon_pid} | wc`.to_i > 1
111
+ if ultrasphinx_daemon_pid and `ps #{ultrasphinx_daemon_pid} | wc`.to_i > 1
112
+ true
113
+ else
114
+ # remove bogus lockfiles
115
+ Dir[Ultrasphinx::INDEX_SETTINGS["path"] + "*spl"].each {|file| File.delete(file)}
116
+ false
117
+ end
125
118
  end
@@ -0,0 +1,56 @@
1
+
2
+ #
3
+ # Sphinx/Ultrasphinx user-configurable options.
4
+ #
5
+ # Copy this file to RAILS_ROOT/config/ultrasphinx.
6
+ # You can use individual namespaces if you want (e.g. "development.base").
7
+ #
8
+
9
+ indexer
10
+ {
11
+ # Indexer running options
12
+ mem_limit = 256M
13
+ }
14
+
15
+ searchd
16
+ {
17
+ # Daemon options
18
+ # What interface the search daemon should listen on and where to store its logs
19
+ address = 0.0.0.0
20
+ port = 3312
21
+ log = /opt/local/var/db/sphinx/log/searchd.log
22
+ query_log = /opt/local/var/db/sphinx/log/query.log
23
+ read_timeout = 5
24
+ max_children = 300
25
+ pid_file = /opt/local/var/db/sphinx/log/searchd.pid
26
+ max_matches = 100000
27
+ }
28
+
29
+ client
30
+ {
31
+ # Client options
32
+ # How your application connects to the search daemon (not necessarily the same as above)
33
+ server_host = localhost
34
+ server_port = 3312
35
+ }
36
+
37
+ source
38
+ {
39
+ # Individual SQL source options
40
+ sql_range_step = 20000
41
+ strip_html = 0
42
+ index_html_attrs =
43
+ sql_query_post =
44
+ }
45
+
46
+ index
47
+ {
48
+ # Index building options
49
+ path = /opt/local/var/db/sphinx/
50
+ docinfo = extern # just leave this alone
51
+ morphology = stem_en
52
+ stopwords = # /path/to/stopwords.txt
53
+ min_word_len = 1
54
+ charset_type = utf-8 # or sbcs (Single Byte Character Set)
55
+ charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z,
56
+ }
@@ -0,0 +1,32 @@
1
+
2
+ def silently
3
+ old_stdout, $stdout = $stdout, StringIO.new
4
+ yield
5
+ $stdout = old_stdout
6
+ end
7
+
8
+ RAILS_ROOT = File.dirname(__FILE__)
9
+ $LOAD_PATH << "#{RAILS_ROOT}/../lib" << RAILS_ROOT
10
+
11
+ RAILS_ENV = "test"
12
+
13
+ require 'rubygems'
14
+ require 'initializer'
15
+ require 'active_support'
16
+ require 'sqlite3'
17
+ require 'active_record'
18
+ require 'test/spec'
19
+ require 'ruby-debug'
20
+
21
+ ActiveRecord::Base.establish_connection(
22
+ config = {
23
+ :adapter => 'sqlite3',
24
+ :database => ':memory:'
25
+ })
26
+ ActiveRecord::Base.connection.instance_variable_set('@config', config)
27
+
28
+ silently { require 'schema' }
29
+ require 'models'
30
+ require 'ultrasphinx'
31
+
32
+ Debugger.start
@@ -0,0 +1,93 @@
1
+
2
+ require "#{File.dirname(__FILE__)}/../test_helper.rb"
3
+
4
+ describe "parser" do
5
+
6
+ def setup
7
+ @s = Ultrasphinx::Search.new
8
+ end
9
+
10
+ [
11
+ 'artichokes',
12
+ 'artichokes',
13
+
14
+ ' artichokes ',
15
+ 'artichokes',
16
+
17
+ 'artichoke heart',
18
+ 'artichoke heart',
19
+
20
+ '"artichoke hearts"',
21
+ '"artichoke hearts"',
22
+
23
+ ' "artichoke hearts " ',
24
+ '"artichoke hearts"',
25
+
26
+ 'artichoke AND hearts',
27
+ 'artichoke hearts',
28
+
29
+ 'artichoke OR hearts',
30
+ 'artichoke | hearts',
31
+
32
+ 'artichoke NOT heart',
33
+ 'artichoke - heart',
34
+
35
+ 'artichoke and hearts',
36
+ 'artichoke hearts',
37
+
38
+ 'artichoke or hearts',
39
+ 'artichoke | hearts',
40
+
41
+ 'artichoke not heart',
42
+ 'artichoke - heart',
43
+
44
+ 'title:artichoke',
45
+ '@title artichoke',
46
+
47
+ 'user:"john mose"',
48
+ '@user "john mose"',
49
+
50
+ 'artichoke OR rhubarb NOT heart user:"john mose"',
51
+ 'artichoke | rhubarb - heart @user "john mose"',
52
+
53
+ 'title:artichoke hearts',
54
+ 'hearts @title artichoke',
55
+
56
+ 'title:artichoke AND hearts',
57
+ 'hearts @title artichoke',
58
+
59
+ 'title:artichoke NOT hearts',
60
+ 'hearts - @title artichoke',
61
+
62
+ 'title:artichoke OR hearts',
63
+ 'hearts | @title artichoke',
64
+
65
+ 'title:artichoke title:hearts',
66
+ '@title ( artichoke hearts )',
67
+
68
+ 'title:artichoke OR title:hearts',
69
+ '@title ( artichoke | hearts )',
70
+
71
+ 'title:artichoke NOT title:hearts "john mose" ',
72
+ '"john mose" @title ( artichoke - hearts )',
73
+
74
+ '"john mose" AND title:artichoke dogs OR title:hearts cats',
75
+ '"john mose" dogs cats @title ( artichoke | hearts )',
76
+
77
+ 'board:england OR board:tristate',
78
+ '@board ( england | tristate )',
79
+
80
+ '(800) 555-LOVE',
81
+ '(800) 555-LOVE',
82
+
83
+ 'Bend, OR',
84
+ 'Bend, OR'
85
+
86
+ ].in_groups_of(2).each do |query, result|
87
+ it "should parse" do
88
+ @s.send(:parse, query).should.equal(result)
89
+ end
90
+ end
91
+
92
+ end
93
+
@@ -0,0 +1,35 @@
1
+
2
+ # Gem::Specification for Ultrasphinx-1.5
3
+ # Originally generated by Echoe
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{ultrasphinx}
7
+ s.version = "1.5"
8
+ s.date = %q{2007-09-19}
9
+ s.summary = %q{Ruby on Rails configurator and client to the Sphinx fulltext search engine.}
10
+ s.email = %q{}
11
+ s.homepage = %q{http://blog.evanweaver.com/pages/code#ultrasphinx}
12
+ s.rubyforge_project = %q{fauna}
13
+ s.description = %q{Ruby on Rails configurator and client to the Sphinx fulltext search engine.}
14
+ s.has_rdoc = true
15
+ s.authors = [""]
16
+ s.files = ["vendor/will_paginate/LICENSE", "vendor/sphinx/README", "vendor/sphinx/Rakefile", "vendor/sphinx/LICENSE", "vendor/sphinx/lib/client.rb", "vendor/sphinx/init.rb", "TODO", "test/unit/parser_test.rb", "test/test_helper.rb", "test/config/ultrasphinx/test.base", "tasks/ultrasphinx.rake", "README", "Manifest", "LICENSE", "lib/ultrasphinx.rb", "lib/ultrasphinx/ultrasphinx.rb", "lib/ultrasphinx/spell.rb", "lib/ultrasphinx/search.rb", "lib/ultrasphinx/search/parser.rb", "lib/ultrasphinx/search/internals.rb", "lib/ultrasphinx/is_indexed.rb", "lib/ultrasphinx/fields.rb", "lib/ultrasphinx/core_extensions.rb", "lib/ultrasphinx/configure.rb", "lib/ultrasphinx/autoload.rb", "init.rb", "examples/default.base", "examples/app.multi", "CHANGELOG", "ultrasphinx.gemspec"]
17
+ s.test_files = ["test/test_helper.rb"]
18
+ s.add_dependency(%q<chronic>, ["> 0.0.0"])
19
+ end
20
+
21
+
22
+ # # Original Rakefile source (requires the Echoe gem):
23
+ #
24
+ #
25
+ # require 'rubygems'
26
+ # require 'echoe'
27
+ #
28
+ # Echoe.new("ultrasphinx") do |p|
29
+ # p.project = "fauna"
30
+ # p.summary = "Ruby on Rails configurator and client to the Sphinx fulltext search engine."
31
+ # p.url = "http://blog.evanweaver.com/pages/code#ultrasphinx"
32
+ # p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
33
+ # p.rdoc_pattern = /is_indexed.rb|search.rb|spell.rb|ultrasphinx.rb|^README|TODO|CHANGELOG|^LICENSE/
34
+ # p.dependencies = "chronic"
35
+ # end
@@ -0,0 +1,58 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the GPL
3
+ (see COPYING.txt file), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) rename any non-standard executables so the names do not conflict
21
+ with standard executables, which must also be provided.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or executable
26
+ form, provided that you do at least ONE of the following:
27
+
28
+ a) distribute the executables and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard executables non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under this terms.
43
+
44
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
45
+ files under the ./missing directory. See each file for the copying
46
+ condition.
47
+
48
+ 5. The scripts and library files supplied as input to or produced as
49
+ output from the software do not automatically fall under the
50
+ copyright of the software, but belong to whomever generated them,
51
+ and may be sold commercially, and may be aggregated with this
52
+ software.
53
+
54
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
55
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
56
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57
+ PURPOSE.
58
+
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2007 PJ Hyett and Mislav Marohnić
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ultrasphinx
5
5
  version: !ruby/object:Gem::Version
6
- version: "1"
7
- date: 2007-08-01 00:00:00 -04:00
6
+ version: "1.5"
7
+ date: 2007-09-19 00:00:00 -04:00
8
8
  summary: Ruby on Rails configurator and client to the Sphinx fulltext search engine.
9
9
  require_paths:
10
10
  - lib
@@ -25,33 +25,64 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ - |
29
+ -----BEGIN CERTIFICATE-----
30
+ MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARldmFu
31
+ MRgwFgYKCZImiZPyLGQBGRYIY2xvdWRidXIxEjAQBgoJkiaJk/IsZAEZFgJzdDAe
32
+ Fw0wNzA5MTYxMDMzMDBaFw0wODA5MTUxMDMzMDBaMD0xDTALBgNVBAMMBGV2YW4x
33
+ GDAWBgoJkiaJk/IsZAEZFghjbG91ZGJ1cjESMBAGCgmSJomT8ixkARkWAnN0MIIB
34
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C0Io89nyApnr+PvbNFge9Vs
35
+ yRWAlGBUEMahpXp28VrrfXZT0rAW7JBo4PlCE3jl4nE4dzE6gAdItSycjTosrw7A
36
+ Ir5+xoyl4Vb35adv56TIQQXvNz+BzlqnkAY5JN0CSBRTQb6mxS3hFyD/h4qgDosj
37
+ R2RFVzHqSxCS8xq4Ny8uzOwOi+Xyu4w67fI5JvnPvMxqrlR1eaIQHmxnf76RzC46
38
+ QO5QhufjAYGGXd960XzbQsQyTDUYJzrvT7AdOfiyZzKQykKt8dEpDn+QPjFTnGnT
39
+ QmgJBX5WJN0lHF2l1sbv3gh4Kn1tZu+kTUqeXY6ShAoDTyvZRiFqQdwh8w2lTQID
40
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU+WqJz3xQ
41
+ XSea1hRvvHWcIMgeeC4wDQYJKoZIhvcNAQEFBQADggEBAGLZ75jfOEW8Nsl26CTt
42
+ JFrWxQTcQT/UljeefVE3xYr7lc9oQjbqO3FOyued3qW7TaNEtZfSHoYeUSMYbpw1
43
+ XAwocIPuSRFDGM4B+hgQGVDx8PMGiJKom4qLXjO40UZsR7QyN/u869Vj45LURm6h
44
+ MBcPeqCASI+WNprj9+uZa2kmHiitrFqqfMBNlm5IFbn9XeYSta9AHVvs5QQqV2m5
45
+ hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr
46
+ x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+
47
+ yZ0=
48
+ -----END CERTIFICATE-----
49
+
28
50
  post_install_message:
29
51
  authors:
30
52
  - ""
31
53
  files:
32
- - ./CHANGELOG
33
- - ./LICENSE
34
- - ./Manifest
35
- - ./README
36
- - ./Rakefile
37
- - ./examples/app.multi
38
- - ./examples/default.base
39
- - ./init.rb
40
- - ./lib/ultrasphinx/autoload.rb
41
- - ./lib/ultrasphinx/core_extensions.rb
42
- - ./lib/ultrasphinx/fields.rb
43
- - ./lib/ultrasphinx/is_indexed.rb
44
- - ./lib/ultrasphinx/search.rb
45
- - ./lib/ultrasphinx/spell.rb
46
- - ./lib/ultrasphinx/ultrasphinx.rb
47
- - ./lib/ultrasphinx.rb
48
- - ./tasks/ultrasphinx.rake
49
- - ./vendor/sphinx/README
50
- - ./vendor/sphinx/Rakefile
51
- - ./vendor/sphinx/init.rb
52
- - ./vendor/sphinx/lib/client.rb
53
- test_files: []
54
-
54
+ - vendor/will_paginate/LICENSE
55
+ - vendor/sphinx/README
56
+ - vendor/sphinx/Rakefile
57
+ - vendor/sphinx/LICENSE
58
+ - vendor/sphinx/lib/client.rb
59
+ - vendor/sphinx/init.rb
60
+ - TODO
61
+ - test/unit/parser_test.rb
62
+ - test/test_helper.rb
63
+ - test/config/ultrasphinx/test.base
64
+ - tasks/ultrasphinx.rake
65
+ - README
66
+ - Manifest
67
+ - LICENSE
68
+ - lib/ultrasphinx.rb
69
+ - lib/ultrasphinx/ultrasphinx.rb
70
+ - lib/ultrasphinx/spell.rb
71
+ - lib/ultrasphinx/search.rb
72
+ - lib/ultrasphinx/search/parser.rb
73
+ - lib/ultrasphinx/search/internals.rb
74
+ - lib/ultrasphinx/is_indexed.rb
75
+ - lib/ultrasphinx/fields.rb
76
+ - lib/ultrasphinx/core_extensions.rb
77
+ - lib/ultrasphinx/configure.rb
78
+ - lib/ultrasphinx/autoload.rb
79
+ - init.rb
80
+ - examples/default.base
81
+ - examples/app.multi
82
+ - CHANGELOG
83
+ - ultrasphinx.gemspec
84
+ test_files:
85
+ - test/test_helper.rb
55
86
  rdoc_options: []
56
87
 
57
88
  extra_rdoc_files: []
@@ -62,5 +93,13 @@ extensions: []
62
93
 
63
94
  requirements: []
64
95
 
65
- dependencies: []
66
-
96
+ dependencies:
97
+ - !ruby/object:Gem::Dependency
98
+ name: chronic
99
+ version_requirement:
100
+ version_requirements: !ruby/object:Gem::Version::Requirement
101
+ requirements:
102
+ - - ">"
103
+ - !ruby/object:Gem::Version
104
+ version: 0.0.0
105
+ version: