riddle 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -1
- data/lib/riddle/client.rb +3 -3
- data/lib/riddle/configuration/section.rb +15 -1
- data/lib/riddle/configuration/sql_source.rb +0 -13
- data/lib/riddle/controller.rb +2 -2
- data/spec/functional/update_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/configuration/sql_source_spec.rb +4 -3
- metadata +62 -13
data/README.textile
CHANGED
@@ -61,7 +61,7 @@ that the query took to run.
|
|
61
61
|
@:status@ is the error code for the query - and if there was a related warning, it will be under
|
62
62
|
the @:warning@ key. Fatal errors will be described under @:error@.
|
63
63
|
|
64
|
-
If you've installed the gem and wondering why there's no tests - check out the
|
64
|
+
If you've installed the gem and wondering why there's no tests - check out the git version. I've kept the specs out of the gem as I have a decent amount of test data in there, which really isn't needed unless you want to submit patches.
|
65
65
|
|
66
66
|
h2. Contributors
|
67
67
|
|
@@ -80,3 +80,4 @@ Thanks to the following people who have contributed to Riddle in some shape or f
|
|
80
80
|
* Jerry Vos
|
81
81
|
* Piotr Sarnacki
|
82
82
|
* Tim Preston
|
83
|
+
* Amir Yalon
|
data/lib/riddle/client.rb
CHANGED
@@ -175,9 +175,9 @@ module Riddle
|
|
175
175
|
# the latitude and longitude (in radians), and the reference position.
|
176
176
|
# Note that for geocoding to work properly, you must also set
|
177
177
|
# match_mode to :extended. To sort results by distance, you will
|
178
|
-
# need to set
|
179
|
-
# expects latitude and longitude to be returned from you
|
180
|
-
# in radians.
|
178
|
+
# need to set sort_by to '@geodist asc', and sort_mode to extended (as an
|
179
|
+
# example). Sphinx expects latitude and longitude to be returned from you
|
180
|
+
# SQL source in radians.
|
181
181
|
#
|
182
182
|
# Example:
|
183
183
|
# client.set_anchor('lat', -0.6591741, 'long', 2.530770)
|
@@ -21,7 +21,7 @@ module Riddle
|
|
21
21
|
conf = " #{setting} = "
|
22
22
|
else
|
23
23
|
conf = setting_to_array(setting).collect { |set|
|
24
|
-
" #{setting} = #{set}"
|
24
|
+
" #{setting} = #{rendered_setting set}"
|
25
25
|
}
|
26
26
|
end
|
27
27
|
conf.length == 0 ? nil : conf
|
@@ -38,6 +38,20 @@ module Riddle
|
|
38
38
|
[value]
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
def rendered_setting(setting)
|
43
|
+
return setting unless setting.is_a?(String)
|
44
|
+
|
45
|
+
index = 8100
|
46
|
+
output = setting.clone
|
47
|
+
|
48
|
+
while index < output.length
|
49
|
+
output.insert(index, "\\\n")
|
50
|
+
index += 8100
|
51
|
+
end
|
52
|
+
|
53
|
+
output
|
54
|
+
end
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
@@ -31,19 +31,6 @@ module Riddle
|
|
31
31
|
@unpack_mysqlcompress = []
|
32
32
|
end
|
33
33
|
|
34
|
-
def sql_query=(query)
|
35
|
-
unless query.nil?
|
36
|
-
max_length = 8178 # max is: 8192 - "sql_query = ".length - "\\\n".length
|
37
|
-
i = max_length
|
38
|
-
while i < query.length
|
39
|
-
i = query.rindex(" ", i)
|
40
|
-
query.insert(i, "\\" + "\n")
|
41
|
-
i = i + max_length
|
42
|
-
end
|
43
|
-
end
|
44
|
-
@sql_query = query
|
45
|
-
end
|
46
|
-
|
47
34
|
def valid?
|
48
35
|
super && (!( @sql_host.nil? || @sql_user.nil? || @sql_db.nil? ||
|
49
36
|
@sql_query.nil? ) || !@parent.nil?)
|
data/lib/riddle/controller.rb
CHANGED
@@ -21,7 +21,7 @@ module Riddle
|
|
21
21
|
options = indexes.last.is_a?(Hash) ? indexes.pop : {}
|
22
22
|
indexes << '--all' if indexes.empty?
|
23
23
|
|
24
|
-
cmd = "#{indexer} --config #{@path} #{indexes.join(' ')}"
|
24
|
+
cmd = "#{indexer} --config '#{@path}' #{indexes.join(' ')}"
|
25
25
|
cmd << " --rotate" if running?
|
26
26
|
options[:verbose] ? system(cmd) : `#{cmd}`
|
27
27
|
end
|
@@ -29,7 +29,7 @@ module Riddle
|
|
29
29
|
def start
|
30
30
|
return if running?
|
31
31
|
|
32
|
-
cmd = "#{searchd} --pidfile --config #{@path}"
|
32
|
+
cmd = "#{searchd} --pidfile --config '#{@path}'"
|
33
33
|
|
34
34
|
if RUBY_PLATFORM =~ /mswin/
|
35
35
|
system("start /B #{cmd} 1> NUL 2>&1")
|
@@ -11,17 +11,17 @@ describe "Sphinx Updates" do
|
|
11
11
|
result[:matches].should_not be_empty
|
12
12
|
result[:matches].length.should == 1
|
13
13
|
ellie = result[:matches].first
|
14
|
-
ellie[:attributes]["birthday"].should == Time.
|
14
|
+
ellie[:attributes]["birthday"].should == Time.local(1970, 1, 23).to_i
|
15
15
|
|
16
16
|
# make Ellie younger by 6 years
|
17
|
-
@client.update("people", ["birthday"], {ellie[:doc] => [Time.
|
17
|
+
@client.update("people", ["birthday"], {ellie[:doc] => [Time.local(1976, 1, 23).to_i]})
|
18
18
|
|
19
19
|
# check attribute's value
|
20
20
|
result = @client.query("Ellie K Ford")
|
21
21
|
result[:matches].should_not be_empty
|
22
22
|
result[:matches].length.should == 1
|
23
23
|
ellie = result[:matches].first
|
24
|
-
ellie[:attributes]["birthday"].should == Time.
|
24
|
+
ellie[:attributes]["birthday"].should == Time.local(1976, 1, 23).to_i
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should update multiple records appropriately" do
|
data/spec/spec_helper.rb
CHANGED
@@ -116,16 +116,17 @@ source src1
|
|
116
116
|
it "should insert a backslash-newline into an sql_query when greater than 8178 characters" do
|
117
117
|
source = Riddle::Configuration::SQLSource.new("src1", "mysql")
|
118
118
|
source.sql_query = big_query_string[0, 8200]
|
119
|
+
source.parent = 'src0'
|
119
120
|
|
120
|
-
|
121
|
+
source.render.should match(/sql_query\s=\s[^\n]+\\\n/)
|
121
122
|
end
|
122
123
|
|
123
124
|
it "should insert two backslash-newlines into an sql_query when greater than 16,356 characters" do
|
124
125
|
source = Riddle::Configuration::SQLSource.new("src1", "mysql")
|
125
126
|
source.sql_query = big_query_string
|
127
|
+
source.parent = 'src0'
|
126
128
|
|
127
|
-
|
128
|
-
(source.sql_query.index("\\\n", 8178) < 16356).should be_true
|
129
|
+
source.render.should match(/sql_query\s=\s[^\n]+\\\n[^\n]+\\\n/)
|
129
130
|
end
|
130
131
|
|
131
132
|
def big_query_string
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 1
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 11
|
10
|
+
version: 1.0.11
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Pat Allan
|
@@ -9,29 +15,39 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-06-30 00:00:00 +10:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
23
34
|
version: 1.2.9
|
24
|
-
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: yard
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
43
|
- - ">="
|
32
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
33
48
|
version: "0"
|
34
|
-
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
35
51
|
description: A Ruby API and configuration helper for the Sphinx search service.
|
36
52
|
email: pat@freelancing-gods.com
|
37
53
|
executables: []
|
@@ -64,6 +80,33 @@ files:
|
|
64
80
|
- lib/riddle/configuration/sql_source.rb
|
65
81
|
- lib/riddle/configuration/xml_source.rb
|
66
82
|
- lib/riddle/controller.rb
|
83
|
+
- spec/functional/connection_spec.rb
|
84
|
+
- spec/functional/excerpt_spec.rb
|
85
|
+
- spec/functional/keywords_spec.rb
|
86
|
+
- spec/functional/persistance_spec.rb
|
87
|
+
- spec/functional/search_spec.rb
|
88
|
+
- spec/functional/status_spec.rb
|
89
|
+
- spec/functional/update_spec.rb
|
90
|
+
- spec/riddle/auto_version_spec.rb
|
91
|
+
- spec/riddle/client_spec.rb
|
92
|
+
- spec/riddle/configuration_spec.rb
|
93
|
+
- spec/riddle/controller_spec.rb
|
94
|
+
- spec/riddle_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
- spec/sphinx_helper.rb
|
97
|
+
- spec/unit/client_spec.rb
|
98
|
+
- spec/unit/configuration/distributed_index_spec.rb
|
99
|
+
- spec/unit/configuration/index_spec.rb
|
100
|
+
- spec/unit/configuration/indexer_spec.rb
|
101
|
+
- spec/unit/configuration/searchd_spec.rb
|
102
|
+
- spec/unit/configuration/source_spec.rb
|
103
|
+
- spec/unit/configuration/sql_source_spec.rb
|
104
|
+
- spec/unit/configuration/xml_source_spec.rb
|
105
|
+
- spec/unit/configuration_spec.rb
|
106
|
+
- spec/unit/filter_spec.rb
|
107
|
+
- spec/unit/message_spec.rb
|
108
|
+
- spec/unit/response_spec.rb
|
109
|
+
- spec/unit/riddle_spec.rb
|
67
110
|
has_rdoc: true
|
68
111
|
homepage: http://riddle.freelancing-gods.com
|
69
112
|
licenses: []
|
@@ -74,21 +117,27 @@ rdoc_options:
|
|
74
117
|
require_paths:
|
75
118
|
- lib
|
76
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
77
121
|
requirements:
|
78
122
|
- - ">="
|
79
123
|
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
125
|
+
segments:
|
126
|
+
- 0
|
80
127
|
version: "0"
|
81
|
-
version:
|
82
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
83
130
|
requirements:
|
84
131
|
- - ">="
|
85
132
|
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
86
136
|
version: "0"
|
87
|
-
version:
|
88
137
|
requirements: []
|
89
138
|
|
90
139
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.3.
|
140
|
+
rubygems_version: 1.3.7
|
92
141
|
signing_key:
|
93
142
|
specification_version: 3
|
94
143
|
summary: An API for Sphinx, written in and for Ruby.
|