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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c9fac63dd0806281c216b33b8b63c106c66fcd5
4
- data.tar.gz: 17dff8f7b3bd8bed62094bae3a86ffe0b1f68786
3
+ metadata.gz: 987a546d85fb415adbda2a2657a8efd959a5d364
4
+ data.tar.gz: 9bd9acfab7148c58c0768886ceaf02f2f1067275
5
5
  SHA512:
6
- metadata.gz: 4500d87ee774b264ed96dcb72c3cee2427d473ec335ac56ee08e22345c7dcf5561e6b8b7fb21e961f2efd28ea7a7eb4b795195e41bf0f19f2ddc3f10f276424a
7
- data.tar.gz: 739c50d5c3862a62eb6679adbc3e63ef6cb2e48e2fca305ed1cb7f1aec6b15eaa0ead2ecb23d500c1f0234ed58a4be65568b1ce2bf44424abebc897d44b66cbf
6
+ metadata.gz: 45eab55a1d9b586edd917f5f7db7c330c37df3842975a43f4bf1948996155c1e033bb14d00e833657cede23181b43cd4d8344e433c112da7d59c92b2f6a8aeee
7
+ data.tar.gz: 3cef1d1b356f364dd1d7aedb9bc3c3ccd3595b732ab6ba46eb24d2276f649b33b3b47a6dad66eb3f33b38ff68f6d904e65a307e45f1dd83fb6ddc612057b06fe
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  !/log/.keep
13
13
  /spec/cassettes/*
14
14
  .env
15
+ *.gem
@@ -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
- validate_response(resp)
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 validate_response(resp)
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?
@@ -1,3 +1,3 @@
1
1
  class AlgoliaPlaces
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-15 00:00:00.000000000 Z
11
+ date: 2017-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler