inquisitio 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +5 -1
- data/lib/inquisitio/search_url_builder.rb +13 -2
- data/lib/inquisitio/version.rb +1 -1
- data/test/search_url_builder_test.rb +10 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MDBmN2I1ZjMwMzEwZDk4MGQ4ZjZkZjEzNGY2ODZlYWEwNjBmYmY4NA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7fd33b4a7884125f5845e35aab4c28c9ce7e17d4
|
4
|
+
data.tar.gz: 8008f740c7dc2bbdc91cf9decde94df3c1bd73e8
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YzUxNmVhZGM5ODk5Yzk4MGVhNWZjODBlM2I4NDk4OGZkNGUwM2Q2ZTUwZDNi
|
11
|
-
YWE4M2JlNjRhMzhhMTEzMWZmMDljYWYwZGU1ZDY1YTVmY2M0MzE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NWVlYWQzYWJlNmM3MmI5NGM3ZGViNTNhODA3MmU4NTU0ZDlmYzUwMTYxMzE4
|
14
|
-
M2M4NGQ5ZDYxNWVjZTA5MzE5MDlhYmQ3ODVkYTM3M2EzZDNhN2Y2OWNkZjBh
|
15
|
-
Y2VmYjczNzhjMjg1YjBlMmVjMjhhMWU3OGU5ZDUwZTIzOTFjYzQ=
|
6
|
+
metadata.gz: 61bdc0964f9dbaffc6590de6b6013519ceba2cafe8cc36a52463db1f3e082a47d51e55b7234c5767880e4aa6516fb5ccd1e50eb3f6bbbbcb0fed74e77ca1d170
|
7
|
+
data.tar.gz: b933134ee24f80390eb6a76c98ebcf68a29061943da85a2b1bd4d54df330526416d13f6246a0295c7bf9e7eec81fb634951fdf6126e20acd2387b62cbad4fe27
|
data/CHANGELOG.md
CHANGED
@@ -27,9 +27,20 @@ module Inquisitio
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def boolean_query
|
30
|
-
filters = @filters.map
|
30
|
+
filters = @filters.map do |key,value|
|
31
|
+
key = key.to_s.gsub('\'','')
|
32
|
+
|
33
|
+
if value.is_a?(String)
|
34
|
+
"#{key}:'#{value.to_s.gsub('\'','')}'"
|
35
|
+
elsif value.is_a?(Array)
|
36
|
+
mapping = value.map {|v| "#{key}:'#{v.to_s.gsub('\'','')}'" }.join(" ")
|
37
|
+
"(or #{mapping})"
|
38
|
+
else
|
39
|
+
raise InquisitioError.new("Filter values must be strings or arrays.")
|
40
|
+
end
|
41
|
+
end
|
31
42
|
queries = filters.join(" ")
|
32
|
-
queries = "'#{@query.gsub('\'','')}' #{queries}" if @query
|
43
|
+
queries = "'#{@query.to_s.gsub('\'','')}' #{queries}" if @query
|
33
44
|
"bq=#{URI.encode("(and #{queries})")}"
|
34
45
|
end
|
35
46
|
|
data/lib/inquisitio/version.rb
CHANGED
@@ -63,5 +63,15 @@ module Inquisitio
|
|
63
63
|
assert_equal expected_url, url
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_create_search_url_with_filter_array
|
67
|
+
url = SearchUrlBuilder.build(query: 'Star Wars', filters: {genre: ['Animation', 'Action']})
|
68
|
+
expected_url = 'http://my.search-endpoint.com/2011-02-01/search?bq=(and%20\'Star%20Wars\'%20(or%20genre:\'Animation\'%20genre:\'Action\'))&size=10'
|
69
|
+
assert_equal expected_url, url
|
70
|
+
end
|
71
|
+
def test_throws_exception_when_using_unsupported_filter_value_type
|
72
|
+
assert_raises(InquisitioError) do
|
73
|
+
SearchUrlBuilder.build(query: 'Star Wars', filters: {genre: {}})
|
74
|
+
end
|
75
|
+
end
|
66
76
|
end
|
67
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inquisitio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
@@ -42,42 +42,42 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mocha
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -143,12 +143,12 @@ require_paths:
|
|
143
143
|
- lib
|
144
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
|
-
- -
|
146
|
+
- - '>='
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- -
|
151
|
+
- - '>='
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|