baidu_api-lbs_cloud 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edec3c2e38a4c941c7d6574ede3bbb68ad33020a
4
- data.tar.gz: a86eae6df13051b957171a72120adf67b93c070d
3
+ metadata.gz: 54caf66826309bb946e385341c3c3924b4de4125
4
+ data.tar.gz: e681c298482532976884f05cc76381be25872092
5
5
  SHA512:
6
- metadata.gz: 21589efba8f43762bb4152180af469dcaa81babe186f48887277f0ed94b698eaa72278513e1a0e3d11630016304e5cc1b617eea268e004d636ba456177af48c0
7
- data.tar.gz: e6bfcfb376587627aff5f8927c511522e5bcc1dc9ced5327eaf7db4ac52b7a5e2034636251aeb9e9c712ab0f38ee0900d975a3ca64396a611ef5ee00dd0bf785
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
- data = data.merge(ak: ak)
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 sk.nil?
73
- sn = Digest::MD5.hexdigest(ERB::Util.url_encode("#{uri}?#{query_str}#{sk}"))
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
@@ -1,5 +1,5 @@
1
1
  module BaiduApi
2
2
  module LbsCloud
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  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.2
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-01-16 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler