initforthe-thinking-sphinx 1.1.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/LICENCE +20 -0
  2. data/README.textile +141 -0
  3. data/lib/thinking_sphinx.rb +215 -0
  4. data/lib/thinking_sphinx/active_record.rb +278 -0
  5. data/lib/thinking_sphinx/active_record/attribute_updates.rb +48 -0
  6. data/lib/thinking_sphinx/active_record/delta.rb +87 -0
  7. data/lib/thinking_sphinx/active_record/has_many_association.rb +29 -0
  8. data/lib/thinking_sphinx/active_record/search.rb +57 -0
  9. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +42 -0
  10. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +54 -0
  11. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +135 -0
  12. data/lib/thinking_sphinx/association.rb +164 -0
  13. data/lib/thinking_sphinx/attribute.rb +268 -0
  14. data/lib/thinking_sphinx/class_facet.rb +15 -0
  15. data/lib/thinking_sphinx/collection.rb +148 -0
  16. data/lib/thinking_sphinx/configuration.rb +262 -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 +27 -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 +82 -0
  26. data/lib/thinking_sphinx/facet.rb +108 -0
  27. data/lib/thinking_sphinx/facet_collection.rb +59 -0
  28. data/lib/thinking_sphinx/field.rb +82 -0
  29. data/lib/thinking_sphinx/index.rb +99 -0
  30. data/lib/thinking_sphinx/index/builder.rb +287 -0
  31. data/lib/thinking_sphinx/index/faux_column.rb +110 -0
  32. data/lib/thinking_sphinx/property.rb +160 -0
  33. data/lib/thinking_sphinx/rails_additions.rb +136 -0
  34. data/lib/thinking_sphinx/search.rb +727 -0
  35. data/lib/thinking_sphinx/search/facets.rb +104 -0
  36. data/lib/thinking_sphinx/source.rb +150 -0
  37. data/lib/thinking_sphinx/source/internal_properties.rb +46 -0
  38. data/lib/thinking_sphinx/source/sql.rb +126 -0
  39. data/lib/thinking_sphinx/tasks.rb +162 -0
  40. data/rails/init.rb +14 -0
  41. data/spec/unit/thinking_sphinx/active_record/delta_spec.rb +136 -0
  42. data/spec/unit/thinking_sphinx/active_record/has_many_association_spec.rb +53 -0
  43. data/spec/unit/thinking_sphinx/active_record/search_spec.rb +107 -0
  44. data/spec/unit/thinking_sphinx/active_record_spec.rb +329 -0
  45. data/spec/unit/thinking_sphinx/association_spec.rb +246 -0
  46. data/spec/unit/thinking_sphinx/attribute_spec.rb +338 -0
  47. data/spec/unit/thinking_sphinx/collection_spec.rb +15 -0
  48. data/spec/unit/thinking_sphinx/configuration_spec.rb +222 -0
  49. data/spec/unit/thinking_sphinx/core/string_spec.rb +9 -0
  50. data/spec/unit/thinking_sphinx/facet_collection_spec.rb +64 -0
  51. data/spec/unit/thinking_sphinx/facet_spec.rb +302 -0
  52. data/spec/unit/thinking_sphinx/field_spec.rb +154 -0
  53. data/spec/unit/thinking_sphinx/index/builder_spec.rb +355 -0
  54. data/spec/unit/thinking_sphinx/index/faux_column_spec.rb +30 -0
  55. data/spec/unit/thinking_sphinx/index_spec.rb +45 -0
  56. data/spec/unit/thinking_sphinx/rails_additions_spec.rb +191 -0
  57. data/spec/unit/thinking_sphinx/search_spec.rb +228 -0
  58. data/spec/unit/thinking_sphinx/source_spec.rb +217 -0
  59. data/spec/unit/thinking_sphinx_spec.rb +151 -0
  60. data/tasks/distribution.rb +67 -0
  61. data/tasks/rails.rake +1 -0
  62. data/tasks/testing.rb +78 -0
  63. data/vendor/after_commit/LICENSE +20 -0
  64. data/vendor/after_commit/README +16 -0
  65. data/vendor/after_commit/Rakefile +22 -0
  66. data/vendor/after_commit/init.rb +8 -0
  67. data/vendor/after_commit/lib/after_commit.rb +45 -0
  68. data/vendor/after_commit/lib/after_commit/active_record.rb +114 -0
  69. data/vendor/after_commit/lib/after_commit/connection_adapters.rb +103 -0
  70. data/vendor/after_commit/test/after_commit_test.rb +53 -0
  71. data/vendor/delayed_job/lib/delayed/job.rb +251 -0
  72. data/vendor/delayed_job/lib/delayed/message_sending.rb +7 -0
  73. data/vendor/delayed_job/lib/delayed/performable_method.rb +55 -0
  74. data/vendor/delayed_job/lib/delayed/worker.rb +54 -0
  75. data/vendor/riddle/lib/riddle.rb +30 -0
  76. data/vendor/riddle/lib/riddle/client.rb +619 -0
  77. data/vendor/riddle/lib/riddle/client/filter.rb +53 -0
  78. data/vendor/riddle/lib/riddle/client/message.rb +65 -0
  79. data/vendor/riddle/lib/riddle/client/response.rb +84 -0
  80. data/vendor/riddle/lib/riddle/configuration.rb +33 -0
  81. data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +48 -0
  82. data/vendor/riddle/lib/riddle/configuration/index.rb +142 -0
  83. data/vendor/riddle/lib/riddle/configuration/indexer.rb +19 -0
  84. data/vendor/riddle/lib/riddle/configuration/remote_index.rb +17 -0
  85. data/vendor/riddle/lib/riddle/configuration/searchd.rb +25 -0
  86. data/vendor/riddle/lib/riddle/configuration/section.rb +43 -0
  87. data/vendor/riddle/lib/riddle/configuration/source.rb +23 -0
  88. data/vendor/riddle/lib/riddle/configuration/sql_source.rb +34 -0
  89. data/vendor/riddle/lib/riddle/configuration/xml_source.rb +28 -0
  90. data/vendor/riddle/lib/riddle/controller.rb +44 -0
  91. metadata +190 -0
@@ -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,25 @@
1
+ module Riddle
2
+ class Configuration
3
+ class Searchd < Riddle::Configuration::Section
4
+ self.settings = [:address, :port, :log, :query_log, :read_timeout,
5
+ :max_children, :pid_file, :max_matches, :seamless_rotate,
6
+ :preopen_indexes, :unlink_old]
7
+
8
+ attr_accessor *self.settings
9
+
10
+ def render
11
+ raise ConfigurationError unless valid?
12
+
13
+ (
14
+ ["searchd", "{"] +
15
+ settings_body +
16
+ ["}", ""]
17
+ ).join("\n")
18
+ end
19
+
20
+ def valid?
21
+ !( @port.nil? || @pid_file.nil? )
22
+ end
23
+ end
24
+ end
25
+ 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,34 @@
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_attr_uint, :sql_attr_bool,
7
+ :sql_attr_timestamp, :sql_attr_str2ordinal, :sql_attr_float,
8
+ :sql_attr_multi, :sql_query_post, :sql_query_post_index,
9
+ :sql_ranged_throttle, :sql_query_info]
10
+
11
+ attr_accessor *self.settings
12
+
13
+ def initialize(name, type)
14
+ @name = name
15
+ @type = type
16
+
17
+ @sql_query_pre = []
18
+ @sql_attr_uint = []
19
+ @sql_attr_bool = []
20
+ @sql_attr_timestamp = []
21
+ @sql_attr_str2ordinal = []
22
+ @sql_attr_float = []
23
+ @sql_attr_multi = []
24
+ @sql_query_post = []
25
+ @sql_query_post_index = []
26
+ end
27
+
28
+ def valid?
29
+ super && (!( @sql_host.nil? || @sql_user.nil? || @sql_db.nil? ||
30
+ @sql_query.nil? ) || !@parent.nil?)
31
+ end
32
+ end
33
+ end
34
+ 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,44 @@
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
+ `#{cmd}`
19
+
20
+ sleep(1)
21
+
22
+ unless running?
23
+ puts "Failed to start searchd daemon. Check #{@configuration.searchd.log}."
24
+ end
25
+ end
26
+
27
+ def stop
28
+ return unless running?
29
+ `kill #{pid}`
30
+ end
31
+
32
+ def pid
33
+ if File.exists?("#{@configuration.searchd.pid_file}")
34
+ `cat #{@configuration.searchd.pid_file}`[/\d+/]
35
+ else
36
+ nil
37
+ end
38
+ end
39
+
40
+ def running?
41
+ pid && `ps #{pid} | wc -l`.to_i > 1
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: initforthe-thinking-sphinx
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.21
5
+ platform: ruby
6
+ authors:
7
+ - Pat Allan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-11 00:00:00 -07:00
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.
17
+ email: pat@freelancing-gods.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - rails/init.rb
26
+ - lib/thinking_sphinx/active_record/attribute_updates.rb
27
+ - lib/thinking_sphinx/active_record/delta.rb
28
+ - lib/thinking_sphinx/active_record/has_many_association.rb
29
+ - lib/thinking_sphinx/active_record/search.rb
30
+ - lib/thinking_sphinx/active_record.rb
31
+ - lib/thinking_sphinx/adapters/abstract_adapter.rb
32
+ - lib/thinking_sphinx/adapters/mysql_adapter.rb
33
+ - lib/thinking_sphinx/adapters/postgresql_adapter.rb
34
+ - lib/thinking_sphinx/association.rb
35
+ - lib/thinking_sphinx/attribute.rb
36
+ - lib/thinking_sphinx/class_facet.rb
37
+ - lib/thinking_sphinx/collection.rb
38
+ - lib/thinking_sphinx/configuration.rb
39
+ - lib/thinking_sphinx/core/string.rb
40
+ - lib/thinking_sphinx/deltas/datetime_delta.rb
41
+ - lib/thinking_sphinx/deltas/default_delta.rb
42
+ - lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb
43
+ - lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb
44
+ - lib/thinking_sphinx/deltas/delayed_delta/job.rb
45
+ - lib/thinking_sphinx/deltas/delayed_delta.rb
46
+ - lib/thinking_sphinx/deltas.rb
47
+ - lib/thinking_sphinx/deploy/capistrano.rb
48
+ - lib/thinking_sphinx/facet.rb
49
+ - lib/thinking_sphinx/facet_collection.rb
50
+ - lib/thinking_sphinx/field.rb
51
+ - lib/thinking_sphinx/index/builder.rb
52
+ - lib/thinking_sphinx/index/faux_column.rb
53
+ - lib/thinking_sphinx/index.rb
54
+ - lib/thinking_sphinx/property.rb
55
+ - lib/thinking_sphinx/rails_additions.rb
56
+ - lib/thinking_sphinx/search/facets.rb
57
+ - lib/thinking_sphinx/search.rb
58
+ - lib/thinking_sphinx/source/internal_properties.rb
59
+ - lib/thinking_sphinx/source/sql.rb
60
+ - lib/thinking_sphinx/source.rb
61
+ - lib/thinking_sphinx/tasks.rb
62
+ - lib/thinking_sphinx.rb
63
+ - LICENCE
64
+ - README.textile
65
+ - tasks/distribution.rb
66
+ - tasks/testing.rb
67
+ - tasks/rails.rake
68
+ - vendor/after_commit
69
+ - vendor/after_commit/init.rb
70
+ - vendor/after_commit/lib
71
+ - vendor/after_commit/lib/after_commit
72
+ - vendor/after_commit/lib/after_commit/active_record.rb
73
+ - 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
+ - vendor/after_commit/test/after_commit_test.rb
80
+ - vendor/delayed_job
81
+ - vendor/delayed_job/lib
82
+ - vendor/delayed_job/lib/delayed
83
+ - vendor/delayed_job/lib/delayed/job.rb
84
+ - vendor/delayed_job/lib/delayed/message_sending.rb
85
+ - vendor/delayed_job/lib/delayed/performable_method.rb
86
+ - 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
91
+ - vendor/riddle/lib/riddle/client/filter.rb
92
+ - vendor/riddle/lib/riddle/client/message.rb
93
+ - vendor/riddle/lib/riddle/client/response.rb
94
+ - vendor/riddle/lib/riddle/client.rb
95
+ - vendor/riddle/lib/riddle/configuration
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/configuration.rb
106
+ - vendor/riddle/lib/riddle/controller.rb
107
+ - vendor/riddle/lib/riddle.rb
108
+ - spec/unit/thinking_sphinx/active_record/delta_spec.rb
109
+ - spec/unit/thinking_sphinx/active_record/has_many_association_spec.rb
110
+ - spec/unit/thinking_sphinx/active_record/search_spec.rb
111
+ - spec/unit/thinking_sphinx/active_record_spec.rb
112
+ - spec/unit/thinking_sphinx/association_spec.rb
113
+ - spec/unit/thinking_sphinx/attribute_spec.rb
114
+ - spec/unit/thinking_sphinx/collection_spec.rb
115
+ - spec/unit/thinking_sphinx/configuration_spec.rb
116
+ - spec/unit/thinking_sphinx/core/string_spec.rb
117
+ - spec/unit/thinking_sphinx/facet_collection_spec.rb
118
+ - spec/unit/thinking_sphinx/facet_spec.rb
119
+ - spec/unit/thinking_sphinx/field_spec.rb
120
+ - spec/unit/thinking_sphinx/index/builder_spec.rb
121
+ - spec/unit/thinking_sphinx/index/faux_column_spec.rb
122
+ - spec/unit/thinking_sphinx/index_spec.rb
123
+ - spec/unit/thinking_sphinx/rails_additions_spec.rb
124
+ - spec/unit/thinking_sphinx/search_spec.rb
125
+ - spec/unit/thinking_sphinx/source_spec.rb
126
+ - spec/unit/thinking_sphinx_spec.rb
127
+ has_rdoc: true
128
+ homepage: http://ts.freelancing-gods.com
129
+ post_install_message: |+
130
+ As of Thinking Sphinx 1.1.18, there is one important change to
131
+ note: previously, the default morphology for indexing was 'stem_en'. The new
132
+ default is nil, to avoid any unexpected behavior. If you wish to keep the old
133
+ value though, you will need to add the following settings to your
134
+ config/sphinx.yml file:
135
+
136
+ development:
137
+ morphology: stem_en
138
+ test:
139
+ morphology: stem_en
140
+ production:
141
+ morphology: stem_en
142
+
143
+ To understand morphologies/stemmers better, visit the following link:
144
+ http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
145
+
146
+ rdoc_options:
147
+ - --title
148
+ - Thinking Sphinx -- Rails/Merb Sphinx Plugin
149
+ - --line-numbers
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: "0"
157
+ version:
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: "0"
163
+ version:
164
+ requirements: []
165
+
166
+ rubyforge_project: thinking-sphinx
167
+ rubygems_version: 1.2.0
168
+ signing_key:
169
+ specification_version: 2
170
+ summary: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
171
+ test_files:
172
+ - spec/unit/thinking_sphinx/active_record/delta_spec.rb
173
+ - spec/unit/thinking_sphinx/active_record/has_many_association_spec.rb
174
+ - spec/unit/thinking_sphinx/active_record/search_spec.rb
175
+ - spec/unit/thinking_sphinx/active_record_spec.rb
176
+ - spec/unit/thinking_sphinx/association_spec.rb
177
+ - spec/unit/thinking_sphinx/attribute_spec.rb
178
+ - spec/unit/thinking_sphinx/collection_spec.rb
179
+ - spec/unit/thinking_sphinx/configuration_spec.rb
180
+ - spec/unit/thinking_sphinx/core/string_spec.rb
181
+ - spec/unit/thinking_sphinx/facet_collection_spec.rb
182
+ - spec/unit/thinking_sphinx/facet_spec.rb
183
+ - spec/unit/thinking_sphinx/field_spec.rb
184
+ - spec/unit/thinking_sphinx/index/builder_spec.rb
185
+ - spec/unit/thinking_sphinx/index/faux_column_spec.rb
186
+ - spec/unit/thinking_sphinx/index_spec.rb
187
+ - spec/unit/thinking_sphinx/rails_additions_spec.rb
188
+ - spec/unit/thinking_sphinx/search_spec.rb
189
+ - spec/unit/thinking_sphinx/source_spec.rb
190
+ - spec/unit/thinking_sphinx_spec.rb