graticule 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGELOG.txt +8 -0
  2. data/LICENSE.txt +30 -0
  3. data/Manifest.txt +44 -0
  4. data/README.txt +10 -0
  5. data/Rakefile +16 -0
  6. data/init.rb +2 -0
  7. data/lib/graticule.rb +14 -0
  8. data/lib/graticule/distance.rb +24 -0
  9. data/lib/graticule/distance/haversine.rb +65 -0
  10. data/lib/graticule/distance/spherical.rb +30 -0
  11. data/lib/graticule/distance/vincenty.rb +99 -0
  12. data/lib/graticule/geocoder.rb +26 -0
  13. data/lib/graticule/geocoders/bogus.rb +12 -0
  14. data/lib/graticule/geocoders/geocoder_us.rb +45 -0
  15. data/lib/graticule/geocoders/google.rb +96 -0
  16. data/lib/graticule/geocoders/meta_carta.rb +102 -0
  17. data/lib/graticule/geocoders/rest.rb +98 -0
  18. data/lib/graticule/geocoders/yahoo.rb +101 -0
  19. data/lib/graticule/location.rb +28 -0
  20. data/lib/graticule/version.rb +3 -0
  21. data/test/fixtures/responses/geocoder_us/success.xml +10 -0
  22. data/test/fixtures/responses/geocoder_us/unknown.xml +1 -0
  23. data/test/fixtures/responses/google/badkey.xml +10 -0
  24. data/test/fixtures/responses/google/limit.xml +10 -0
  25. data/test/fixtures/responses/google/missing_address.xml +10 -0
  26. data/test/fixtures/responses/google/server_error.xml +10 -0
  27. data/test/fixtures/responses/google/success.xml +37 -0
  28. data/test/fixtures/responses/google/unavailable.xml +10 -0
  29. data/test/fixtures/responses/google/unknown_address.xml +10 -0
  30. data/test/fixtures/responses/meta_carta/bad_address.xml +9 -0
  31. data/test/fixtures/responses/meta_carta/multiple.xml +33 -0
  32. data/test/fixtures/responses/meta_carta/success.xml +23 -0
  33. data/test/fixtures/responses/yahoo/success.xml +3 -0
  34. data/test/fixtures/responses/yahoo/unknown_address.xml +6 -0
  35. data/test/mocks/uri.rb +51 -0
  36. data/test/test_helper.rb +31 -0
  37. data/test/unit/graticule/distance_test.rb +30 -0
  38. data/test/unit/graticule/geocoder_test.rb +31 -0
  39. data/test/unit/graticule/geocoders/geocoder_us_test.rb +42 -0
  40. data/test/unit/graticule/geocoders/geocoders.rb +56 -0
  41. data/test/unit/graticule/geocoders/google_test.rb +22 -0
  42. data/test/unit/graticule/geocoders/meta_carta_test.rb +70 -0
  43. data/test/unit/graticule/geocoders/yahoo_test.rb +49 -0
  44. data/test/unit/graticule/location_test.rb +38 -0
  45. metadata +102 -0
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Graticule
4
+ class LocationTest < Test::Unit::TestCase
5
+
6
+ def test_distance_to
7
+ washington_dc = Location.new(:latitude => 38.898748, :longitude => -77.037684)
8
+ chicago = Location.new(:latitude => 41.85, :longitude => -87.65)
9
+ assert_in_delta 594.820, washington_dc.distance_to(chicago), 1.0
10
+ end
11
+
12
+ def test_responds_to
13
+ [:latitude, :longitude, :street, :city, :state, :zip, :country, :coordinates, :precision].each do |m|
14
+ assert Location.new.respond_to?(m), "should respond to #{m}"
15
+ end
16
+ end
17
+
18
+ def test_coordinates
19
+ l = Location.new(:latitude => 100, :longitude => 50)
20
+ assert_equal [100, 50], l.coordinates
21
+ end
22
+
23
+ def test_equal
24
+ assert_equal Location.new, Location.new
25
+
26
+ attrs = {:latitude => 100.5389, :longitude => -147.5893, :street => '123 A Street',
27
+ :city => 'Somewhere', :state => 'NO', :zip => '12345', :country => 'USA', :precision => :address}
28
+
29
+ assert_equal Location.new(attrs), Location.new(attrs)
30
+ attrs.each do |k,v|
31
+ assert_equal Location.new(k => v), Location.new(k => v)
32
+ assert_not_equal Location.new, Location.new(k => v)
33
+ assert_not_equal Location.new(attrs), Location.new(attrs.update(k => nil))
34
+ end
35
+ end
36
+
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: graticule
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.1
7
+ date: 2006-12-16 00:00:00 -05:00
8
+ summary: API for using all the popular geocoding services.
9
+ require_paths:
10
+ - lib
11
+ email: brandon@opensoul.org
12
+ homepage: http://graticule.rubyforge.org
13
+ rubyforge_project: graticule
14
+ description: Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Brandon Keepers
30
+ files:
31
+ - CHANGELOG.txt
32
+ - LICENSE.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - init.rb
37
+ - lib/graticule.rb
38
+ - lib/graticule/distance.rb
39
+ - lib/graticule/distance/haversine.rb
40
+ - lib/graticule/distance/spherical.rb
41
+ - lib/graticule/distance/vincenty.rb
42
+ - lib/graticule/geocoder.rb
43
+ - lib/graticule/geocoders/bogus.rb
44
+ - lib/graticule/geocoders/geocoder_us.rb
45
+ - lib/graticule/geocoders/google.rb
46
+ - lib/graticule/geocoders/meta_carta.rb
47
+ - lib/graticule/geocoders/rest.rb
48
+ - lib/graticule/geocoders/yahoo.rb
49
+ - lib/graticule/location.rb
50
+ - lib/graticule/version.rb
51
+ - test/fixtures/responses/geocoder_us/success.xml
52
+ - test/fixtures/responses/geocoder_us/unknown.xml
53
+ - test/fixtures/responses/google/badkey.xml
54
+ - test/fixtures/responses/google/limit.xml
55
+ - test/fixtures/responses/google/missing_address.xml
56
+ - test/fixtures/responses/google/server_error.xml
57
+ - test/fixtures/responses/google/success.xml
58
+ - test/fixtures/responses/google/unavailable.xml
59
+ - test/fixtures/responses/google/unknown_address.xml
60
+ - test/fixtures/responses/meta_carta/bad_address.xml
61
+ - test/fixtures/responses/meta_carta/multiple.xml
62
+ - test/fixtures/responses/meta_carta/success.xml
63
+ - test/fixtures/responses/yahoo/success.xml
64
+ - test/fixtures/responses/yahoo/unknown_address.xml
65
+ - test/mocks/uri.rb
66
+ - test/test_helper.rb
67
+ - test/unit/graticule/distance_test.rb
68
+ - test/unit/graticule/geocoder_test.rb
69
+ - test/unit/graticule/geocoders/geocoder_us_test.rb
70
+ - test/unit/graticule/geocoders/geocoders.rb
71
+ - test/unit/graticule/geocoders/google_test.rb
72
+ - test/unit/graticule/geocoders/meta_carta_test.rb
73
+ - test/unit/graticule/geocoders/yahoo_test.rb
74
+ - test/unit/graticule/location_test.rb
75
+ test_files:
76
+ - test/unit/graticule/distance_test.rb
77
+ - test/unit/graticule/geocoder_test.rb
78
+ - test/unit/graticule/location_test.rb
79
+ - test/unit/graticule/geocoders/geocoder_us_test.rb
80
+ - test/unit/graticule/geocoders/google_test.rb
81
+ - test/unit/graticule/geocoders/meta_carta_test.rb
82
+ - test/unit/graticule/geocoders/yahoo_test.rb
83
+ rdoc_options: []
84
+
85
+ extra_rdoc_files: []
86
+
87
+ executables: []
88
+
89
+ extensions: []
90
+
91
+ requirements: []
92
+
93
+ dependencies:
94
+ - !ruby/object:Gem::Dependency
95
+ name: hoe
96
+ version_requirement:
97
+ version_requirements: !ruby/object:Gem::Version::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.6
102
+ version: