hariton-thinking-sphinx 1.2.7.0

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.
Files changed (93) hide show
  1. data/LICENCE +20 -0
  2. data/README.textile +156 -0
  3. data/VERSION.yml +4 -0
  4. data/lib/thinking_sphinx.rb +210 -0
  5. data/lib/thinking_sphinx/active_record.rb +298 -0
  6. data/lib/thinking_sphinx/active_record/attribute_updates.rb +48 -0
  7. data/lib/thinking_sphinx/active_record/delta.rb +87 -0
  8. data/lib/thinking_sphinx/active_record/has_many_association.rb +29 -0
  9. data/lib/thinking_sphinx/active_record/scopes.rb +39 -0
  10. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +42 -0
  11. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +54 -0
  12. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +136 -0
  13. data/lib/thinking_sphinx/association.rb +164 -0
  14. data/lib/thinking_sphinx/attribute.rb +329 -0
  15. data/lib/thinking_sphinx/class_facet.rb +15 -0
  16. data/lib/thinking_sphinx/configuration.rb +282 -0
  17. data/lib/thinking_sphinx/core/string.rb +15 -0
  18. data/lib/thinking_sphinx/deltas.rb +30 -0
  19. data/lib/thinking_sphinx/deltas/datetime_delta.rb +50 -0
  20. data/lib/thinking_sphinx/deltas/default_delta.rb +68 -0
  21. data/lib/thinking_sphinx/deltas/delayed_delta.rb +30 -0
  22. data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +24 -0
  23. data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +27 -0
  24. data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +26 -0
  25. data/lib/thinking_sphinx/deploy/capistrano.rb +100 -0
  26. data/lib/thinking_sphinx/excerpter.rb +22 -0
  27. data/lib/thinking_sphinx/facet.rb +108 -0
  28. data/lib/thinking_sphinx/facet_search.rb +134 -0
  29. data/lib/thinking_sphinx/field.rb +82 -0
  30. data/lib/thinking_sphinx/index.rb +99 -0
  31. data/lib/thinking_sphinx/index/builder.rb +287 -0
  32. data/lib/thinking_sphinx/index/faux_column.rb +110 -0
  33. data/lib/thinking_sphinx/property.rb +160 -0
  34. data/lib/thinking_sphinx/rails_additions.rb +150 -0
  35. data/lib/thinking_sphinx/search.rb +671 -0
  36. data/lib/thinking_sphinx/search_methods.rb +421 -0
  37. data/lib/thinking_sphinx/source.rb +150 -0
  38. data/lib/thinking_sphinx/source/internal_properties.rb +46 -0
  39. data/lib/thinking_sphinx/source/sql.rb +128 -0
  40. data/lib/thinking_sphinx/tasks.rb +165 -0
  41. data/rails/init.rb +14 -0
  42. data/spec/lib/thinking_sphinx/active_record/delta_spec.rb +136 -0
  43. data/spec/lib/thinking_sphinx/active_record/has_many_association_spec.rb +53 -0
  44. data/spec/lib/thinking_sphinx/active_record/scopes_spec.rb +96 -0
  45. data/spec/lib/thinking_sphinx/active_record_spec.rb +354 -0
  46. data/spec/lib/thinking_sphinx/association_spec.rb +246 -0
  47. data/spec/lib/thinking_sphinx/attribute_spec.rb +465 -0
  48. data/spec/lib/thinking_sphinx/configuration_spec.rb +268 -0
  49. data/spec/lib/thinking_sphinx/core/string_spec.rb +9 -0
  50. data/spec/lib/thinking_sphinx/excerpter_spec.rb +49 -0
  51. data/spec/lib/thinking_sphinx/facet_search_spec.rb +176 -0
  52. data/spec/lib/thinking_sphinx/facet_spec.rb +302 -0
  53. data/spec/lib/thinking_sphinx/field_spec.rb +154 -0
  54. data/spec/lib/thinking_sphinx/index/builder_spec.rb +355 -0
  55. data/spec/lib/thinking_sphinx/index/faux_column_spec.rb +30 -0
  56. data/spec/lib/thinking_sphinx/index_spec.rb +45 -0
  57. data/spec/lib/thinking_sphinx/rails_additions_spec.rb +203 -0
  58. data/spec/lib/thinking_sphinx/search_methods_spec.rb +152 -0
  59. data/spec/lib/thinking_sphinx/search_spec.rb +993 -0
  60. data/spec/lib/thinking_sphinx/source_spec.rb +217 -0
  61. data/spec/lib/thinking_sphinx_spec.rb +161 -0
  62. data/tasks/distribution.rb +49 -0
  63. data/tasks/rails.rake +1 -0
  64. data/tasks/testing.rb +78 -0
  65. data/vendor/after_commit/LICENSE +20 -0
  66. data/vendor/after_commit/README +16 -0
  67. data/vendor/after_commit/Rakefile +22 -0
  68. data/vendor/after_commit/init.rb +8 -0
  69. data/vendor/after_commit/lib/after_commit.rb +45 -0
  70. data/vendor/after_commit/lib/after_commit/active_record.rb +114 -0
  71. data/vendor/after_commit/lib/after_commit/connection_adapters.rb +103 -0
  72. data/vendor/after_commit/test/after_commit_test.rb +53 -0
  73. data/vendor/delayed_job/lib/delayed/job.rb +251 -0
  74. data/vendor/delayed_job/lib/delayed/message_sending.rb +7 -0
  75. data/vendor/delayed_job/lib/delayed/performable_method.rb +55 -0
  76. data/vendor/delayed_job/lib/delayed/worker.rb +54 -0
  77. data/vendor/riddle/lib/riddle.rb +30 -0
  78. data/vendor/riddle/lib/riddle/client.rb +719 -0
  79. data/vendor/riddle/lib/riddle/client/filter.rb +53 -0
  80. data/vendor/riddle/lib/riddle/client/message.rb +70 -0
  81. data/vendor/riddle/lib/riddle/client/response.rb +94 -0
  82. data/vendor/riddle/lib/riddle/configuration.rb +33 -0
  83. data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +49 -0
  84. data/vendor/riddle/lib/riddle/configuration/index.rb +146 -0
  85. data/vendor/riddle/lib/riddle/configuration/indexer.rb +19 -0
  86. data/vendor/riddle/lib/riddle/configuration/remote_index.rb +17 -0
  87. data/vendor/riddle/lib/riddle/configuration/searchd.rb +46 -0
  88. data/vendor/riddle/lib/riddle/configuration/section.rb +43 -0
  89. data/vendor/riddle/lib/riddle/configuration/source.rb +23 -0
  90. data/vendor/riddle/lib/riddle/configuration/sql_source.rb +39 -0
  91. data/vendor/riddle/lib/riddle/configuration/xml_source.rb +28 -0
  92. data/vendor/riddle/lib/riddle/controller.rb +54 -0
  93. metadata +169 -0
