googlestaticmap 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/README.md +5 -1
- data/lib/googlestaticmap.rb +18 -7
- data/test/tc_google_static_map.rb +23 -6
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad36a4237b16d0a78f5275fef2732de1fa38c8d3
|
4
|
+
data.tar.gz: 76f929f6ea26f88b05628e85fb5059baca039a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b21ce6e938e92acf3dff7bd4c481d7830aea9450eb143193356cec28964bde44e15d42295335399ca08039c00174897aacd09d0051aacb0720c4d479aaae6a98
|
7
|
+
data.tar.gz: 6b1304bf3165f499139823589681a35c67ef79e76a78411b7edf6551c4e3a54affa2d5e1995e9fba096588b5a36cddf4aad6491c91d4081a6dbb17048f0de0c2
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,10 @@ this URL as the src of an img element on an HTML page
|
|
27
27
|
map = GoogleStaticMap.new(:zoom => 11, :center => MapLocation.new(:address => "Washington, DC"))
|
28
28
|
image_url = map.url(:auto)
|
29
29
|
|
30
|
+
When using the url function you can force the final url to use http or https:
|
31
|
+
|
32
|
+
image_url = map.url('http')
|
33
|
+
|
30
34
|
Get a map with blue markers at the White House and the Supreme Court, zoomed
|
31
35
|
the closest that the map can be with both markers visible, at the default
|
32
36
|
size. image will be the binary data of the map
|
@@ -74,7 +78,7 @@ You can also specify a channel for better tracking if you are a Maps For Busines
|
|
74
78
|
|
75
79
|
## Compatibility
|
76
80
|
|
77
|
-
This has been tested and is working with Ruby 1.
|
81
|
+
This has been tested and is working with Ruby 1.9.3, 2.0.0, 2.1.1, 2.1.10, 2.2.6, 2.3.3, 2.4.0, and the latest JRuby.
|
78
82
|
|
79
83
|
## Author
|
80
84
|
|
data/lib/googlestaticmap.rb
CHANGED
@@ -64,14 +64,19 @@ class GoogleStaticMap
|
|
64
64
|
# If proxy_address is set, set this to the port of the proxy server
|
65
65
|
attr_accessor :proxy_port
|
66
66
|
|
67
|
-
# API Key - see https://developers.google.com/maps/documentation/
|
68
|
-
# Note that if this is set,
|
67
|
+
# API Key - see https://developers.google.com/maps/documentation/static-maps/get-api-key#key for details
|
68
|
+
# Note that if this is set, you cannot provide a client ID
|
69
69
|
attr_accessor :api_key
|
70
70
|
|
71
|
-
# ClientId
|
72
|
-
# see https://developers.google.com/maps/documentation/
|
73
|
-
#
|
71
|
+
# ClientId for business customers -
|
72
|
+
# see https://developers.google.com/maps/documentation/static-maps/get-api-key#key for details
|
73
|
+
# Note that if this is set, you cannot provide an API key.
|
74
74
|
attr_accessor :client_id
|
75
|
+
|
76
|
+
# The private key, also known as the URL signing secret, is used to to generate the signature parameter
|
77
|
+
# in the URL. This is required if you are using a client ID, or a premium API key, and is optional
|
78
|
+
# if you are using a standard API key. See
|
79
|
+
# https://developers.google.com/maps/documentation/static-maps/get-api-key for more details
|
75
80
|
attr_accessor :private_key
|
76
81
|
|
77
82
|
# Channel - identifier channel for tracking API source in enterprise tools
|
@@ -100,6 +105,12 @@ class GoogleStaticMap
|
|
100
105
|
unless @center || @markers.length > 0 || @paths.length > 0
|
101
106
|
raise Exception.new("Need to specify either a center, markers, or a path")
|
102
107
|
end
|
108
|
+
if !@api_key.nil? && !@client_id.nil?
|
109
|
+
rasise Exception.new("You cannot specify both an API key and a client ID, only specify one")
|
110
|
+
end
|
111
|
+
if !@client_id.nil? && @private_key.nil?
|
112
|
+
raise Exception.new("private_key must be specified if using a client ID")
|
113
|
+
end
|
103
114
|
protocol = 'http' unless protocol == 'http' || protocol == 'https' ||
|
104
115
|
protocol == :auto
|
105
116
|
protocol = protocol == :auto ? '' : protocol + ":"
|
@@ -115,9 +126,9 @@ class GoogleStaticMap
|
|
115
126
|
@paths.each {|p| attrs << ["path",p.to_s] }
|
116
127
|
attrs << ["center", @center.to_s] if !@center.nil?
|
117
128
|
attrs << ["key", @api_key] if !@api_key.nil?
|
118
|
-
attrs << ["client", @client_id] if
|
129
|
+
attrs << ["client", @client_id] if !@client_id.nil?
|
119
130
|
path << attrs.sort_by {|k,v| k}.collect {|attr| "#{attr[0]}=#{attr[1]}"}.join("&")
|
120
|
-
if
|
131
|
+
if (!@api_key.nil? || !@client_id.nil?) && !@private_key.nil?
|
121
132
|
signature = GoogleStaticMapHelpers.sign(path, @private_key)
|
122
133
|
path << "&signature=" << signature
|
123
134
|
end
|
@@ -119,6 +119,18 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
|
|
119
119
|
assert !u.include?("signature"), u
|
120
120
|
end
|
121
121
|
|
122
|
+
def test_url_api_key_with_private_key
|
123
|
+
g = default_map
|
124
|
+
g.api_key = "asdfapikey"
|
125
|
+
g.private_key = "vNIXE0xscrmjlyV-12Nj_BvUPaw="
|
126
|
+
u = nil
|
127
|
+
assert_nothing_raised { u = g.url }
|
128
|
+
assert_equal 9, u.split("&").length, u
|
129
|
+
assert u.include?("key=asdfapikey"), u
|
130
|
+
assert !u.include?("client"), u
|
131
|
+
assert u.include?("signature="), u
|
132
|
+
end
|
133
|
+
|
122
134
|
def test_url_for_business
|
123
135
|
g = default_map
|
124
136
|
g.client_id = "asdfclientid"
|
@@ -131,15 +143,20 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
|
|
131
143
|
assert !u.include?("key="), u
|
132
144
|
end
|
133
145
|
|
134
|
-
def
|
146
|
+
def test_url_for_business_no_private_key
|
135
147
|
g = default_map
|
136
148
|
g.client_id = "asdfclientid"
|
137
149
|
u = nil
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
150
|
+
assert_raise { u = g.url }
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_url_for_business_with_api_key
|
154
|
+
g = default_map
|
155
|
+
g.client_id = "asdfclientid"
|
156
|
+
g.private_key = "vNIXE0xscrmjlyV-12Nj_BvUPaw="
|
157
|
+
g.api_key = "asdfapikey"
|
158
|
+
u = nil
|
159
|
+
assert_raise { u = g.url }
|
143
160
|
end
|
144
161
|
|
145
162
|
def test_get_map_success_no_file_http
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: googlestaticmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Sowers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.3
|
41
55
|
description: Easily retrieve single PNG, GIF, or JPG map images from Google with your
|
42
56
|
own custom markers and paths using the Static Maps API service with this gem. Simply
|
43
57
|
set the attributes you want for your map and GoogleStaticMap will take care of getting
|
@@ -78,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
92
|
version: '0'
|
79
93
|
requirements: []
|
80
94
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.4.8
|
82
96
|
signing_key:
|
83
97
|
specification_version: 4
|
84
98
|
summary: Class for retrieving maps from the Google Maps Static API service
|