warp-thinking-sphinx 1.2.12 → 1.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/README.textile +21 -4
  2. data/VERSION +1 -0
  3. data/features/abstract_inheritance.feature +10 -0
  4. data/features/alternate_primary_key.feature +1 -1
  5. data/features/attribute_updates.feature +22 -5
  6. data/features/deleting_instances.feature +3 -0
  7. data/features/facets.feature +6 -0
  8. data/features/facets_across_model.feature +2 -2
  9. data/features/searching_across_models.feature +1 -1
  10. data/features/searching_by_index.feature +40 -0
  11. data/features/sphinx_scopes.feature +7 -0
  12. data/features/step_definitions/alpha_steps.rb +14 -1
  13. data/features/step_definitions/beta_steps.rb +1 -1
  14. data/features/step_definitions/common_steps.rb +12 -2
  15. data/features/step_definitions/facet_steps.rb +5 -1
  16. data/features/step_definitions/scope_steps.rb +4 -0
  17. data/features/step_definitions/sphinx_steps.rb +8 -4
  18. data/features/sti_searching.feature +5 -0
  19. data/features/support/{db/database.example.yml → database.example.yml} +0 -0
  20. data/features/support/db/fixtures/foxes.rb +3 -0
  21. data/features/support/db/fixtures/music.rb +4 -0
  22. data/features/support/db/fixtures/robots.rb +1 -1
  23. data/features/support/db/fixtures/tags.rb +1 -1
  24. data/features/support/db/migrations/create_alphas.rb +1 -0
  25. data/features/support/db/migrations/create_genres.rb +3 -0
  26. data/features/support/db/migrations/create_music.rb +6 -0
  27. data/features/support/db/migrations/create_robots.rb +1 -2
  28. data/features/support/env.rb +16 -1
  29. data/features/support/models/alpha.rb +12 -0
  30. data/features/support/models/comment.rb +3 -3
  31. data/features/support/models/fox.rb +5 -0
  32. data/features/support/models/genre.rb +3 -0
  33. data/features/support/models/medium.rb +5 -0
  34. data/features/support/models/music.rb +8 -0
  35. data/features/support/models/post.rb +2 -1
  36. data/features/support/models/robot.rb +4 -0
  37. data/lib/cucumber/thinking_sphinx/external_world.rb +8 -0
  38. data/lib/cucumber/thinking_sphinx/internal_world.rb +126 -0
  39. data/lib/cucumber/thinking_sphinx/sql_logger.rb +20 -0
  40. data/lib/thinking_sphinx.rb +56 -37
  41. data/lib/thinking_sphinx/active_record.rb +257 -192
  42. data/lib/thinking_sphinx/active_record/attribute_updates.rb +10 -12
  43. data/lib/thinking_sphinx/active_record/delta.rb +0 -26
  44. data/lib/thinking_sphinx/active_record/scopes.rb +37 -1
  45. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +1 -1
  46. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +18 -11
  47. data/lib/thinking_sphinx/attribute.rb +19 -4
  48. data/lib/thinking_sphinx/auto_version.rb +22 -0
  49. data/lib/thinking_sphinx/configuration.rb +57 -59
  50. data/lib/thinking_sphinx/context.rb +74 -0
  51. data/lib/thinking_sphinx/deltas.rb +0 -2
  52. data/lib/thinking_sphinx/deltas/default_delta.rb +14 -20
  53. data/lib/thinking_sphinx/deploy/capistrano.rb +1 -1
  54. data/lib/thinking_sphinx/facet_search.rb +3 -1
  55. data/lib/thinking_sphinx/index.rb +77 -19
  56. data/lib/thinking_sphinx/index/builder.rb +2 -2
  57. data/lib/thinking_sphinx/search.rb +47 -9
  58. data/lib/thinking_sphinx/search_methods.rb +22 -4
  59. data/lib/thinking_sphinx/source.rb +9 -8
  60. data/lib/thinking_sphinx/source/sql.rb +5 -3
  61. data/lib/thinking_sphinx/tasks.rb +13 -57
  62. data/lib/thinking_sphinx/test.rb +52 -0
  63. data/rails/init.rb +4 -2
  64. data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/delta_spec.rb +4 -6
  65. data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/has_many_association_spec.rb +0 -0
  66. data/spec/thinking_sphinx/active_record/scopes_spec.rb +177 -0
  67. data/spec/thinking_sphinx/active_record_spec.rb +622 -0
  68. data/spec/{lib/thinking_sphinx → thinking_sphinx}/association_spec.rb +0 -0
  69. data/spec/{lib/thinking_sphinx → thinking_sphinx}/attribute_spec.rb +39 -0
  70. data/spec/thinking_sphinx/auto_version_spec.rb +39 -0
  71. data/spec/{lib/thinking_sphinx → thinking_sphinx}/configuration_spec.rb +27 -61
  72. data/spec/thinking_sphinx/context_spec.rb +119 -0
  73. data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/array_spec.rb +0 -0
  74. data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/string_spec.rb +0 -0
  75. data/spec/{lib/thinking_sphinx → thinking_sphinx}/excerpter_spec.rb +0 -0
  76. data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_search_spec.rb +0 -0
  77. data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_spec.rb +0 -0
  78. data/spec/{lib/thinking_sphinx → thinking_sphinx}/field_spec.rb +0 -0
  79. data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/builder_spec.rb +24 -0
  80. data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/faux_column_spec.rb +0 -0
  81. data/spec/thinking_sphinx/index_spec.rb +183 -0
  82. data/spec/{lib/thinking_sphinx → thinking_sphinx}/rails_additions_spec.rb +0 -0
  83. data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_methods_spec.rb +0 -0
  84. data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_spec.rb +41 -0
  85. data/spec/{lib/thinking_sphinx → thinking_sphinx}/source_spec.rb +1 -1
  86. data/spec/thinking_sphinx_spec.rb +204 -0
  87. data/tasks/distribution.rb +6 -20
  88. data/tasks/testing.rb +8 -19
  89. metadata +117 -142
  90. data/VERSION.yml +0 -4
  91. data/features/a.rb +0 -17
  92. data/features/datetime_deltas.feature +0 -66
  93. data/features/delayed_delta_indexing.feature +0 -37
  94. data/features/step_definitions/datetime_delta_steps.rb +0 -15
  95. data/features/step_definitions/delayed_delta_indexing_steps.rb +0 -7
  96. data/features/support/db/active_record.rb +0 -40
  97. data/features/support/db/fixtures/delayed_betas.rb +0 -10
  98. data/features/support/db/fixtures/thetas.rb +0 -10
  99. data/features/support/db/migrations/create_delayed_betas.rb +0 -17
  100. data/features/support/db/migrations/create_thetas.rb +0 -5
  101. data/features/support/db/mysql.rb +0 -3
  102. data/features/support/db/postgresql.rb +0 -3
  103. data/features/support/models/delayed_beta.rb +0 -7
  104. data/features/support/models/theta.rb +0 -7
  105. data/features/support/post_database.rb +0 -43
  106. data/features/support/z.rb +0 -19
  107. data/lib/thinking_sphinx/deltas/datetime_delta.rb +0 -50
  108. data/lib/thinking_sphinx/deltas/delayed_delta.rb +0 -30
  109. data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +0 -24
  110. data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +0 -27
  111. data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +0 -26
  112. data/spec/lib/thinking_sphinx/active_record/scopes_spec.rb +0 -96
  113. data/spec/lib/thinking_sphinx/active_record_spec.rb +0 -353
  114. data/spec/lib/thinking_sphinx/deltas/job_spec.rb +0 -32
  115. data/spec/lib/thinking_sphinx/index_spec.rb +0 -45
  116. data/spec/lib/thinking_sphinx_spec.rb +0 -162
  117. data/vendor/after_commit/LICENSE +0 -20
  118. data/vendor/after_commit/README +0 -16
  119. data/vendor/after_commit/Rakefile +0 -22
  120. data/vendor/after_commit/init.rb +0 -8
  121. data/vendor/after_commit/lib/after_commit.rb +0 -45
  122. data/vendor/after_commit/lib/after_commit/active_record.rb +0 -114
  123. data/vendor/after_commit/lib/after_commit/connection_adapters.rb +0 -103
  124. data/vendor/after_commit/test/after_commit_test.rb +0 -53
  125. data/vendor/delayed_job/lib/delayed/job.rb +0 -251
  126. data/vendor/delayed_job/lib/delayed/message_sending.rb +0 -7
  127. data/vendor/delayed_job/lib/delayed/performable_method.rb +0 -55
  128. data/vendor/delayed_job/lib/delayed/worker.rb +0 -54
  129. data/vendor/riddle/lib/riddle.rb +0 -30
  130. data/vendor/riddle/lib/riddle/client.rb +0 -635
  131. data/vendor/riddle/lib/riddle/client/filter.rb +0 -53
  132. data/vendor/riddle/lib/riddle/client/message.rb +0 -66
  133. data/vendor/riddle/lib/riddle/client/response.rb +0 -84
  134. data/vendor/riddle/lib/riddle/configuration.rb +0 -33
  135. data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +0 -48
  136. data/vendor/riddle/lib/riddle/configuration/index.rb +0 -142
  137. data/vendor/riddle/lib/riddle/configuration/indexer.rb +0 -19
  138. data/vendor/riddle/lib/riddle/configuration/remote_index.rb +0 -17
  139. data/vendor/riddle/lib/riddle/configuration/searchd.rb +0 -25
  140. data/vendor/riddle/lib/riddle/configuration/section.rb +0 -43
  141. data/vendor/riddle/lib/riddle/configuration/source.rb +0 -23
  142. data/vendor/riddle/lib/riddle/configuration/sql_source.rb +0 -34
  143. data/vendor/riddle/lib/riddle/configuration/xml_source.rb +0 -28
  144. data/vendor/riddle/lib/riddle/controller.rb +0 -53
@@ -1,17 +0,0 @@
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
@@ -1,25 +0,0 @@
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
@@ -1,43 +0,0 @@
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
@@ -1,23 +0,0 @@
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
@@ -1,34 +0,0 @@
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
@@ -1,28 +0,0 @@
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
@@ -1,53 +0,0 @@
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
- end
53
- end