riddle 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/HISTORY +6 -0
- data/README.markdown +1 -1
- data/lib/riddle/0.9.9/configuration/searchd.rb +4 -2
- data/lib/riddle/configuration/parser.rb +1 -1
- data/lib/riddle/query.rb +6 -1
- data/lib/riddle/query/select.rb +2 -0
- data/riddle.gemspec +1 -1
- data/spec/riddle/query/select_spec.rb +5 -0
- data/spec/riddle/query_spec.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9703ab2715784c618307e9081ebf69b2bea0ed08
|
4
|
+
data.tar.gz: 9570d8929bbb278985a468570c34ddc6cf702502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d097ac478f457a842116c00ba098ebc0d70b19e5fad881b53aa7721ac2058d75e3c63a05647185e9c58931bfa06adce4e5c8405018197f0bf6cdce11794dfe2
|
7
|
+
data.tar.gz: 2375a83b6ff035108262bc185483ecbe7a13a7abedf676fb2df20ab293b52eefa4fee4df1b9d003b642600b0109461e9d75e6bf715718d1bbc0d2a8b30bda69b
|
data/.travis.yml
CHANGED
data/HISTORY
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
2.1.0 - January 5th 2017
|
2
|
+
- Wrap string attribute filter values in single quotes.
|
3
|
+
- Remove direct references to FixNum to avoid MRI 2.4 warnings.
|
4
|
+
- Remove escaped line-endings while parsing.
|
5
|
+
- Escape word-operators like MAYBE, NEAR etc (Jonathan del Strother)
|
6
|
+
|
1
7
|
2.0.0 - September 25th 2016
|
2
8
|
- Start and stop commands now accept a verbose option.
|
3
9
|
- Failed commands (as determined by a non-zero status code) raise a Riddle::CommandFailedError exception.
|
data/README.markdown
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Riddle
|
2
2
|
class Configuration
|
3
3
|
class Searchd
|
4
|
+
NUMBER = 1.class
|
5
|
+
|
4
6
|
def valid?
|
5
7
|
set_listen
|
6
8
|
|
@@ -10,14 +12,14 @@ module Riddle
|
|
10
12
|
private
|
11
13
|
|
12
14
|
def set_listen
|
13
|
-
@listen = @listen.to_s if @listen.is_a?(
|
15
|
+
@listen = @listen.to_s if @listen.is_a?(NUMBER)
|
14
16
|
|
15
17
|
return unless @listen.nil? || @listen.empty?
|
16
18
|
|
17
19
|
@listen = []
|
18
20
|
@listen << @port.to_s if @port
|
19
21
|
@listen << "9306:mysql41" if @mysql41.is_a?(TrueClass)
|
20
|
-
@listen << "#{@mysql41}:mysql41" if @mysql41.is_a?(
|
22
|
+
@listen << "#{@mysql41}:mysql41" if @mysql41.is_a?(NUMBER)
|
21
23
|
|
22
24
|
@listen.each { |l| l.insert(0, "#{@address}:") } if @address
|
23
25
|
end
|
data/lib/riddle/query.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
module Riddle::Query
|
2
|
+
ESCAPE_CHARACTERS = /[\(\)\|\-!@~\/"\/\^\$\\><&=\?]/
|
3
|
+
# http://sphinxsearch.com/docs/current/extended-syntax.html
|
4
|
+
ESCAPE_WORDS = /\b(?:MAYBE|NEAR|PARAGRAPH|SENTENCE|ZONE|ZONESPAN)\b/
|
5
|
+
|
2
6
|
def self.connection(address = '127.0.0.1', port = 9312)
|
3
7
|
require 'mysql2'
|
4
8
|
|
@@ -99,7 +103,8 @@ module Riddle::Query
|
|
99
103
|
end
|
100
104
|
|
101
105
|
def self.escape(string)
|
102
|
-
string.gsub(
|
106
|
+
string.gsub(ESCAPE_CHARACTERS) { |match| "\\#{match}" }
|
107
|
+
.gsub(ESCAPE_WORDS) { |word| "\\#{word}" }
|
103
108
|
end
|
104
109
|
|
105
110
|
def self.quote(string)
|
data/lib/riddle/query/select.rb
CHANGED
data/riddle.gemspec
CHANGED
@@ -122,6 +122,11 @@ describe Riddle::Query::Select do
|
|
122
122
|
should == "SELECT * FROM foo_core WHERE MATCH('foo') AND `bar` BETWEEN 1 AND 5"
|
123
123
|
end
|
124
124
|
|
125
|
+
it "handles filters with strings" do
|
126
|
+
query.from('foo_core').where(:bar => 'baz').to_sql.
|
127
|
+
should == "SELECT * FROM foo_core WHERE `bar` = 'baz'"
|
128
|
+
end
|
129
|
+
|
125
130
|
it "handles filters expecting matches on all values" do
|
126
131
|
query.from('foo_core').where_all(:bars => [1, 2]).to_sql.
|
127
132
|
should == "SELECT * FROM foo_core WHERE `bars` = 1 AND `bars` = 2"
|
data/spec/riddle/query_spec.rb
CHANGED
@@ -83,5 +83,15 @@ describe Riddle::Query do
|
|
83
83
|
Riddle::Query.escape(reserved).should == "\\#{reserved}"
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
it "escapes word-operators correctly" do
|
88
|
+
operators = ['MAYBE', 'NEAR', 'PARAGRAPH', 'SENTENCE', 'ZONE', 'ZONESPAN']
|
89
|
+
operators.each do |operator|
|
90
|
+
base = "string with #{operator} operator"
|
91
|
+
Riddle::Query.escape(base).should == base.gsub(operator, "\\#{operator}")
|
92
|
+
end
|
93
|
+
|
94
|
+
Riddle::Query.escape("FIND THE ZONES").should == "FIND THE ZONES"
|
95
|
+
end
|
86
96
|
end
|
87
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
289
|
version: '0'
|
290
290
|
requirements: []
|
291
291
|
rubyforge_project: riddle
|
292
|
-
rubygems_version: 2.
|
292
|
+
rubygems_version: 2.6.8
|
293
293
|
signing_key:
|
294
294
|
specification_version: 4
|
295
295
|
summary: An API for Sphinx, written in and for Ruby.
|