gmapper 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ To create a map of a location, say the Googleplex:
18
18
 
19
19
  Then, lets say we want to add a marker to point out where it is:
20
20
 
21
- map << Google::Maps::Static::Marker.new([37.422, 122.084], :color => :blue, :label => 'G')
21
+ map << Google::Maps::Static::Markers.new([37.422, 122.084], :color => :blue, :label => 'G')
22
22
 
23
23
  To save the map to your local disk:
24
24
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/rdoctask'
4
4
  require 'echoe'
5
5
  require 'spec/rake/spectask'
6
6
 
7
- Echoe.new( 'gmapper', '0.2.0' ) do |p|
7
+ Echoe.new( 'gmapper', '0.2.1' ) do |p|
8
8
  p.author = "TJ Peden"
9
9
  p.email = "tj.peden@tj-coding.com"
10
10
  p.summary = "A version agnostic, dependency free Ruby library for the Google Maps API."
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gmapper}
5
- s.version = "0.2.0"
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Peden"]
9
- s.date = %q{2010-09-02}
9
+ s.date = %q{2010-09-22}
10
10
  s.description = %q{A (mostly) version agnostic, dependency free Ruby library for the Google Maps API.
11
11
 
12
12
  Currently only supports Google Static Maps.
@@ -1,3 +1,5 @@
1
+ # All map items have the same format
2
+
1
3
  module Google
2
4
 
3
5
  module Maps
@@ -5,6 +5,8 @@ module Google
5
5
  module Static
6
6
 
7
7
  class Map
8
+ attr_accessor :timeout
9
+
8
10
  def initialize *args
9
11
  @base = "http://maps.google.com/maps/api/staticmap"
10
12
 
@@ -31,8 +33,12 @@ module Google
31
33
  alias_method :add_item, :<<
32
34
 
33
35
  def save file
34
- response = ::Net::HTTP.get( ::URI.parse( url._encode ) )
35
- File.open( file, 'wb' ) { |f| f.write response }
36
+ uri = ::URI.parse( url._encode )
37
+ http = ::Net::HTTP.new( uri.host, uri.port )
38
+ http.read_timeout = @timeout if @timeout
39
+
40
+ response = http.get( "#{uri.path}?#{uri.query}" )
41
+ File.open( file, 'wb' ) { |f| f.write response.body }
36
42
  end
37
43
 
38
44
  def url
@@ -48,7 +54,7 @@ module Google
48
54
  url = "#{@base}?#{parameters}"
49
55
 
50
56
  def url._encode
51
- gsub(/\|/, '%7C')
57
+ gsub(/\|/) { |match| '%' + match.unpack('H2').join.upcase }
52
58
  end
53
59
 
54
60
  @url = url
@@ -74,9 +80,9 @@ module Google
74
80
 
75
81
  result += '&' + @items.join('&') unless @items.empty?
76
82
 
77
- result.gsub!(/\s/, '+')
83
+ result.gsub!(' ', '+')
78
84
 
79
- result
85
+ result.split(/&(?=[a-z]+=)/).map { |param| param.gsub('&', '%26') }.join('&')
80
86
  end
81
87
  end # => Google::Maps::Static::Map
82
88
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - TJ Peden
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-02 00:00:00 -04:00
17
+ date: 2010-09-22 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20