geocoder 0.1.1 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of geocoder might be problematic. Click here for more details.

data/TODO DELETED
@@ -1,10 +0,0 @@
1
- = Geocoder To-Do list
2
-
3
- Send suggestions to Paul Smith <paul@cnt.org>.
4
-
5
- * unit tests for CLI
6
- * many more tests of known and unknown addresses
7
- * caching
8
- * more services (c'mon, Google!) [Ontok?]
9
- * Rails plugin
10
- * option to "average" results from more than one service
data/bin/geocode DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'geocoder'
3
- cli = Geocoder::Cli.new ARGV
4
- cli.go!
@@ -1,2 +0,0 @@
1
- 41.854436,-87.675853,2038 S Damen Ave,Chicago,IL,60608
2
- 41.918850,-87.677800,2038 N Damen Ave,Chicago,IL,60647
@@ -1 +0,0 @@
1
- 41.910408,-87.680592,2125 W North Ave,Chicago,IL,60647
@@ -1 +0,0 @@
1
- 2: couldn't find this address! sorry
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?> <Error xmlns="urn:yahoo:api">
2
- The following errors were detected:
3
- <Message>unable to parse location</Message></Error>
4
- <!-- ws02.search.scd.yahoo.com uncompressed/chunked Fri Feb 3 16:08:33 PST 2006 -->
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"><Result precision="address" warning="The exact location could not be found, here is the closest match: 2038 S Damen Ave, Chicago, IL 60608"><Latitude>41.854524</Latitude><Longitude>-87.676083</Longitude><Address>2038 S DAMEN AVE</Address><City>CHICAGO</City><State>IL</State><Zip>60608-2625</Zip><Country>US</Country></Result><Result precision="address" warning="The exact location could not be found, here is the closest match: 2038 N Damen Ave, Chicago, IL 60647"><Latitude>41.918759</Latitude><Longitude>-87.67763</Longitude><Address>2038 N DAMEN AVE</Address><City>CHICAGO</City><State>IL</State><Zip>60647-4564</Zip><Country>US</Country></Result></ResultSet>
2
- <!-- ws01.search.scd.yahoo.com uncompressed Fri Feb 3 14:49:21 PST 2006 -->
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"><Result precision="address"><Latitude>41.910263</Latitude><Longitude>-87.680696</Longitude><Address>2125 W NORTH AVE</Address><City>CHICAGO</City><State>IL</State><Zip>60647-5415</Zip><Country>US</Country></Result></ResultSet>
2
- <!-- ws01.search.scd.yahoo.com uncompressed Fri Feb 3 14:49:43 PST 2006 -->
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?> <Error xmlns="urn:yahoo:api">
2
- The following errors were detected:
3
- <Message>unable to parse location</Message></Error>
4
- <!-- ws02.search.scd.yahoo.com uncompressed/chunked Tue Feb 7 14:52:36 PST 2006 -->
data/test/mocks/http.rb DELETED
@@ -1,19 +0,0 @@
1
- require 'net/http'
2
-
3
- module Net
4
- class HTTP
5
- alias_method :old_get, :get
6
- def get(path, *args)
7
- begin
8
- filename = File.dirname(__FILE__) + "/" + File.basename(path)
9
- return File.open(filename)
10
- rescue Errno::ENOENT
11
- old_get(path, *args)
12
- end
13
- end
14
- end
15
- end
16
-
17
- class File
18
- alias_method :body, :read
19
- end
data/test/sample.xml DELETED
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"><Result precision="address"><Latitude>41.910263</Latitude><Longitude>-87.680696</Longitude><Address>2125 W NORTH AVE</Address><City>CHICAGO</City><State>IL</State><Zip>60647-5415</Zip><Country>US</Country></Result></ResultSet>
2
- <!-- ws02.search.re2.yahoo.com uncompressed Wed Jan 25 14:06:31 PST 2006 -->
@@ -1,105 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/geocoder'
3
- require File.dirname(__FILE__) + '/mocks/http'
4
-
5
- class TC_GeoCoderUsSuccess < Test::Unit::TestCase
6
- include Geocoder
7
-
8
- def setup
9
- @geocoder = GeoCoderUs.new
10
- @response = @geocoder.geocode "2125 w north ave chicago il"
11
- end
12
-
13
- def test_success
14
- assert_equal true, @response.success?
15
- end
16
-
17
- def test_latitude
18
- assert_in_delta 41.910408, @response.latitude, 0.0005
19
- end
20
-
21
- def test_longitude
22
- assert_in_delta -87.680592, @response.longitude, 0.0005
23
- end
24
-
25
- def test_address
26
- assert_equal "2125 W North Ave", @response.address
27
- end
28
-
29
- def test_city
30
- assert_equal "Chicago", @response.city
31
- end
32
-
33
- def test_state
34
- assert_equal "IL", @response.state
35
- end
36
-
37
- def test_zip
38
- assert_equal "60647", @response.zip
39
- end
40
-
41
- def test_lat
42
- assert_respond_to @response, :lat
43
- assert_same @response.lat, @response.latitude
44
- end
45
-
46
- def test_lng
47
- assert_respond_to @response, :lng
48
- assert_same @response.lng, @response.lng
49
- end
50
- end
51
-
52
- class TC_GeoCoderUsAmbiguous < Test::Unit::TestCase
53
- include Geocoder
54
-
55
- def setup
56
- @geocoder = GeoCoderUs.new
57
- @response = @geocoder.geocode "2038 damen ave chicago il"
58
- end
59
-
60
- def test_success
61
- assert_equal false, @response.success?
62
- end
63
-
64
- def test_matches
65
- assert_equal 2, @response.size
66
- end
67
-
68
- def test_warning
69
- @response.each do |result|
70
- assert_nil result.warning
71
- end
72
- end
73
-
74
- def test_precision
75
- @response.each do |result|
76
- assert_nil result.precision
77
- end
78
- end
79
- end
80
-
81
- class TC_GeoCoderUsExceptions < Test::Unit::TestCase
82
- include Geocoder
83
-
84
- def setup
85
- @geocoder = GeoCoderUs.new
86
- end
87
-
88
- def test_throws_on_nil
89
- assert_raise(Geocoder::BlankLocationString) {
90
- @geocoder.geocode nil
91
- }
92
- end
93
-
94
- def test_throws_on_empty_string
95
- assert_raise(Geocoder::BlankLocationString) {
96
- @geocoder.geocode ""
97
- }
98
- end
99
-
100
- def test_throws_on_ungeocodeable
101
- assert_raise(Geocoder::GeocodingError) {
102
- @geocoder.geocode "donotleaveitisnotreal"
103
- }
104
- end
105
- end
data/test/tc_yahoo.rb DELETED
@@ -1,110 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/geocoder'
3
- require File.dirname(__FILE__) + '/mocks/http'
4
-
5
- class TC_YahooGeocoderSuccess < Test::Unit::TestCase
6
- include Geocoder
7
-
8
- def setup
9
- @geocoder = Yahoo.new "YahooDemo"
10
- @response = @geocoder.geocode "2125 w north ave chicago il"
11
- end
12
-
13
- def test_success
14
- assert_equal true, @response.success?
15
- end
16
-
17
- def test_latitude
18
- assert_in_delta 41.910263, @response.latitude, 0.0005
19
- end
20
-
21
- def test_longitude
22
- assert_in_delta -87.680696, @response.longitude, 0.0005
23
- end
24
-
25
- def test_address
26
- assert_equal "2125 W NORTH AVE", @response.address
27
- end
28
-
29
- def test_city
30
- assert_equal "CHICAGO", @response.city
31
- end
32
-
33
- def test_state
34
- assert_equal "IL", @response.state
35
- end
36
-
37
- def test_zip
38
- assert_equal "60647-5415", @response.zip
39
- end
40
-
41
- def test_country
42
- assert_equal "US", @response.country
43
- end
44
-
45
- def test_lat
46
- assert_respond_to @response, :lat
47
- assert_same @response.lat, @response.latitude
48
- end
49
-
50
- def test_lng
51
- assert_respond_to @response, :lng
52
- assert_same @response.lng, @response.lng
53
- end
54
- end
55
-
56
- class TC_YahooGeocoderAmbiguous < Test::Unit::TestCase
57
- include Geocoder
58
-
59
- def setup
60
- @geocoder = Yahoo.new "YahooDemo"
61
- @response = @geocoder.geocode "2038 damen ave chicago il"
62
- end
63
-
64
- def test_success
65
- assert_equal false, @response.success?
66
- end
67
-
68
- def test_matches
69
- assert_equal 2, @response.size
70
- end
71
-
72
- def test_warning
73
- @response.each do |result|
74
- assert_match %r{^The exact location could not be found, here is the closest match:},
75
- result.warning
76
- end
77
- end
78
-
79
- def test_precision
80
- @response.each do |result|
81
- assert_equal "address", result.precision
82
- end
83
- end
84
- end
85
-
86
- class TC_YahooGeocoderExceptions < Test::Unit::TestCase
87
- include Geocoder
88
-
89
- def setup
90
- @geocoder = Yahoo.new "YahooDemo"
91
- end
92
-
93
- def test_throws_on_nil
94
- assert_raise(Geocoder::BlankLocationString) {
95
- @geocoder.geocode nil
96
- }
97
- end
98
-
99
- def test_throws_on_empty_string
100
- assert_raise(Geocoder::BlankLocationString) {
101
- @geocoder.geocode ""
102
- }
103
- end
104
-
105
- def test_throws_on_ungeocodeable
106
- assert_raise(Geocoder::GeocodingError) {
107
- @geocoder.geocode "donotleaveitisnotreal"
108
- }
109
- end
110
- end
data/test/ts_geocoder.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'test/unit'
2
- %w{ tc_yahoo tc_geocoderus }.each { |tc|
3
- require File.dirname(__FILE__) + "/#{tc}"
4
- }