baidu_api-lbs_cloud 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/baidu_api/lbs_cloud/v3/request_base.rb +5 -3
- data/lib/baidu_api/lbs_cloud/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: 54caf66826309bb946e385341c3c3924b4de4125
|
4
|
+
data.tar.gz: e681c298482532976884f05cc76381be25872092
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d13482e27a461b1d404ec15fea4a9d52ecfcfaa3a14de68b0231274a4c12a0ec5ec0620df718280c38b10caac148317b56d4dc0e3536b7328350b55a0cf4a44d
|
7
|
+
data.tar.gz: b30aca6ff4ebd5ffaa40a68b123446ab3c29a33c799f04cbf48c03ee7d4a0f3599a816a6cfc97abd4542de1be3c1c73e7a639258ac41b574b73e4a90188513c7
|
data/README.md
CHANGED
@@ -28,6 +28,9 @@ require 'baidu_api/lbs_cloud'
|
|
28
28
|
# :sk is unnecessary if you are not authenticating with SN
|
29
29
|
BaiduApi::LbsCloud::V3::Geodata.setup ak: 'xxxx', sk: 'xxxxx'
|
30
30
|
|
31
|
+
# Also :ak and :sk can be Proc if you want load them dynamically
|
32
|
+
BaiduApi::LbsCloud::V3::Geodata.setup ak: ->{ Settings.current.ak } , sk: -> { Settings.current.sk }
|
33
|
+
|
31
34
|
# get geodata singleton instance
|
32
35
|
geodata = BaiduApi::LbsCloud::V3::Geodata.instance
|
33
36
|
|
@@ -65,12 +65,14 @@ module BaiduApi::LbsCloud::V3::RequestBase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def build_query(uri, data)
|
68
|
-
|
68
|
+
ak_str = ak.is_a?(Proc) ? ak.call : ak
|
69
|
+
sk_str = sk.is_a?(Proc) ? sk.call : sk
|
70
|
+
data = data.merge(ak: ak_str)
|
69
71
|
query_str = data.sort.map do |key, value|
|
70
72
|
"#{key}=#{URI.encode(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"
|
71
73
|
end.join('&')
|
72
|
-
return query_str if
|
73
|
-
sn = Digest::MD5.hexdigest(ERB::Util.url_encode("#{uri}?#{query_str}#{
|
74
|
+
return query_str if sk_str.nil?
|
75
|
+
sn = Digest::MD5.hexdigest(ERB::Util.url_encode("#{uri}?#{query_str}#{sk_str}"))
|
74
76
|
"#{query_str}&sn=#{sn}"
|
75
77
|
end
|
76
78
|
end
|
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.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiaohui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|