riddle 0.9.8.1112
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/MIT-LICENCE +20 -0
- data/README +60 -0
- data/lib/riddle.rb +20 -0
- data/lib/riddle/client.rb +548 -0
- data/lib/riddle/client/filter.rb +44 -0
- data/lib/riddle/client/message.rb +65 -0
- data/lib/riddle/client/response.rb +74 -0
- data/spec/fixtures/data/anchor.bin +0 -0
- data/spec/fixtures/data/any.bin +0 -0
- data/spec/fixtures/data/boolean.bin +0 -0
- data/spec/fixtures/data/distinct.bin +0 -0
- data/spec/fixtures/data/field_weights.bin +0 -0
- data/spec/fixtures/data/filter.bin +0 -0
- data/spec/fixtures/data/filter_array.bin +0 -0
- data/spec/fixtures/data/filter_array_exclude.bin +0 -0
- data/spec/fixtures/data/filter_floats.bin +0 -0
- data/spec/fixtures/data/filter_floats_exclude.bin +0 -0
- data/spec/fixtures/data/filter_floats_range.bin +0 -0
- data/spec/fixtures/data/filter_range.bin +0 -0
- data/spec/fixtures/data/filter_range_exclude.bin +0 -0
- data/spec/fixtures/data/group.bin +0 -0
- data/spec/fixtures/data/index.bin +0 -0
- data/spec/fixtures/data/index_weights.bin +0 -0
- data/spec/fixtures/data/phrase.bin +0 -0
- data/spec/fixtures/data/rank_mode.bin +0 -0
- data/spec/fixtures/data/simple.bin +0 -0
- data/spec/fixtures/data/sort.bin +0 -0
- data/spec/fixtures/data/update_simple.bin +0 -0
- data/spec/fixtures/data/weights.bin +0 -0
- data/spec/fixtures/data_generator.php +130 -0
- data/spec/fixtures/sphinx/configuration.erb +38 -0
- data/spec/fixtures/sphinx/people.old.spa +0 -0
- data/spec/fixtures/sphinx/people.old.spd +0 -0
- data/spec/fixtures/sphinx/people.old.sph +0 -0
- data/spec/fixtures/sphinx/people.old.spi +0 -0
- data/spec/fixtures/sphinx/people.old.spm +0 -0
- data/spec/fixtures/sphinx/people.old.spp +0 -0
- data/spec/fixtures/sphinx/people.spa +0 -0
- data/spec/fixtures/sphinx/people.spd +0 -0
- data/spec/fixtures/sphinx/people.sph +0 -0
- data/spec/fixtures/sphinx/people.spi +0 -0
- data/spec/fixtures/sphinx/people.spm +0 -0
- data/spec/fixtures/sphinx/people.spp +0 -0
- data/spec/fixtures/sphinx/searchd.log +4732 -0
- data/spec/fixtures/sphinx/searchd.query.log +783 -0
- data/spec/fixtures/sphinx/spec.conf +38 -0
- data/spec/fixtures/sphinxapi.php +1066 -0
- data/spec/fixtures/sql/conf.example.yml +3 -0
- data/spec/fixtures/sql/conf.yml +3 -0
- data/spec/fixtures/sql/data.sql +25000 -0
- data/spec/fixtures/sql/structure.sql +16 -0
- data/spec/functional/excerpt_spec.rb +102 -0
- data/spec/functional/search_spec.rb +69 -0
- data/spec/functional/update_spec.rb +41 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/sphinx_helper.rb +92 -0
- data/spec/unit/client_spec.rb +154 -0
- data/spec/unit/filter_spec.rb +33 -0
- data/spec/unit/message_spec.rb +63 -0
- data/spec/unit/response_spec.rb +64 -0
- metadata +128 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Riddle::Client::Filter do
|
4
|
+
it "should render a filter that uses an array of ints correctly" do
|
5
|
+
filter = Riddle::Client::Filter.new("field", [1, 2, 3])
|
6
|
+
filter.query_message.should == query_contents(:filter_array)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should render a filter that has exclude set correctly" do
|
10
|
+
filter = Riddle::Client::Filter.new("field", [1, 2, 3], true)
|
11
|
+
filter.query_message.should == query_contents(:filter_array_exclude)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should render a filter that is a range of ints correctly" do
|
15
|
+
filter = Riddle::Client::Filter.new("field", 1..3)
|
16
|
+
filter.query_message.should == query_contents(:filter_range)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should render a filter that is a range of ints as exclude correctly" do
|
20
|
+
filter = Riddle::Client::Filter.new("field", 1..3, true)
|
21
|
+
filter.query_message.should == query_contents(:filter_range_exclude)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should render a filter that is a range of floats correctly" do
|
25
|
+
filter = Riddle::Client::Filter.new("field", 5.4..13.5)
|
26
|
+
filter.query_message.should == query_contents(:filter_floats)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should render a filter that is a range of floats as exclude correctly" do
|
30
|
+
filter = Riddle::Client::Filter.new("field", 5.4..13.5, true)
|
31
|
+
filter.query_message.should == query_contents(:filter_floats_exclude)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Riddle::Client::Message do
|
4
|
+
it "should start with an empty string" do
|
5
|
+
Riddle::Client::Message.new.to_s.should == ""
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should append raw data correctly" do
|
9
|
+
data = [1, 2, 3].pack('NNN')
|
10
|
+
message = Riddle::Client::Message.new
|
11
|
+
message.append data
|
12
|
+
message.to_s.should == data
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should append strings correctly - with length first" do
|
16
|
+
str = "something to test with"
|
17
|
+
message = Riddle::Client::Message.new
|
18
|
+
message.append_string str
|
19
|
+
message.to_s.should == [str.length].pack('N') + str
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should append integers correctly - packed with N" do
|
23
|
+
message = Riddle::Client::Message.new
|
24
|
+
message.append_int 234
|
25
|
+
message.to_s.should == [234].pack('N')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should append floats correctly - packed with f" do
|
29
|
+
message = Riddle::Client::Message.new
|
30
|
+
message.append_float 1.4
|
31
|
+
message.to_s.should == [1.4].pack('f').unpack('L*').pack('N')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should append a collection of integers correctly" do
|
35
|
+
message = Riddle::Client::Message.new
|
36
|
+
message.append_ints 1, 2, 3, 4
|
37
|
+
message.to_s.should == [1, 2, 3, 4].pack('NNNN')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should append a collection of floats correctly" do
|
41
|
+
message = Riddle::Client::Message.new
|
42
|
+
message.append_floats 1.0, 1.1, 1.2, 1.3
|
43
|
+
message.to_s.should == [1.0, 1.1, 1.2, 1.3].pack('ffff').unpack('L*L*L*L*').pack('NNNN')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should append an array of strings correctly" do
|
47
|
+
arr = ["a", "bb", "ccc"]
|
48
|
+
message = Riddle::Client::Message.new
|
49
|
+
message.append_array arr
|
50
|
+
message.to_s.should == [3, 1].pack('NN') + "a" + [2].pack('N') + "bb" +
|
51
|
+
[3].pack('N') + "ccc"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should append a variety of objects correctly" do
|
55
|
+
message = Riddle::Client::Message.new
|
56
|
+
message.append_int 4
|
57
|
+
message.append_string "test"
|
58
|
+
message.append_array ["one", "two"]
|
59
|
+
message.append_floats 1.5, 1.7
|
60
|
+
message.to_s.should == [4, 4].pack('NN') + "test" + [2, 3].pack('NN') +
|
61
|
+
"one" + [3].pack('N') + "two" + [1.5, 1.7].pack('ff').unpack('L*L*').pack('NN')
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Riddle::Client::Response do
|
4
|
+
it "should interpret an integer correctly" do
|
5
|
+
Riddle::Client::Response.new([42].pack('N')).next_int.should == 42
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should interpret a string correctly" do
|
9
|
+
str = "this is a string"
|
10
|
+
Riddle::Client::Response.new(
|
11
|
+
[str.length].pack('N') + str
|
12
|
+
).next.should == str
|
13
|
+
end
|
14
|
+
|
15
|
+
# Comparing floats with decimal places doesn't seem to be exact
|
16
|
+
it "should interpret a float correctly" do
|
17
|
+
Riddle::Client::Response.new([1.0].pack('f').unpack('L*').pack('N')).next_float.should == 1.0
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should interpret an array of strings correctly" do
|
21
|
+
arr = ["a", "b", "c", "d"]
|
22
|
+
Riddle::Client::Response.new(
|
23
|
+
[arr.length].pack('N') + arr.collect { |str|
|
24
|
+
[str.length].pack('N') + str
|
25
|
+
}.join("")
|
26
|
+
).next_array.should == arr
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should interpret an array of ints correctly" do
|
30
|
+
arr = [1, 2, 3, 4]
|
31
|
+
Riddle::Client::Response.new(
|
32
|
+
[arr.length].pack('N') + arr.collect { |int|
|
33
|
+
[int].pack('N')
|
34
|
+
}.join("")
|
35
|
+
).next_int_array.should == arr
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should reflect the length of the incoming data correctly" do
|
39
|
+
data = [1, 2, 3, 4].pack('NNNN')
|
40
|
+
Riddle::Client::Response.new(data).length.should == data.length
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should handle a combination of strings and ints correctly" do
|
44
|
+
data = [1, 3, 5, 1].pack('NNNN') + 'a' + [2, 4].pack('NN') + 'test'
|
45
|
+
response = Riddle::Client::Response.new(data)
|
46
|
+
response.next_int.should == 1
|
47
|
+
response.next_int.should == 3
|
48
|
+
response.next_int.should == 5
|
49
|
+
response.next.should == 'a'
|
50
|
+
response.next_int.should == 2
|
51
|
+
response.next.should == 'test'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should handle a combination of strings, ints, floats and string arrays correctly" do
|
55
|
+
data = [1, 2, 2].pack('NNN') + 'aa' + [2].pack('N') + 'bb' + [4].pack('N') +
|
56
|
+
"word" + [7].pack('f').unpack('L*').pack('N') + [3, 2, 2, 2].pack('NNNN')
|
57
|
+
response = Riddle::Client::Response.new(data)
|
58
|
+
response.next_int.should == 1
|
59
|
+
response.next_array.should == ['aa', 'bb']
|
60
|
+
response.next.should == "word"
|
61
|
+
response.next_float.should == 7
|
62
|
+
response.next_int_array.should == [2, 2, 2]
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riddle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.8.1112
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pat Allan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-05 00:00:00 +11:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: API for Sphinx, written in and for Ruby.
|
17
|
+
email: pat@freelancing-gods.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/riddle/client/filter.rb
|
26
|
+
- lib/riddle/client/message.rb
|
27
|
+
- lib/riddle/client/response.rb
|
28
|
+
- lib/riddle/client.rb
|
29
|
+
- lib/riddle.rb
|
30
|
+
- MIT-LICENCE
|
31
|
+
- README
|
32
|
+
- spec/fixtures
|
33
|
+
- spec/fixtures/data
|
34
|
+
- spec/fixtures/data/anchor.bin
|
35
|
+
- spec/fixtures/data/any.bin
|
36
|
+
- spec/fixtures/data/boolean.bin
|
37
|
+
- spec/fixtures/data/distinct.bin
|
38
|
+
- spec/fixtures/data/field_weights.bin
|
39
|
+
- spec/fixtures/data/filter.bin
|
40
|
+
- spec/fixtures/data/filter_array.bin
|
41
|
+
- spec/fixtures/data/filter_array_exclude.bin
|
42
|
+
- spec/fixtures/data/filter_floats.bin
|
43
|
+
- spec/fixtures/data/filter_floats_exclude.bin
|
44
|
+
- spec/fixtures/data/filter_floats_range.bin
|
45
|
+
- spec/fixtures/data/filter_range.bin
|
46
|
+
- spec/fixtures/data/filter_range_exclude.bin
|
47
|
+
- spec/fixtures/data/group.bin
|
48
|
+
- spec/fixtures/data/index.bin
|
49
|
+
- spec/fixtures/data/index_weights.bin
|
50
|
+
- spec/fixtures/data/phrase.bin
|
51
|
+
- spec/fixtures/data/rank_mode.bin
|
52
|
+
- spec/fixtures/data/simple.bin
|
53
|
+
- spec/fixtures/data/sort.bin
|
54
|
+
- spec/fixtures/data/update_simple.bin
|
55
|
+
- spec/fixtures/data/weights.bin
|
56
|
+
- spec/fixtures/data_generator.php
|
57
|
+
- spec/fixtures/sphinx
|
58
|
+
- spec/fixtures/sphinx/configuration.erb
|
59
|
+
- spec/fixtures/sphinx/people.old.spa
|
60
|
+
- spec/fixtures/sphinx/people.old.spd
|
61
|
+
- spec/fixtures/sphinx/people.old.sph
|
62
|
+
- spec/fixtures/sphinx/people.old.spi
|
63
|
+
- spec/fixtures/sphinx/people.old.spm
|
64
|
+
- spec/fixtures/sphinx/people.old.spp
|
65
|
+
- spec/fixtures/sphinx/people.spa
|
66
|
+
- spec/fixtures/sphinx/people.spd
|
67
|
+
- spec/fixtures/sphinx/people.sph
|
68
|
+
- spec/fixtures/sphinx/people.spi
|
69
|
+
- spec/fixtures/sphinx/people.spm
|
70
|
+
- spec/fixtures/sphinx/people.spp
|
71
|
+
- spec/fixtures/sphinx/searchd.log
|
72
|
+
- spec/fixtures/sphinx/searchd.query.log
|
73
|
+
- spec/fixtures/sphinx/spec.conf
|
74
|
+
- spec/fixtures/sphinxapi.php
|
75
|
+
- spec/fixtures/sql
|
76
|
+
- spec/fixtures/sql/conf.example.yml
|
77
|
+
- spec/fixtures/sql/conf.yml
|
78
|
+
- spec/fixtures/sql/data.sql
|
79
|
+
- spec/fixtures/sql/structure.sql
|
80
|
+
- spec/functional
|
81
|
+
- spec/functional/excerpt_spec.rb
|
82
|
+
- spec/functional/search_spec.rb
|
83
|
+
- spec/functional/update_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
- spec/sphinx_helper.rb
|
86
|
+
- spec/unit
|
87
|
+
- spec/unit/client_spec.rb
|
88
|
+
- spec/unit/filter_spec.rb
|
89
|
+
- spec/unit/message_spec.rb
|
90
|
+
- spec/unit/response_spec.rb
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://riddle.freelancing-gods.com
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options:
|
95
|
+
- --title
|
96
|
+
- Riddle -- Ruby Sphinx Client
|
97
|
+
- --main
|
98
|
+
- Riddle::Client
|
99
|
+
- --line-numbers
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project: riddle
|
117
|
+
rubygems_version: 1.0.1
|
118
|
+
signing_key:
|
119
|
+
specification_version: 2
|
120
|
+
summary: API for Sphinx, written in and for Ruby.
|
121
|
+
test_files:
|
122
|
+
- spec/functional/excerpt_spec.rb
|
123
|
+
- spec/functional/search_spec.rb
|
124
|
+
- spec/functional/update_spec.rb
|
125
|
+
- spec/unit/client_spec.rb
|
126
|
+
- spec/unit/filter_spec.rb
|
127
|
+
- spec/unit/message_spec.rb
|
128
|
+
- spec/unit/response_spec.rb
|