asari 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asari.rb +1 -1
- data/lib/asari/version.rb +1 -1
- data/spec/search_spec.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54baa28b62335e23583d5e9da5939ec8bb108987
|
4
|
+
data.tar.gz: 95b665a1aebec36503b41d9b4cb7e0b2f9d7fafa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 728fa33023f96338a4776c5b6ba9d149e3ae72dd273992f70efea3cae2cebda89827a40a218b48d4611695563cb4293e67d61a2df1f277019343ca48a40da8b9
|
7
|
+
data.tar.gz: eff402cf51a42167726ede40f145dcae12587de6210e6a1c3b23a6f1b986b3bc5cc6bcfca0f3804460d9e119ce02348cc7ea1767dedaf8df855375cd81730539
|
data/lib/asari.rb
CHANGED
@@ -207,7 +207,7 @@ class Asari
|
|
207
207
|
hash.reduce("") do |memo, (key, value)|
|
208
208
|
if %w(and or not).include?(key.to_s) && value.is_a?(Hash)
|
209
209
|
sub_query = reduce.call(value)
|
210
|
-
memo += "(#{key}#{sub_query})" unless sub_query.empty?
|
210
|
+
memo += " (#{key}#{sub_query})" unless sub_query.empty?
|
211
211
|
else
|
212
212
|
if value.is_a?(Range) || value.is_a?(Integer)
|
213
213
|
memo += " #{key}:#{value}"
|
data/lib/asari/version.rb
CHANGED
data/spec/search_spec.rb
CHANGED
@@ -118,46 +118,46 @@ describe Asari do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "builds a query string from a passed hash" do
|
121
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
121
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28and+foo%3A%27bar%27+baz%3A%27bug%27%29&size=10")
|
122
122
|
@asari.search(filter: { and: { foo: "bar", baz: "bug" }})
|
123
123
|
end
|
124
124
|
|
125
125
|
it "honors the logic types" do
|
126
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
126
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28or+foo%3A%27bar%27+baz%3A%27bug%27%29&size=10")
|
127
127
|
@asari.search(filter: { or: { foo: "bar", baz: "bug" }})
|
128
128
|
end
|
129
129
|
|
130
130
|
it "supports nested logic" do
|
131
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
131
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28or+is_donut%3A%27true%27+%28and+round%3A%27true%27+frosting%3A%27true%27+fried%3A%27true%27%29%29&size=10")
|
132
132
|
@asari.search(filter: { or: { is_donut: true, and:
|
133
133
|
{ round: true, frosting: true, fried: true }}
|
134
134
|
})
|
135
135
|
end
|
136
136
|
|
137
137
|
it "supports ruby native numeric ranges" do
|
138
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
138
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28and+bottles%3A1..99+on%3A%27wall%27%29&size=10")
|
139
139
|
@asari.search(filter: { and: { bottles: (1..99), on: "wall"} })
|
140
140
|
end
|
141
141
|
|
142
142
|
it "it supports numeric ranges where the lower bound is open-ended" do
|
143
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
143
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28and+bottles%3A..99+on%3A%27wall%27%29&size=10")
|
144
144
|
@asari.search(filter: { and: { bottles: '..99', on: "wall"} })
|
145
145
|
end
|
146
146
|
|
147
147
|
it "it supports numeric ranges where the upper bound is open-ended" do
|
148
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
148
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28and+bottles%3A1..+on%3A%27wall%27%29&size=10")
|
149
149
|
@asari.search(filter: { and: { bottles: '1..', on: "wall"} })
|
150
150
|
end
|
151
151
|
|
152
152
|
it "fails gracefully with empty params" do
|
153
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
153
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28or+is_donut%3A%27true%27%29&size=10")
|
154
154
|
@asari.search(filter: { or: { is_donut: true, and:
|
155
155
|
{ round: "", frosting: nil, fried: nil }}
|
156
156
|
})
|
157
157
|
end
|
158
158
|
|
159
159
|
it "supports full text search and boolean searching" do
|
160
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=nom&bq
|
160
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=nom&bq=+%28or+is_donut%3A%27true%27+%28and+fried%3A%27true%27%29%29&size=10")
|
161
161
|
@asari.search("nom", filter: { or: { is_donut: true, and:
|
162
162
|
{ round: "", frosting: nil, fried: true }}
|
163
163
|
})
|
@@ -166,7 +166,7 @@ describe Asari do
|
|
166
166
|
|
167
167
|
describe "geography searching" do
|
168
168
|
it "builds a proper query string" do
|
169
|
-
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq
|
169
|
+
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=+%28and+lat%3A2505771415..2506771417+lng%3A2358260777..2359261578%29&size=10")
|
170
170
|
@asari.search filter: { and: Asari::Geography.coordinate_box(meters: 5000, lat: 45.52, lng: 122.6819) }
|
171
171
|
end
|
172
172
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|