@@ -0,0 +1,19 @@
1
+ module Riddle
2
+ class Configuration
3
+ class Indexer < Riddle::Configuration::Section
4
+ self.settings = [:mem_limit, :max_iops, :max_iosize]
5
+
6
+ attr_accessor *self.settings
7
+
8
+ def render
9
+ raise ConfigurationError unless valid?
10
+
11
+ (
12
+ ["indexer", "{"] +
13
+ settings_body +
14
+ ["}", ""]
15
+ ).join("\n")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Riddle
2
+ class Configuration
3
+ class RemoteIndex
4
+ attr_accessor :address, :port, :name
5
+
6
+ def initialize(address, port, name)
7
+ @address = address
8
+ @port = port
9
+ @name = name
10
+ end
11
+
12
+ def remote
13
+ "#{address}:#{port}"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,46 @@
1
+ module Riddle
2
+ class Configuration
3
+ class Searchd < Riddle::Configuration::Section
4
+ self.settings = [:listen, :address, :port, :log, :query_log,
5
+ :read_timeout, :client_timeout, :max_children, :pid_file, :max_matches,
6
+ :seamless_rotate, :preopen_indexes, :unlink_old, :attr_flush_period,
7
+ :ondisk_dict_default, :max_packet_size, :mva_updates_pool,
8
+ :crash_log_path, :max_filters, :max_filter_values]
9
+
10
+ attr_accessor *self.settings
11
+
12
+ def render
13
+ raise ConfigurationError unless valid?
14
+
15
+ (
16
+ ["searchd", "{"] +
17
+ settings_body +
18
+ ["}", ""]
19
+ ).join("\n")
20
+ end
21
+
22
+ def valid?
23
+ set_listen
24
+ clear_deprecated
25
+
26
+ !( @listen.nil? || @pid_file.nil? )
27
+ end
28
+
29
+ private
30
+
31
+ def set_listen
32
+ return unless @listen.nil?
33
+
34
+ @listen = @port.to_s if @port && @address.nil?
35
+ @listen = "#{@address}:#{@port}" if @address && @port
36
+ end
37
+
38
+ def clear_deprecated
39
+ return if @listen.nil?
40
+
41
+ @address = nil
42
+ @port = nil
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,43 @@
1
+ module Riddle
2
+ class Configuration
3
+ class Section
4
+ class << self
5
+ attr_accessor :settings
6
+ end
7
+
8
+ settings = []
9
+
10
+ def valid?
11
+ true
12
+ end
13
+
14
+ private
15
+
16
+ def settings_body
17
+ self.class.settings.select { |setting|
18
+ !send(setting).nil?
19
+ }.collect { |setting|
20
+ if send(setting) == ""
21
+ conf = " #{setting} = "
22
+ else
23
+ conf = setting_to_array(setting).collect { |set|
24
+ " #{setting} = #{set}"
25
+ }
26
+ end
27
+ conf.length == 0 ? nil : conf
28
+ }.flatten.compact
29
+ end
30
+
31
+ def setting_to_array(setting)
32
+ value = send(setting)
33
+ case value
34
+ when Array then value
35
+ when TrueClass then [1]
36
+ when FalseClass then [0]
37
+ else
38
+ [value]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,23 @@
1
+ module Riddle
2
+ class Configuration
3
+ class Source < Riddle::Configuration::Section
4
+ attr_accessor :name, :parent, :type
5
+
6
+ def render
7
+ raise ConfigurationError unless valid?
8
+
9
+ inherited_name = "#{name}"
10
+ inherited_name << " : #{parent}" if parent
11
+ (
12
+ ["source #{inherited_name}", "{"] +
13
+ settings_body +
14
+ ["}", ""]
15
+ ).join("\n")
16
+ end
17
+
18
+ def valid?
19
+ !( @name.nil? || @type.nil? )
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ module Riddle
2
+ class Configuration
3
+ class SQLSource < Riddle::Configuration::Source
4
+ self.settings = [:type, :sql_host, :sql_user, :sql_pass, :sql_db,
5
+ :sql_port, :sql_sock, :mysql_connect_flags, :sql_query_pre, :sql_query,
6
+ :sql_query_range, :sql_range_step, :sql_query_killlist, :sql_attr_uint,
7
+ :sql_attr_bool, :sql_attr_bigint, :sql_attr_timestamp,
8
+ :sql_attr_str2ordinal, :sql_attr_float, :sql_attr_multi,
9
+ :sql_query_post, :sql_query_post_index, :sql_ranged_throttle,
10
+ :sql_query_info, :mssql_winauth, :mssql_unicode, :unpack_zlib,
11
+ :unpack_mysqlcompress, :unpack_mysqlcompress_maxsize]
12
+
13
+ attr_accessor *self.settings
14
+
15
+ def initialize(name, type)
16
+ @name = name
17
+ @type = type
18
+
19
+ @sql_query_pre = []
20
+ @sql_attr_uint = []
21
+ @sql_attr_bool = []
22
+ @sql_attr_bigint = []
23
+ @sql_attr_timestamp = []
24
+ @sql_attr_str2ordinal = []
25
+ @sql_attr_float = []
26
+ @sql_attr_multi = []
27
+ @sql_query_post = []
28
+ @sql_query_post_index = []
29
+ @unpack_zlib = []
30
+ @unpack_mysqlcompress = []
31
+ end
32
+
33
+ def valid?
34
+ super && (!( @sql_host.nil? || @sql_user.nil? || @sql_db.nil? ||
35
+ @sql_query.nil? ) || !@parent.nil?)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ module Riddle
2
+ class Configuration
3
+ class XMLSource < Riddle::Configuration::Source
4
+ self.settings = [:type, :xmlpipe_command, :xmlpipe_field,
5
+ :xmlpipe_attr_uint, :xmlpipe_attr_bool, :xmlpipe_attr_timestamp,
6
+ :xmlpipe_attr_str2ordinal, :xmlpipe_attr_float, :xmlpipe_attr_multi]
7
+
8
+ attr_accessor *self.settings
9
+
10
+ def initialize(name, type)
11
+ @name = name
12
+ @type = type
13
+
14
+ @xmlpipe_field = []
15
+ @xmlpipe_attr_uint = []
16
+ @xmlpipe_attr_bool = []
17
+ @xmlpipe_attr_timestamp = []
18
+ @xmlpipe_attr_str2ordinal = []
19
+ @xmlpipe_attr_float = []
20
+ @xmlpipe_attr_multi = []
21
+ end
22
+
23
+ def valid?
24
+ super && ( !@xmlpipe_command.nil? || !parent.nil? )
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,54 @@
1
+ module Riddle
2
+ class Controller
3
+ def initialize(configuration, path)
4
+ @configuration = configuration
5
+ @path = path
6
+ end
7
+
8
+ def index
9
+ cmd = "indexer --config #{@path} --all"
10
+ cmd << " --rotate" if running?
11
+ `#{cmd}`
12
+ end
13
+
14
+ def start
15
+ return if running?
16
+
17
+ cmd = "searchd --pidfile --config #{@path}"
18
+
19
+ if RUBY_PLATFORM =~ /mswin/
20
+ system("start /B #{cmd} 1> NUL 2>&1")
21
+ else
22
+ `#{cmd}`
23
+ end
24
+
25
+ sleep(1)
26
+
27
+ unless running?
28
+ puts "Failed to start searchd daemon. Check #{@configuration.searchd.log}."
29
+ end
30
+ end
31
+
32
+ def stop
33
+ return unless running?
34
+ Process.kill('SIGTERM', pid.to_i)
35
+ rescue Errno::EINVAL
36
+ Process.kill('SIGKILL', pid.to_i)
37
+ end
38
+
39
+ def pid
40
+ if File.exists?(@configuration.searchd.pid_file)
41
+ File.read(@configuration.searchd.pid_file)[/\d+/]
42
+ else
43
+ nil
44
+ end
45
+ end
46
+
47
+ def running?
48
+ !!pid && !!Process.kill(0, pid.to_i)
49
+ rescue
50
+ false
51
+ end
52
+
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hariton-thinking-sphinx
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Pat Allan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-10 00:00:00 -07:00
13
+ default_executable:
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:
26
+ email: pat@freelancing-gods.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.textile
33
+ files:
34
+ - LICENCE
35
+ - README.textile
36
+ - VERSION.yml
37
+ - lib/thinking_sphinx.rb
38
+ - lib/thinking_sphinx/active_record.rb
39
+ - lib/thinking_sphinx/active_record/attribute_updates.rb
40
+ - lib/thinking_sphinx/active_record/delta.rb
41
+ - lib/thinking_sphinx/active_record/has_many_association.rb
42
+ - lib/thinking_sphinx/active_record/scopes.rb
43
+ - lib/thinking_sphinx/adapters/abstract_adapter.rb
44
+ - lib/thinking_sphinx/adapters/mysql_adapter.rb
45
+ - lib/thinking_sphinx/adapters/postgresql_adapter.rb
46
+ - lib/thinking_sphinx/association.rb
47
+ - lib/thinking_sphinx/attribute.rb
48
+ - lib/thinking_sphinx/class_facet.rb
49
+ - lib/thinking_sphinx/configuration.rb
50
+ - lib/thinking_sphinx/core/string.rb
51
+ - lib/thinking_sphinx/deltas.rb
52
+ - lib/thinking_sphinx/deltas/datetime_delta.rb
53
+ - lib/thinking_sphinx/deltas/default_delta.rb
54
+ - lib/thinking_sphinx/deltas/delayed_delta.rb
55
+ - lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb
56
+ - lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb
57
+ - lib/thinking_sphinx/deltas/delayed_delta/job.rb
58
+ - lib/thinking_sphinx/deploy/capistrano.rb
59
+ - lib/thinking_sphinx/excerpter.rb
60
+ - lib/thinking_sphinx/facet.rb
61
+ - lib/thinking_sphinx/facet_search.rb
62
+ - lib/thinking_sphinx/field.rb
63
+ - lib/thinking_sphinx/index.rb
64
+ - lib/thinking_sphinx/index/builder.rb
65
+ - lib/thinking_sphinx/index/faux_column.rb
66
+ - lib/thinking_sphinx/property.rb
67
+ - lib/thinking_sphinx/rails_additions.rb
68
+ - lib/thinking_sphinx/search.rb
69
+ - lib/thinking_sphinx/search_methods.rb
70
+ - lib/thinking_sphinx/source.rb
71
+ - lib/thinking_sphinx/source/internal_properties.rb
72
+ - lib/thinking_sphinx/source/sql.rb
73
+ - lib/thinking_sphinx/tasks.rb
74
+ - rails/init.rb
75
+ - tasks/distribution.rb
76
+ - tasks/rails.rake
77
+ - tasks/testing.rb
78
+ - vendor/after_commit/LICENSE
79
+ - vendor/after_commit/README
80
+ - vendor/after_commit/Rakefile
81
+ - vendor/after_commit/init.rb
82
+ - vendor/after_commit/lib/after_commit.rb
83
+ - vendor/after_commit/lib/after_commit/active_record.rb
84
+ - vendor/after_commit/lib/after_commit/connection_adapters.rb
85
+ - vendor/after_commit/test/after_commit_test.rb
86
+ - vendor/delayed_job/lib/delayed/job.rb
87
+ - vendor/delayed_job/lib/delayed/message_sending.rb
88
+ - vendor/delayed_job/lib/delayed/performable_method.rb
89
+ - vendor/delayed_job/lib/delayed/worker.rb
90
+ - vendor/riddle/lib/riddle.rb
91
+ - vendor/riddle/lib/riddle/client.rb
92
+ - vendor/riddle/lib/riddle/client/filter.rb
93
+ - vendor/riddle/lib/riddle/client/message.rb
94
+ - vendor/riddle/lib/riddle/client/response.rb
95
+ - vendor/riddle/lib/riddle/configuration.rb
96
+ - vendor/riddle/lib/riddle/configuration/distributed_index.rb
97
+ - vendor/riddle/lib/riddle/configuration/index.rb
98
+ - vendor/riddle/lib/riddle/configuration/indexer.rb
99
+ - vendor/riddle/lib/riddle/configuration/remote_index.rb
100
+ - vendor/riddle/lib/riddle/configuration/searchd.rb
101
+ - vendor/riddle/lib/riddle/configuration/section.rb
102
+ - vendor/riddle/lib/riddle/configuration/source.rb
103
+ - vendor/riddle/lib/riddle/configuration/sql_source.rb
104
+ - vendor/riddle/lib/riddle/configuration/xml_source.rb
105
+ - vendor/riddle/lib/riddle/controller.rb
106
+ has_rdoc: true
107
+ homepage: http://ts.freelancing-gods.com
108
+ licenses:
109
+ post_install_message: |+
110
+ With the release of Thinking Sphinx 1.1.18, there is one important change to
111
+ note: previously, the default morphology for indexing was 'stem_en'. The new
112
+ default is nil, to avoid any unexpected behavior. If you wish to keep the old
113
+ value though, you will need to add the following settings to your
114
+ config/sphinx.yml file:
115
+
116
+ development:
117
+ morphology: stem_en
118
+ test:
119
+ morphology: stem_en
120
+ production:
121
+ morphology: stem_en
122
+
123
+ To understand morphologies/stemmers better, visit the following link:
124
+ http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
125
+
126
+ rdoc_options:
127
+ - --charset=UTF-8
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: "0"
135
+ version:
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: "0"
141
+ version:
142
+ requirements: []
143
+
144
+ rubyforge_project:
145
+ rubygems_version: 1.3.5
146
+ signing_key:
147
+ specification_version: 2
148
+ summary: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
149
+ test_files:
150
+ - spec/lib/thinking_sphinx/active_record/delta_spec.rb
151
+ - spec/lib/thinking_sphinx/active_record/has_many_association_spec.rb
152
+ - spec/lib/thinking_sphinx/active_record/scopes_spec.rb
153
+ - spec/lib/thinking_sphinx/active_record_spec.rb
154
+ - spec/lib/thinking_sphinx/association_spec.rb
155
+ - spec/lib/thinking_sphinx/attribute_spec.rb
156
+ - spec/lib/thinking_sphinx/configuration_spec.rb
157
+ - spec/lib/thinking_sphinx/core/string_spec.rb
158
+ - spec/lib/thinking_sphinx/excerpter_spec.rb
159
+ - spec/lib/thinking_sphinx/facet_search_spec.rb
160
+ - spec/lib/thinking_sphinx/facet_spec.rb
161
+ - spec/lib/thinking_sphinx/field_spec.rb
162
+ - spec/lib/thinking_sphinx/index/builder_spec.rb
163
+ - spec/lib/thinking_sphinx/index/faux_column_spec.rb
164
+ - spec/lib/thinking_sphinx/index_spec.rb
165
+ - spec/lib/thinking_sphinx/rails_additions_spec.rb
166
+ - spec/lib/thinking_sphinx/search_methods_spec.rb
167
+ - spec/lib/thinking_sphinx/search_spec.rb
168
+ - spec/lib/thinking_sphinx/source_spec.rb
169
+ - spec/lib/thinking_sphinx_spec.rb