gmaps_directions 0.2.0 → 0.2.1

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -4,6 +4,7 @@ require 'uri'
4
4
  require 'active_support/core_ext/object/blank'
5
5
  require 'active_support/configurable'
6
6
  require 'active_support/ordered_options'
7
+ require 'net/http'
7
8
 
8
9
  module GmapsDirections
9
10
 
@@ -53,9 +54,8 @@ module GmapsDirections
53
54
  end
54
55
 
55
56
  def call_google
56
- Yajl::HttpStream.get(directions_api_url) do |results_hash|
57
- @parsed_directions_response = results_hash
58
- end
57
+ response = Net::HTTP.get_response(directions_api_url).body
58
+ @parsed_directions_response = Yajl::Parser.parse(response)
59
59
  end
60
60
 
61
61
  private
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
4
 
3
5
  describe "GmapsDirections" do
@@ -7,7 +9,10 @@ describe "GmapsDirections" do
7
9
  end_address = "Just Avenue 42, 11111 Sin City"
8
10
 
9
11
  directions_api_url = URI.parse("http://maps.googleapis.com/maps/api/directions/json?origin=#{URI.encode(start_address)}&destination=#{URI.encode(end_address)}&mode=driving&units=metric&language=en&sensor=false&alternatives=false")
10
- Yajl::HttpStream.should_receive(:get).with(directions_api_url).and_yield({"routes" => [double("route_hash")], "status" => "OK"})
12
+
13
+ ::Net::HTTP.should_receive(:get_response).with(directions_api_url).and_return(double("response", :body => ""))
14
+ ::Yajl::Parser.should_receive(:parse).and_return({"routes" => [double("route_hash")], "status" => "OK"})
15
+
11
16
  GmapsDirections::Route.should_receive(:new)
12
17
 
13
18
  GmapsDirections::API.find_directions :from => start_address, :to => end_address
@@ -128,19 +133,19 @@ describe "GmapsDirections" do
128
133
 
129
134
  end
130
135
 
131
- it 'should perform a real request see if everything is parsed correctly' do
136
+ it 'should perform a real request and see if everything is parsed correctly' do
132
137
  routes = GmapsDirections::API.find_directions :from => "1 Infinite Loop, Cupertino",
133
- :to => "1200 Park Avenue, Emmerville"
138
+ :to => "1200 Park Ave, Emeryville"
134
139
 
135
140
  route = routes.first
136
141
 
137
- route.duration.should == 3482
142
+ (route.duration / 60).should == 58
138
143
  route.formatted_duration.should == "58 mins"
139
- route.distance.should == 84827
140
- route.formatted_distance.should == "84.8 km"
144
+ (route.distance / 1000).should == 85
145
+ route.formatted_distance.should == "85.2 km"
141
146
  route.start_address.should == "1 Infinite Loop, Cupertino, CA 95014, USA"
142
147
  route.end_address.should == "1200 Park Ave, Emeryville, CA 94608, USA"
143
- route.start_location.should == { "lng" => -122.03125, "lat" => 37.3317 }
148
+ route.start_location.should == { "lng" => -122.0291, "lat" => 37.33051 }
144
149
  route.end_location.should == { "lat" => 37.8317100, "lng" => -122.2833000 }
145
150
  route.status.should == "OK"
146
151
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmaps_directions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Breuer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-12 00:00:00 +02:00
18
+ date: 2011-08-11 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency