thinking-sphinx 1.2.13 → 1.4.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.
- data/README.textile +37 -4
- data/VERSION +1 -0
- data/features/abstract_inheritance.feature +10 -0
- data/features/alternate_primary_key.feature +1 -1
- data/features/attribute_updates.feature +49 -5
- data/features/deleting_instances.feature +3 -0
- data/features/excerpts.feature +8 -0
- data/features/facets.feature +15 -1
- data/features/facets_across_model.feature +2 -2
- data/features/field_sorting.feature +18 -0
- data/features/handling_edits.feature +1 -1
- data/features/searching_across_models.feature +2 -2
- data/features/searching_by_index.feature +40 -0
- data/features/searching_by_model.feature +1 -8
- data/features/sphinx_scopes.feature +33 -0
- data/features/step_definitions/alpha_steps.rb +14 -1
- data/features/step_definitions/beta_steps.rb +1 -1
- data/features/step_definitions/common_steps.rb +21 -2
- data/features/step_definitions/facet_steps.rb +4 -0
- data/features/step_definitions/scope_steps.rb +8 -0
- data/features/step_definitions/search_steps.rb +5 -0
- data/features/step_definitions/sphinx_steps.rb +8 -4
- data/features/sti_searching.feature +5 -0
- data/features/support/env.rb +7 -6
- data/features/{support → thinking_sphinx}/db/fixtures/betas.rb +1 -0
- data/features/{support → thinking_sphinx}/db/fixtures/comments.rb +1 -1
- data/features/{support → thinking_sphinx}/db/fixtures/developers.rb +2 -0
- data/features/thinking_sphinx/db/fixtures/foxes.rb +3 -0
- data/features/thinking_sphinx/db/fixtures/music.rb +4 -0
- data/features/{support → thinking_sphinx}/db/fixtures/people.rb +1 -1
- data/features/{support → thinking_sphinx}/db/fixtures/tags.rb +1 -1
- data/features/{support → thinking_sphinx}/db/migrations/create_alphas.rb +1 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_developers.rb +0 -2
- data/features/thinking_sphinx/db/migrations/create_genres.rb +3 -0
- data/features/thinking_sphinx/db/migrations/create_music.rb +6 -0
- data/features/thinking_sphinx/models/alpha.rb +23 -0
- data/features/thinking_sphinx/models/andrew.rb +17 -0
- data/features/{support → thinking_sphinx}/models/beta.rb +1 -1
- data/features/{support → thinking_sphinx}/models/developer.rb +2 -2
- data/features/{support → thinking_sphinx}/models/extensible_beta.rb +1 -1
- data/features/thinking_sphinx/models/fox.rb +5 -0
- data/features/thinking_sphinx/models/genre.rb +3 -0
- data/features/thinking_sphinx/models/medium.rb +5 -0
- data/features/thinking_sphinx/models/music.rb +8 -0
- data/features/{support → thinking_sphinx}/models/person.rb +2 -1
- data/features/{support → thinking_sphinx}/models/post.rb +2 -1
- data/lib/cucumber/thinking_sphinx/external_world.rb +12 -0
- data/lib/cucumber/thinking_sphinx/internal_world.rb +13 -11
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +17 -15
- data/lib/thinking_sphinx/active_record/delta.rb +0 -26
- data/lib/thinking_sphinx/active_record/has_many_association.rb +34 -11
- data/lib/thinking_sphinx/active_record/scopes.rb +46 -3
- data/lib/thinking_sphinx/active_record.rb +271 -193
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +45 -9
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +5 -1
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +9 -1
- data/lib/thinking_sphinx/attribute.rb +67 -23
- data/lib/thinking_sphinx/auto_version.rb +24 -0
- data/lib/thinking_sphinx/bundled_search.rb +44 -0
- data/lib/thinking_sphinx/class_facet.rb +3 -2
- data/lib/thinking_sphinx/configuration.rb +78 -64
- data/lib/thinking_sphinx/context.rb +76 -0
- data/lib/thinking_sphinx/deltas/default_delta.rb +14 -20
- data/lib/thinking_sphinx/deltas.rb +0 -2
- data/lib/thinking_sphinx/deploy/capistrano.rb +1 -1
- data/lib/thinking_sphinx/excerpter.rb +1 -1
- data/lib/thinking_sphinx/facet.rb +6 -5
- data/lib/thinking_sphinx/facet_search.rb +54 -24
- data/lib/thinking_sphinx/field.rb +2 -4
- data/lib/thinking_sphinx/index/builder.rb +36 -20
- data/lib/thinking_sphinx/index/faux_column.rb +8 -0
- data/lib/thinking_sphinx/index.rb +77 -19
- data/lib/thinking_sphinx/join.rb +37 -0
- data/lib/thinking_sphinx/property.rb +9 -2
- data/lib/thinking_sphinx/rails_additions.rb +4 -4
- data/lib/thinking_sphinx/search.rb +212 -66
- data/lib/thinking_sphinx/search_methods.rb +22 -4
- data/lib/thinking_sphinx/source/internal_properties.rb +2 -2
- data/lib/thinking_sphinx/source/sql.rb +5 -3
- data/lib/thinking_sphinx/source.rb +21 -12
- data/lib/thinking_sphinx/tasks.rb +26 -58
- data/lib/thinking_sphinx/test.rb +55 -0
- data/lib/thinking_sphinx.rb +70 -38
- data/rails/init.rb +4 -2
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/delta_spec.rb +6 -8
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/has_many_association_spec.rb +26 -3
- data/spec/thinking_sphinx/active_record/scopes_spec.rb +176 -0
- data/spec/thinking_sphinx/active_record_spec.rb +618 -0
- data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +134 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/association_spec.rb +1 -1
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/attribute_spec.rb +87 -46
- data/spec/thinking_sphinx/auto_version_spec.rb +47 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/configuration_spec.rb +73 -63
- data/spec/thinking_sphinx/context_spec.rb +127 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/array_spec.rb +1 -1
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/string_spec.rb +1 -1
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/excerpter_spec.rb +1 -9
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_search_spec.rb +76 -82
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_spec.rb +5 -5
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/field_spec.rb +1 -42
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/builder_spec.rb +71 -31
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/faux_column_spec.rb +8 -2
- data/spec/thinking_sphinx/index_spec.rb +183 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/rails_additions_spec.rb +5 -5
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_methods_spec.rb +5 -1
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_spec.rb +183 -31
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/source_spec.rb +18 -2
- data/spec/thinking_sphinx/test_spec.rb +20 -0
- data/spec/thinking_sphinx_spec.rb +204 -0
- data/tasks/distribution.rb +7 -26
- data/tasks/testing.rb +32 -20
- metadata +488 -147
- data/VERSION.yml +0 -5
- data/features/datetime_deltas.feature +0 -66
- data/features/delayed_delta_indexing.feature +0 -37
- data/features/step_definitions/datetime_delta_steps.rb +0 -15
- data/features/step_definitions/delayed_delta_indexing_steps.rb +0 -7
- data/features/support/database.yml +0 -5
- data/features/support/db/active_record.rb +0 -40
- data/features/support/db/database.yml +0 -5
- data/features/support/db/fixtures/delayed_betas.rb +0 -10
- data/features/support/db/fixtures/thetas.rb +0 -10
- data/features/support/db/migrations/create_delayed_betas.rb +0 -17
- data/features/support/db/migrations/create_thetas.rb +0 -5
- data/features/support/db/mysql.rb +0 -3
- data/features/support/db/postgresql.rb +0 -3
- data/features/support/models/alpha.rb +0 -10
- data/features/support/models/delayed_beta.rb +0 -7
- data/features/support/models/theta.rb +0 -7
- data/features/support/post_database.rb +0 -43
- data/lib/thinking_sphinx/deltas/datetime_delta.rb +0 -50
- data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +0 -24
- data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +0 -27
- data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +0 -26
- data/lib/thinking_sphinx/deltas/delayed_delta.rb +0 -30
- data/spec/lib/thinking_sphinx/active_record/scopes_spec.rb +0 -96
- data/spec/lib/thinking_sphinx/active_record_spec.rb +0 -353
- data/spec/lib/thinking_sphinx/deltas/job_spec.rb +0 -32
- data/spec/lib/thinking_sphinx/index_spec.rb +0 -45
- data/spec/lib/thinking_sphinx_spec.rb +0 -162
- data/vendor/after_commit/LICENSE +0 -20
- data/vendor/after_commit/README +0 -16
- data/vendor/after_commit/Rakefile +0 -22
- data/vendor/after_commit/init.rb +0 -8
- data/vendor/after_commit/lib/after_commit/active_record.rb +0 -114
- data/vendor/after_commit/lib/after_commit/connection_adapters.rb +0 -103
- data/vendor/after_commit/lib/after_commit.rb +0 -45
- data/vendor/after_commit/test/after_commit_test.rb +0 -53
- data/vendor/delayed_job/lib/delayed/job.rb +0 -251
- data/vendor/delayed_job/lib/delayed/message_sending.rb +0 -7
- data/vendor/delayed_job/lib/delayed/performable_method.rb +0 -55
- data/vendor/delayed_job/lib/delayed/worker.rb +0 -54
- data/vendor/riddle/lib/riddle/client/filter.rb +0 -53
- data/vendor/riddle/lib/riddle/client/message.rb +0 -66
- data/vendor/riddle/lib/riddle/client/response.rb +0 -84
- data/vendor/riddle/lib/riddle/client.rb +0 -635
- data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +0 -48
- data/vendor/riddle/lib/riddle/configuration/index.rb +0 -142
- data/vendor/riddle/lib/riddle/configuration/indexer.rb +0 -19
- data/vendor/riddle/lib/riddle/configuration/remote_index.rb +0 -17
- data/vendor/riddle/lib/riddle/configuration/searchd.rb +0 -25
- data/vendor/riddle/lib/riddle/configuration/section.rb +0 -43
- data/vendor/riddle/lib/riddle/configuration/source.rb +0 -23
- data/vendor/riddle/lib/riddle/configuration/sql_source.rb +0 -34
- data/vendor/riddle/lib/riddle/configuration/xml_source.rb +0 -28
- data/vendor/riddle/lib/riddle/configuration.rb +0 -33
- data/vendor/riddle/lib/riddle/controller.rb +0 -53
- data/vendor/riddle/lib/riddle.rb +0 -30
- data/features/{support → thinking_sphinx}/database.example.yml +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/alphas.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/authors.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/boxes.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/categories.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/cats.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/dogs.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/extensible_betas.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/gammas.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/posts.rb +0 -0
- data/features/{support → thinking_sphinx}/db/fixtures/robots.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_animals.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_authors.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_authors_posts.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_betas.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_boxes.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_categories.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_comments.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_extensible_betas.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_gammas.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_people.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_posts.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_robots.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_taggings.rb +0 -0
- data/features/{support → thinking_sphinx}/db/migrations/create_tags.rb +0 -0
- data/features/{support → thinking_sphinx}/models/animal.rb +0 -0
- data/features/{support → thinking_sphinx}/models/author.rb +0 -0
- data/features/{support → thinking_sphinx}/models/box.rb +0 -0
- data/features/{support → thinking_sphinx}/models/cat.rb +0 -0
- data/features/{support → thinking_sphinx}/models/category.rb +0 -0
- data/features/{support → thinking_sphinx}/models/comment.rb +3 -3
- /data/features/{support → thinking_sphinx}/models/dog.rb +0 -0
- /data/features/{support → thinking_sphinx}/models/gamma.rb +0 -0
- /data/features/{support → thinking_sphinx}/models/robot.rb +0 -0
- /data/features/{support → thinking_sphinx}/models/tag.rb +0 -0
- /data/features/{support → thinking_sphinx}/models/tagging.rb +0 -0
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
module Riddle
|
|
2
|
-
class Configuration
|
|
3
|
-
class Index < Riddle::Configuration::Section
|
|
4
|
-
self.settings = [:source, :path, :docinfo, :mlock, :morphology,
|
|
5
|
-
:stopwords, :wordforms, :exceptions, :min_word_len, :charset_type,
|
|
6
|
-
:charset_table, :ignore_chars, :min_prefix_len, :min_infix_len,
|
|
7
|
-
:prefix_fields, :infix_fields, :enable_star, :ngram_len, :ngram_chars,
|
|
8
|
-
:phrase_boundary, :phrase_boundary_step, :html_strip,
|
|
9
|
-
:html_index_attrs, :html_remove_elements, :preopen]
|
|
10
|
-
|
|
11
|
-
attr_accessor :name, :parent, :sources, :path, :docinfo, :mlock,
|
|
12
|
-
:morphologies, :stopword_files, :wordform_files, :exception_files,
|
|
13
|
-
:min_word_len, :charset_type, :charset_table, :ignore_characters,
|
|
14
|
-
:min_prefix_len, :min_infix_len, :prefix_field_names,
|
|
15
|
-
:infix_field_names, :enable_star, :ngram_len, :ngram_characters,
|
|
16
|
-
:phrase_boundaries, :phrase_boundary_step, :html_strip,
|
|
17
|
-
:html_index_attrs, :html_remove_element_tags, :preopen
|
|
18
|
-
|
|
19
|
-
def initialize(name, *sources)
|
|
20
|
-
@name = name
|
|
21
|
-
@sources = sources
|
|
22
|
-
@morphologies = []
|
|
23
|
-
@stopword_files = []
|
|
24
|
-
@wordform_files = []
|
|
25
|
-
@exception_files = []
|
|
26
|
-
@ignore_characters = []
|
|
27
|
-
@prefix_field_names = []
|
|
28
|
-
@infix_field_names = []
|
|
29
|
-
@ngram_characters = []
|
|
30
|
-
@phrase_boundaries = []
|
|
31
|
-
@html_remove_element_tags = []
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def source
|
|
35
|
-
@sources.collect { |s| s.name }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def morphology
|
|
39
|
-
nil_join @morphologies, ", "
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def morphology=(morphology)
|
|
43
|
-
@morphologies = nil_split morphology, /,\s?/
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def stopwords
|
|
47
|
-
nil_join @stopword_files, " "
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def stopwords=(stopwords)
|
|
51
|
-
@stopword_files = nil_split stopwords, ' '
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def wordforms
|
|
55
|
-
nil_join @wordform_files, " "
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def wordforms=(wordforms)
|
|
59
|
-
@wordform_files = nil_split wordforms, ' '
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def exceptions
|
|
63
|
-
nil_join @exception_files, " "
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def exceptions=(exceptions)
|
|
67
|
-
@exception_files = nil_split exceptions, ' '
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def ignore_chars
|
|
71
|
-
nil_join @ignore_characters, ", "
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def ignore_chars=(ignore_chars)
|
|
75
|
-
@ignore_characters = nil_split ignore_chars, /,\s?/
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def prefix_fields
|
|
79
|
-
nil_join @prefix_field_names, ", "
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def infix_fields
|
|
83
|
-
nil_join @infix_field_names, ", "
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def ngram_chars
|
|
87
|
-
nil_join @ngram_characters, ", "
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def ngram_chars=(ngram_chars)
|
|
91
|
-
@ngram_characters = nil_split ngram_chars, /,\s?/
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def phrase_boundary
|
|
95
|
-
nil_join @phrase_boundaries, ", "
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def phrase_boundary=(phrase_boundary)
|
|
99
|
-
@phrase_boundaries = nil_split phrase_boundary, /,\s?/
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def html_remove_elements
|
|
103
|
-
nil_join @html_remove_element_tags, ", "
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def html_remove_elements=(html_remove_elements)
|
|
107
|
-
@html_remove_element_tags = nil_split html_remove_elements, /,\s?/
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def render
|
|
111
|
-
raise ConfigurationError, "#{@name} #{@sources.inspect} #{@path} #{@parent}" unless valid?
|
|
112
|
-
|
|
113
|
-
inherited_name = "#{name}"
|
|
114
|
-
inherited_name << " : #{parent}" if parent
|
|
115
|
-
(
|
|
116
|
-
@sources.collect { |s| s.render } +
|
|
117
|
-
["index #{inherited_name}", "{"] +
|
|
118
|
-
settings_body +
|
|
119
|
-
["}", ""]
|
|
120
|
-
).join("\n")
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def valid?
|
|
124
|
-
(!@name.nil?) && (!( @sources.length == 0 || @path.nil? ) || !@parent.nil?)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
private
|
|
128
|
-
|
|
129
|
-
def nil_split(string, pattern)
|
|
130
|
-
(string || "").split(pattern)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def nil_join(array, delimiter)
|
|
134
|
-
if array.length == 0
|
|
135
|
-
nil
|
|
136
|
-
else
|
|
137
|
-
array.join(delimiter)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
|
@@ -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,33 +0,0 @@
|
|
|
1
|
-
require 'riddle/configuration/section'
|
|
2
|
-
|
|
3
|
-
require 'riddle/configuration/distributed_index'
|
|
4
|
-
require 'riddle/configuration/index'
|
|
5
|
-
require 'riddle/configuration/indexer'
|
|
6
|
-
require 'riddle/configuration/remote_index'
|
|
7
|
-
require 'riddle/configuration/searchd'
|
|
8
|
-
require 'riddle/configuration/source'
|
|
9
|
-
require 'riddle/configuration/sql_source'
|
|
10
|
-
require 'riddle/configuration/xml_source'
|
|
11
|
-
|
|
12
|
-
module Riddle
|
|
13
|
-
class Configuration
|
|
14
|
-
class ConfigurationError < StandardError #:nodoc:
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
attr_reader :indexes, :searchd
|
|
18
|
-
attr_accessor :indexer
|
|
19
|
-
|
|
20
|
-
def initialize
|
|
21
|
-
@indexer = Riddle::Configuration::Indexer.new
|
|
22
|
-
@searchd = Riddle::Configuration::Searchd.new
|
|
23
|
-
@indexes = []
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def render
|
|
27
|
-
(
|
|
28
|
-
[@indexer.render, @searchd.render] +
|
|
29
|
-
@indexes.collect { |index| index.render }
|
|
30
|
-
).join("\n")
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
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
|
data/vendor/riddle/lib/riddle.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'socket'
|
|
2
|
-
require 'timeout'
|
|
3
|
-
|
|
4
|
-
require 'riddle/client'
|
|
5
|
-
require 'riddle/configuration'
|
|
6
|
-
require 'riddle/controller'
|
|
7
|
-
|
|
8
|
-
module Riddle #:nodoc:
|
|
9
|
-
class ConnectionError < StandardError #:nodoc:
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module Version #:nodoc:
|
|
13
|
-
Major = 0
|
|
14
|
-
Minor = 9
|
|
15
|
-
Tiny = 8
|
|
16
|
-
# Revision number for RubyForge's sake, taken from what Sphinx
|
|
17
|
-
# outputs to the command line.
|
|
18
|
-
Rev = 1533
|
|
19
|
-
# Release number to mark my own fixes, beyond feature parity with
|
|
20
|
-
# Sphinx itself.
|
|
21
|
-
Release = 10
|
|
22
|
-
|
|
23
|
-
String = [Major, Minor, Tiny].join('.')
|
|
24
|
-
GemVersion = [Major, Minor, Tiny, Rev, Release].join('.')
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.escape(string)
|
|
28
|
-
string.gsub(/[\(\)\|\-!@~"&\/]/) { |char| "\\#{char}" }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|