googlestaticmap 1.2.3 → 1.2.4
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/lib/googlestaticmap.rb +6 -4
- data/lib/googlestaticmap_helper.rb +4 -2
- data/test/tc_google_static_map.rb +9 -0
- data/test/tc_helper.rb +7 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5927d0355fe8b5d37805cdd00be4c0101d160d43
|
4
|
+
data.tar.gz: 7678c34e611f1515334a2fc686e8509b6fa50120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cea618d5b2937fe8f500c7dd88ce5814c93d10b7362cfc73999215876131f3eb959ec3e82ea863a63a86dce61fa925e9b7ea1599828d869c1502f8ae715ad86
|
7
|
+
data.tar.gz: 23564bec56865aedd2acbc028341389270571140054d1aea0dcf9f8966835f55bad4a81b0728fd41323e424d3b1af8f83075588557897ff290c0210612a93a52
|
data/History.txt
CHANGED
data/lib/googlestaticmap.rb
CHANGED
@@ -75,7 +75,7 @@ class GoogleStaticMap
|
|
75
75
|
|
76
76
|
# The private key, also known as the URL signing secret, is used to to generate the signature parameter
|
77
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
|
78
|
+
# if you are using a standard API key. See
|
79
79
|
# https://developers.google.com/maps/documentation/static-maps/get-api-key for more details
|
80
80
|
attr_accessor :private_key
|
81
81
|
|
@@ -83,12 +83,16 @@ class GoogleStaticMap
|
|
83
83
|
# see https://developers.google.com/maps/documentation/business/clientside/quota for details
|
84
84
|
attr_accessor :channel
|
85
85
|
|
86
|
+
# Language - :en, :ja
|
87
|
+
# see https://developers.google.com/maps/documentation/static-maps/intro for details
|
88
|
+
attr_accessor :language
|
89
|
+
|
86
90
|
# Takes an optional hash of attributes
|
87
91
|
def initialize(attrs={})
|
88
92
|
defaults = {:width => 500, :height => 350, :markers => [],
|
89
93
|
:sensor => false, :maptype => "roadmap", :paths => [],
|
90
94
|
:proxy_port => nil, :proxy_address => nil, :api_key => nil,
|
91
|
-
:client_id => nil, :private_key => nil}
|
95
|
+
:client_id => nil, :private_key => nil, :language => nil}
|
92
96
|
|
93
97
|
attributes = defaults.merge(attrs)
|
94
98
|
attributes.each {|k,v| self.send("#{k}=".to_sym,v)}
|
@@ -291,5 +295,3 @@ class MapPolygon < MapPath
|
|
291
295
|
attrs.each {|k,v| self.send("#{k}=".to_sym,v)}
|
292
296
|
end
|
293
297
|
end
|
294
|
-
|
295
|
-
|
@@ -21,8 +21,10 @@ module GoogleStaticMapHelpers #:nodoc: all
|
|
21
21
|
iv_name = i.to_s[1..-1]
|
22
22
|
unless ivs_to_exclude.include?(iv_name)
|
23
23
|
val = object.instance_variable_get(i)
|
24
|
-
|
25
|
-
|
24
|
+
unless val.nil?
|
25
|
+
val = CGI.escape(val.to_s) if options.has_key?(:cgi_escape_values)
|
26
|
+
ivs[iv_name] = val unless val.nil?
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
ivs
|
@@ -97,6 +97,15 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
|
|
97
97
|
assert_no_match /^\/\/maps.googleapis.com/, f
|
98
98
|
end
|
99
99
|
|
100
|
+
# Language is the only nullable one that goes through the normal safe instance
|
101
|
+
# variable pattern
|
102
|
+
def test_url_with_langauge
|
103
|
+
g = default_map
|
104
|
+
g.language = "jp"
|
105
|
+
assert g.url.include?("language=jp")
|
106
|
+
end
|
107
|
+
|
108
|
+
|
100
109
|
def test_url_https
|
101
110
|
g = default_map
|
102
111
|
u = nil
|
data/test/tc_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../lib/googlestaticmap_helper'
|
|
5
5
|
class GoogleStaticMapHelperTest < Test::Unit::TestCase #:nodoc: all
|
6
6
|
|
7
7
|
IVS = {"@var1" => 1, "@var2" => 2, "@var3" => 3,
|
8
|
-
"@url" => "http://maps.google.com"}
|
8
|
+
"@url" => "http://maps.google.com", "@nilvar" => nil}
|
9
9
|
|
10
10
|
class MockRuby18Object
|
11
11
|
def self.instance_variables
|
@@ -30,14 +30,16 @@ class GoogleStaticMapHelperTest < Test::Unit::TestCase #:nodoc: all
|
|
30
30
|
|
31
31
|
def test_safe_instance_variables_no_params
|
32
32
|
[MockRuby18Object, MockRuby19Object].each do |o|
|
33
|
-
|
33
|
+
sivs = GoogleStaticMapHelpers.safe_instance_variables(o)
|
34
|
+
assert_equal ivs_no_at, sivs
|
35
|
+
assert !sivs.has_key?("@nilvar")
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
39
|
def test_safe_instance_variables_exclude
|
38
40
|
[MockRuby18Object, MockRuby19Object].each do |o|
|
39
41
|
sivs = GoogleStaticMapHelpers.safe_instance_variables(o, ["var2"])
|
40
|
-
assert_equal IVS.length-
|
42
|
+
assert_equal IVS.length-2, sivs.length
|
41
43
|
assert !sivs.has_key?("@var2")
|
42
44
|
end
|
43
45
|
end
|
@@ -45,7 +47,7 @@ class GoogleStaticMapHelperTest < Test::Unit::TestCase #:nodoc: all
|
|
45
47
|
def test_safe_instance_variables_cgi
|
46
48
|
[MockRuby18Object, MockRuby19Object].each do |o|
|
47
49
|
sivs = GoogleStaticMapHelpers.safe_instance_variables(o, [], :cgi_escape_values => true)
|
48
|
-
assert_equal IVS.length, sivs.length
|
50
|
+
assert_equal IVS.length-1, sivs.length
|
49
51
|
assert_equal CGI.escape(IVS["@url"]), sivs["url"]
|
50
52
|
end
|
51
53
|
end
|
@@ -63,7 +65,7 @@ class GoogleStaticMapHelperTest < Test::Unit::TestCase #:nodoc: all
|
|
63
65
|
def ivs_no_at
|
64
66
|
ivs = {}
|
65
67
|
IVS.each do |k,v|
|
66
|
-
ivs[k[1..-1]] = v
|
68
|
+
ivs[k[1..-1]] = v unless v.nil?
|
67
69
|
end
|
68
70
|
ivs
|
69
71
|
end
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Sowers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -92,13 +92,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.5.2
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Class for retrieving maps from the Google Maps Static API service
|
99
99
|
test_files:
|
100
100
|
- test/tc_map_path_and_polygon.rb
|
101
|
-
- test/tc_map_location.rb
|
102
|
-
- test/tc_google_static_map.rb
|
103
101
|
- test/tc_helper.rb
|
102
|
+
- test/tc_google_static_map.rb
|
103
|
+
- test/tc_map_location.rb
|
104
104
|
- test/tc_map_marker.rb
|