inquisitio 0.0.13 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/inquisitio/searcher.rb +3 -3
- data/lib/inquisitio/version.rb +1 -1
- data/test/searcher_test.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0153850b7330c032d7d3bdde601026aa999e4572
|
4
|
+
data.tar.gz: 7911234db6c6b7bf878a3b81b124cf07838a042c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b9e466ee1921dee60271bcacad62a9ca0f9456c21e94569d1700daeede197bedeeaf236662f1ed9c614e72a9e0ae038253352ffb87d178fadcee9349259a57
|
7
|
+
data.tar.gz: 984fc2e46cd3c754ab4846b1e8af8bd2190dcb5cad0c560bed257d786476585615ce376bb6029592379ffa8c478882e306716d5255d9f56df07f531ef809c9cb
|
data/CHANGELOG.md
CHANGED
data/lib/inquisitio/searcher.rb
CHANGED
@@ -27,16 +27,16 @@ module Inquisitio
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def ids
|
30
|
-
@ids ||= map{|r|r['med_id']}
|
30
|
+
@ids ||= map{|r|r['data']['med_id'].first}.flatten.map(&:to_i)
|
31
31
|
end
|
32
32
|
|
33
33
|
def records
|
34
34
|
@records ||= begin
|
35
35
|
klasses = {}
|
36
36
|
map do |result|
|
37
|
-
klass = result['med_type']
|
37
|
+
klass = result['data']['med_type'].first
|
38
38
|
klasses[klass] ||= []
|
39
|
-
klasses[klass] << result['med_id']
|
39
|
+
klasses[klass] << result['data']['med_id'].first
|
40
40
|
end
|
41
41
|
|
42
42
|
klasses.map {|klass, ids|
|
data/lib/inquisitio/version.rb
CHANGED
data/test/searcher_test.rb
CHANGED
@@ -6,9 +6,9 @@ module Inquisitio
|
|
6
6
|
super
|
7
7
|
@search_endpoint = 'http://my.search-endpoint.com'
|
8
8
|
Inquisitio.config.search_endpoint = @search_endpoint
|
9
|
-
@result_1 = {'med_id' => 1, 'title' => "Foobar", 'med_type' => "Cat"}
|
10
|
-
@result_2 = {'med_id' => 2, 'title' => "Foobar", 'med_type' => "Cat"}
|
11
|
-
@result_3 = {'med_id' => 20, 'title' => "Foobar2", 'med_type' => "Module_Dog"}
|
9
|
+
@result_1 = {'data' => {'med_id' => ['1'], 'title' => ["Foobar"], 'med_type' => ["Cat"]}}
|
10
|
+
@result_2 = {'data' => {'med_id' => ['2'], 'title' => ["Foobar"], 'med_type' => ["Cat"]}}
|
11
|
+
@result_3 = {'data' => {'med_id' => ['20'], 'title' => ["Foobar2"], 'med_type' => ["Module_Dog"]}}
|
12
12
|
@expected_results = [@result_1, @result_2, @result_3]
|
13
13
|
|
14
14
|
@body = <<-EOS
|
@@ -256,10 +256,10 @@ module Inquisitio
|
|
256
256
|
|
257
257
|
def test_should_return_ids
|
258
258
|
searcher = Searcher.where('Star Wars')
|
259
|
-
assert_equal
|
259
|
+
assert_equal [1,2,20], searcher.ids
|
260
260
|
end
|
261
261
|
|
262
|
-
def
|
262
|
+
def test_should_return_records
|
263
263
|
Object.const_set :Cat, Object.new
|
264
264
|
Module.const_set :Dog, Object.new
|
265
265
|
|
@@ -267,8 +267,8 @@ module Inquisitio
|
|
267
267
|
res2 = 123
|
268
268
|
res3 = true
|
269
269
|
|
270
|
-
Cat.expects(:where).with(id: [1,2]).returns([res1, res2])
|
271
|
-
Module::Dog.expects(:where).with(id: [20]).returns([res3])
|
270
|
+
Cat.expects(:where).with(id: ['1','2']).returns([res1, res2])
|
271
|
+
Module::Dog.expects(:where).with(id: ['20']).returns([res3])
|
272
272
|
|
273
273
|
searcher = Searcher.new
|
274
274
|
searcher.instance_variable_set("@results", [])
|