googlestaticmap 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.1.3 / 2012-07-08
2
+ * Fixed a Ruby 1.9.3 compatibility issue (thanks dusanb!)
3
+ * Fixed a Ruby 1.8.7 compatibility issue introduced in 1.1.1
4
+
1
5
  === 1.1.2 / 2012-04-27
2
6
  * Fixed bug from 1.1.1 when specifying https when calling get_map (thanks aduncan for catching it!)
3
7
 
@@ -57,6 +57,7 @@
57
57
 
58
58
  require 'cgi'
59
59
  require 'net/http'
60
+ require 'net/https' if RUBY_VERSION < "1.9"
60
61
  require File.dirname(__FILE__) + '/googlestaticmap_helper'
61
62
 
62
63
  # Main class for creating a static map. Create an instance, Set attributes
@@ -172,12 +173,12 @@ class GoogleStaticMap
172
173
  http = Net::HTTP.Proxy(@proxy_address,@proxy_port).new("maps.google.com", port)
173
174
  http.use_ssl = protocol == 'https'
174
175
 
175
- resp, data = http.get2(relative_url(protocol))
176
+ resp = http.get2(relative_url(protocol))
176
177
  if resp && resp.is_a?(Net::HTTPSuccess)
177
178
  if output_file
178
- File.open(output_file, "wb") {|f| f << data }
179
+ File.open(output_file, "wb") {|f| f << resp.body }
179
180
  end
180
- data
181
+ resp.body
181
182
  else
182
183
  if resp
183
184
  raise Exception.new("Error encountered while retrieving google map, code #{resp.code}, text #{resp.body}")
@@ -6,8 +6,13 @@ require 'mocha'
6
6
  require File.dirname(__FILE__) + '/../lib/googlestaticmap'
7
7
 
8
8
  class MockSuccess < Net::HTTPSuccess #:nodoc: all
9
- def initialize
9
+ def initialize(data)
10
+ @data = data
10
11
  end
12
+
13
+ def body
14
+ @data
15
+ end
11
16
  end
12
17
 
13
18
  class MockFailure < Net::HTTPServiceUnavailable #:nodoc: all
@@ -95,7 +100,7 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
95
100
 
96
101
  def test_get_map_success_no_file_http
97
102
  test_data = "asdf"
98
- MockHttp.any_instance.expects(:get2).returns([MockSuccess.new,test_data])
103
+ MockHttp.any_instance.expects(:get2).returns(MockSuccess.new(test_data))
99
104
  MockHttp.any_instance.expects(:"use_ssl=").with(false).returns(false)
100
105
  Net::HTTP.expects(:new).returns(MockHttp.new)
101
106
 
@@ -107,7 +112,7 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
107
112
 
108
113
  def test_get_map_success_no_file_https
109
114
  test_data = "asdf"
110
- MockHttp.any_instance.expects(:get2).returns([MockSuccess.new,test_data])
115
+ MockHttp.any_instance.expects(:get2).returns(MockSuccess.new(test_data))
111
116
  MockHttp.any_instance.expects(:"use_ssl=").with(true).returns(true)
112
117
  Net::HTTP.expects(:new).returns(MockHttp.new)
113
118
 
@@ -119,7 +124,7 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
119
124
 
120
125
  def test_get_map_success_write_file
121
126
  test_data = "asdf"
122
- MockHttp.any_instance.expects(:get2).returns([MockSuccess.new,test_data])
127
+ MockHttp.any_instance.expects(:get2).returns(MockSuccess.new(test_data))
123
128
  Net::HTTP.expects(:new).returns(MockHttp.new)
124
129
  file_data = ""
125
130
  file_name = "testdata.png"
@@ -137,7 +142,7 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
137
142
 
138
143
  def test_get_map_success_check_url
139
144
  test_data = "asdf"
140
- MockHttp.any_instance.expects(:get2).returns([MockSuccess.new,test_data])
145
+ MockHttp.any_instance.expects(:get2).returns(MockSuccess.new(test_data))
141
146
  Net::HTTP.expects(:new).returns(MockHttp.new)
142
147
  file_data = ""
143
148
  file_name = "testdata.png"
@@ -155,7 +160,7 @@ class GoogleStaticMapTest < Test::Unit::TestCase #:nodoc: all
155
160
 
156
161
 
157
162
  def test_get_map_failure
158
- MockHttp.any_instance.expects(:get2).returns([MockFailure.new,""])
163
+ MockHttp.any_instance.expects(:get2).returns(MockFailure.new)
159
164
  Net::HTTP.expects(:new).returns(MockHttp.new)
160
165
  g = default_map
161
166
  assert_raise Exception do
metadata CHANGED
@@ -1,67 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: googlestaticmap
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.3
4
5
  prerelease:
5
- version: 1.1.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Brent Sowers
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-04-27 00:00:00 Z
12
+ date: 2012-07-08 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
- description: Easily retrieve single PNG, GIF, or JPG map images from Google with your own custom markers and paths using the Static Maps API service with this gem. Simply set the attributes you want for your map and GoogleStaticMap will take care of getting the map for you, or giving your the URL to retrieve the map.
14
+ description: Easily retrieve single PNG, GIF, or JPG map images from Google with your
15
+ own custom markers and paths using the Static Maps API service with this gem. Simply
16
+ set the attributes you want for your map and GoogleStaticMap will take care of getting
17
+ the map for you, or giving your the URL to retrieve the map.
17
18
  email: brent@coordinatecommons.com
18
19
  executables: []
19
-
20
20
  extensions: []
21
-
22
- extra_rdoc_files:
21
+ extra_rdoc_files:
23
22
  - README
24
23
  - History.txt
25
- files:
24
+ files:
26
25
  - lib/googlestaticmap.rb
27
26
  - lib/googlestaticmap_helper.rb
28
27
  - test/tc_map_path_and_polygon.rb
29
- - test/tc_map_location.rb
30
28
  - test/tc_google_static_map.rb
31
29
  - test/tc_helper.rb
32
30
  - test/tc_map_marker.rb
31
+ - test/tc_map_location.rb
33
32
  - README
34
33
  - History.txt
35
34
  homepage: http://www.coordinatecommons.com/googlestaticmap/
36
35
  licenses: []
37
-
38
36
  post_install_message:
39
37
  rdoc_options: []
40
-
41
- require_paths:
38
+ require_paths:
42
39
  - lib
43
- required_ruby_version: !ruby/object:Gem::Requirement
40
+ required_ruby_version: !ruby/object:Gem::Requirement
44
41
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
49
- required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
47
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: "0"
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
55
52
  requirements: []
56
-
57
53
  rubyforge_project:
58
- rubygems_version: 1.8.7
54
+ rubygems_version: 1.8.24
59
55
  signing_key:
60
56
  specification_version: 3
61
57
  summary: Class for retrieving maps from the Google Maps Static API service
62
- test_files:
58
+ test_files:
63
59
  - test/tc_map_path_and_polygon.rb
64
- - test/tc_map_location.rb
65
60
  - test/tc_google_static_map.rb
66
61
  - test/tc_helper.rb
67
62
  - test/tc_map_marker.rb
63
+ - test/tc_map_location.rb