algolia_places 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/algolia_places.rb +23 -2
- data/lib/algolia_places/version.rb +1 -1
- 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: 987a546d85fb415adbda2a2657a8efd959a5d364
|
4
|
+
data.tar.gz: 9bd9acfab7148c58c0768886ceaf02f2f1067275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45eab55a1d9b586edd917f5f7db7c330c37df3842975a43f4bf1948996155c1e033bb14d00e833657cede23181b43cd4d8344e433c112da7d59c92b2f6a8aeee
|
7
|
+
data.tar.gz: 3cef1d1b356f364dd1d7aedb9bc3c3ccd3595b732ab6ba46eb24d2276f649b33b3b47a6dad66eb3f33b38ff68f6d904e65a307e45f1dd83fb6ddc612057b06fe
|
data/.gitignore
CHANGED
data/lib/algolia_places.rb
CHANGED
@@ -13,6 +13,7 @@ class AlgoliaPlaces
|
|
13
13
|
class << self
|
14
14
|
extend Forwardable
|
15
15
|
def_delegators :instance, :coordinates, :coordinates
|
16
|
+
def_delegators :instance, :hits, :hits
|
16
17
|
def_delegators :instance, :configuration, :configuration
|
17
18
|
|
18
19
|
def root
|
@@ -43,7 +44,7 @@ class AlgoliaPlaces
|
|
43
44
|
def coordinates(query)
|
44
45
|
begin
|
45
46
|
resp = retrieve_query(query)
|
46
|
-
|
47
|
+
coordinates_response(resp)
|
47
48
|
rescue RestClient::ExceptionWithResponse => err
|
48
49
|
if self.rest_exception?
|
49
50
|
raise err
|
@@ -53,8 +54,28 @@ class AlgoliaPlaces
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
57
|
+
|
58
|
+
def hits(query)
|
59
|
+
begin
|
60
|
+
resp = retrieve_query(query)
|
61
|
+
hits_response(resp)
|
62
|
+
rescue RestClient::ExceptionWithResponse => err
|
63
|
+
if self.rest_exception?
|
64
|
+
raise err
|
65
|
+
else
|
66
|
+
self.logger.fatal("#{err}\n#{err.backtrace.inspect}")
|
67
|
+
[]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
def hits_response(resp)
|
75
|
+
JsonPath.new('$.hits').on(resp.body).first
|
76
|
+
end
|
56
77
|
|
57
|
-
def
|
78
|
+
def coordinates_response(resp)
|
58
79
|
results = JsonPath.new('$.hits[0]._geoloc').on resp.body
|
59
80
|
geo_loc = results.first
|
60
81
|
if geo_loc.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia_places
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kopz9999
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|