baidu_api-geocoding 1.0.0 → 1.1.0

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: cb1da98293ff938d23b05e5f955b9afd97b51f2e
4
- data.tar.gz: c978f7368484d1fe9e709885b07de15cbe14ca2e
3
+ metadata.gz: 08ae480fdaec595e85d8b3b537f648d84266b754
4
+ data.tar.gz: 791ad1f0ded3d8bb64bcd6417baeb582d6333a3b
5
5
  SHA512:
6
- metadata.gz: 68a23b438ab3d47ddca8fc0089b222835603eebf31f0efc353c59e7819b9f45317a038d6705757ab37f7cbc3233ab7a8ae0ba575b36d2a7ee720d63dd9ca11cc
7
- data.tar.gz: 920eec7e77c27079ddc348ec16fa6686e6c77be9d652b97ee5a09cfabdb239218ccb2b12e06ec846d2872b67cc5a57da71dddf95618b126edc1b6057378eb991
6
+ metadata.gz: 919e3beaa89cca51685333699a8da3f2837b83cba53f5797087bca20491c671c944bc8970a0653e82b750b8e532b347e4a24f9aef67c831152d96fcf53da5066
7
+ data.tar.gz: 964d438cf85000bc187b82d2422a69a395e41cdf46970ca07e0148bd180d33dc25bb1f0c69ed632ce3d1d1b8aedf28aa0bbeffbbbbfdbb56f830507167b5987f
@@ -0,0 +1,9 @@
1
+ module BaiduApi::Geocoding::Exceptions
2
+ class Failed < StandardError
3
+ attr_reader :raw
4
+ def initialize(raw)
5
+ @raw = raw
6
+ super(raw['msg'])
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module BaiduApi
2
2
  module Geocoding
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'baidu_api/geocoding/version'
3
3
  require 'baidu_api/geocoding/configuration'
4
+ require 'baidu_api/geocoding/exceptions/failed'
4
5
  require 'baidu_api/geocoding/v2/geocoder'
5
6
 
6
7
  module BaiduApi
@@ -27,6 +28,12 @@ module BaiduApi
27
28
  geocoder.geocode(data)
28
29
  end
29
30
 
31
+ def geocode!(data = {})
32
+ ret = geocode(data)
33
+ raise BaiduApi::Geocoding::Exceptions::Failed, ret if ret['status'] != 0
34
+ ret
35
+ end
36
+
30
37
  def fetch_accepted_data(data)
31
38
  %w(ak sk version address city coordtype location pois).inject({}) do |ret, item|
32
39
  ret[item.intern] = fetch_data(data, item)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu_api-geocoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xiaohui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-28 00:00:00.000000000 Z
11
+ date: 2015-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,6 +53,7 @@ files:
53
53
  - baidu_api-geocoding.gemspec
54
54
  - lib/baidu_api/geocoding.rb
55
55
  - lib/baidu_api/geocoding/configuration.rb
56
+ - lib/baidu_api/geocoding/exceptions/failed.rb
56
57
  - lib/baidu_api/geocoding/v2/geocoder.rb
57
58
  - lib/baidu_api/geocoding/version.rb
58
59
  homepage: http://github.com/xiaohui-zhangxh/baidu_api-geocoding