baidu_api-lbs_cloud 0.0.1 → 0.0.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: 8cec0b5d2b430e1dfdebaf823c82bb2ebc5e2388
4
- data.tar.gz: c756debe95e16ef4913ad7db57a2d7451319fba1
3
+ metadata.gz: edec3c2e38a4c941c7d6574ede3bbb68ad33020a
4
+ data.tar.gz: a86eae6df13051b957171a72120adf67b93c070d
5
5
  SHA512:
6
- metadata.gz: d3d3ec46c5a042eec9f07bd8030e0132c8908151e8ee23674f10ed6373b35174913ce212b72804a0a4f41692bc8d9d03fba5ddac104e25367e6588b564dff8e9
7
- data.tar.gz: 6bbf3411fa073750e6a25dc28c73bbc7b6aee7f7825643143f6e19b85f61af84207bd39bb1b21c59d03a4287c3bdcdf976f091dc7300e272c290a31eac33c678
6
+ metadata.gz: 21589efba8f43762bb4152180af469dcaa81babe186f48887277f0ed94b698eaa72278513e1a0e3d11630016304e5cc1b617eea268e004d636ba456177af48c0
7
+ data.tar.gz: e6bfcfb376587627aff5f8927c511522e5bcc1dc9ced5327eaf7db4ac52b7a5e2034636251aeb9e9c712ab0f38ee0900d975a3ca64396a611ef5ee00dd0bf785
data/README.md CHANGED
@@ -44,6 +44,10 @@ geodata.geotable.list()
44
44
  geodata.geotable.create(name: 'mytest', geotype: 3, is_published: 0)
45
45
  => {"status"=>0, "id"=>90288, "message"=>"成功"}
46
46
 
47
+ # rails error if status is non-zero
48
+ geodata.geotable.create!(name: 'mytest')
49
+ BaiduApi::LbsCloud::Exceptions::Failed: geotype:参数必需
50
+
47
51
  # Call Geosearch APIs
48
52
 
49
53
  BaiduApi::LbsCloud::V3::Geosearch.setup ak: 'xxx', sk: 'xxx'
@@ -0,0 +1,9 @@
1
+ module BaiduApi::LbsCloud::Exceptions
2
+ class Failed < StandardError
3
+ attr_reader :raw
4
+ def initialize(raw)
5
+ @raw = raw
6
+ super(raw['message'])
7
+ end
8
+ end
9
+ end
@@ -5,6 +5,8 @@ module BaiduApi::LbsCloud::V3::Geodata
5
5
  self.module_name = 'geodata'
6
6
  self.controller = 'column'
7
7
 
8
+ add_raise_methods :create, :list, :detail, :update, :delete
9
+
8
10
  def create(data)
9
11
  request('create', data, :post)
10
12
  end
@@ -5,6 +5,8 @@ module BaiduApi::LbsCloud::V3::Geodata
5
5
  self.module_name = 'geodata'
6
6
  self.controller = 'geotable'
7
7
 
8
+ add_raise_methods :create, :list, :detail, :update, :delete
9
+
8
10
  def create(data)
9
11
  request('create', data, :post)
10
12
  end
@@ -5,6 +5,8 @@ module BaiduApi::LbsCloud::V3::Geodata
5
5
  self.module_name = 'geodata'
6
6
  self.controller = 'job'
7
7
 
8
+ add_raise_methods :listimportdata, :list, :detail
9
+
8
10
  def listimportdata(data)
9
11
  request('listimportdata', data, :post)
10
12
  end
@@ -5,6 +5,8 @@ module BaiduApi::LbsCloud::V3::Geodata
5
5
  self.module_name = 'geodata'
6
6
  self.controller = 'poi'
7
7
 
8
+ add_raise_methods :create, :list, :detail, :update, :delete
9
+
8
10
  def create(data)
9
11
  request('create', data, :post)
10
12
  end
@@ -28,6 +28,18 @@ module BaiduApi::LbsCloud::V3::RequestBase
28
28
  @controller
29
29
  end
30
30
 
31
+ def add_raise_methods(*methods)
32
+ methods.flatten.each do |m|
33
+ class_eval <<-CODE
34
+ def #{m}!(*args)
35
+ ret = #{m}(*args)
36
+ raise BaiduApi::LbsCloud::Exceptions::Failed.new(ret) if ret['status'] != 0
37
+ ret
38
+ end
39
+ CODE
40
+ end
41
+ end
42
+
31
43
  end
32
44
 
33
45
  attr_accessor :ak, :sk
@@ -1,5 +1,5 @@
1
1
  module BaiduApi
2
2
  module LbsCloud
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -4,4 +4,5 @@ module BaiduApi
4
4
  end
5
5
 
6
6
  require "baidu_api/lbs_cloud/version"
7
+ require 'baidu_api/lbs_cloud/exceptions/failed'
7
8
  require "baidu_api/lbs_cloud/v3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu_api-lbs_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - xiaohui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,7 @@ files:
66
66
  - Rakefile
67
67
  - baidu_api-lbs_cloud.gemspec
68
68
  - lib/baidu_api/lbs_cloud.rb
69
+ - lib/baidu_api/lbs_cloud/exceptions/failed.rb
69
70
  - lib/baidu_api/lbs_cloud/v3.rb
70
71
  - lib/baidu_api/lbs_cloud/v3/geodata.rb
71
72
  - lib/baidu_api/lbs_cloud/v3/geodata/column.rb