aub-graticule 0.2.11

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.
Files changed (88) hide show
  1. data/.gitignore +4 -0
  2. data/CHANGELOG.txt +61 -0
  3. data/LICENSE.txt +30 -0
  4. data/Manifest.txt +84 -0
  5. data/README.txt +41 -0
  6. data/Rakefile +143 -0
  7. data/VERSION +1 -0
  8. data/bin/geocode +5 -0
  9. data/graticule.gemspec +143 -0
  10. data/init.rb +2 -0
  11. data/lib/graticule/cli.rb +64 -0
  12. data/lib/graticule/core_ext.rb +15 -0
  13. data/lib/graticule/distance/haversine.rb +40 -0
  14. data/lib/graticule/distance/spherical.rb +52 -0
  15. data/lib/graticule/distance/vincenty.rb +76 -0
  16. data/lib/graticule/distance.rb +18 -0
  17. data/lib/graticule/geocoder/base.rb +116 -0
  18. data/lib/graticule/geocoder/bogus.rb +15 -0
  19. data/lib/graticule/geocoder/geocoder_ca.rb +54 -0
  20. data/lib/graticule/geocoder/geocoder_us.rb +51 -0
  21. data/lib/graticule/geocoder/google.rb +100 -0
  22. data/lib/graticule/geocoder/host_ip.rb +41 -0
  23. data/lib/graticule/geocoder/local_search_maps.rb +44 -0
  24. data/lib/graticule/geocoder/mapquest.rb +96 -0
  25. data/lib/graticule/geocoder/meta_carta.rb +32 -0
  26. data/lib/graticule/geocoder/multi.rb +46 -0
  27. data/lib/graticule/geocoder/multimap.rb +73 -0
  28. data/lib/graticule/geocoder/postcode_anywhere.rb +63 -0
  29. data/lib/graticule/geocoder/rest.rb +18 -0
  30. data/lib/graticule/geocoder/yahoo.rb +84 -0
  31. data/lib/graticule/geocoder.rb +21 -0
  32. data/lib/graticule/location.rb +61 -0
  33. data/lib/graticule/version.rb +9 -0
  34. data/lib/graticule.rb +26 -0
  35. data/site/index.html +114 -0
  36. data/site/plugin.html +82 -0
  37. data/site/stylesheets/style.css +69 -0
  38. data/test/config.yml.default +36 -0
  39. data/test/fixtures/responses/geocoder_us/success.xml +18 -0
  40. data/test/fixtures/responses/geocoder_us/unknown.xml +1 -0
  41. data/test/fixtures/responses/google/badkey.xml +1 -0
  42. data/test/fixtures/responses/google/limit.xml +10 -0
  43. data/test/fixtures/responses/google/missing_address.xml +1 -0
  44. data/test/fixtures/responses/google/only_coordinates.xml +1 -0
  45. data/test/fixtures/responses/google/partial.xml +1 -0
  46. data/test/fixtures/responses/google/server_error.xml +10 -0
  47. data/test/fixtures/responses/google/success.xml +1 -0
  48. data/test/fixtures/responses/google/success_multiple_results.xml +88 -0
  49. data/test/fixtures/responses/google/unavailable.xml +1 -0
  50. data/test/fixtures/responses/google/unknown_address.xml +1 -0
  51. data/test/fixtures/responses/host_ip/private.txt +4 -0
  52. data/test/fixtures/responses/host_ip/success.txt +4 -0
  53. data/test/fixtures/responses/host_ip/unknown.txt +4 -0
  54. data/test/fixtures/responses/local_search_maps/empty.txt +1 -0
  55. data/test/fixtures/responses/local_search_maps/not_found.txt +1 -0
  56. data/test/fixtures/responses/local_search_maps/success.txt +1 -0
  57. data/test/fixtures/responses/mapquest/multi_result.xml +1 -0
  58. data/test/fixtures/responses/mapquest/success.xml +1 -0
  59. data/test/fixtures/responses/meta_carta/bad_address.xml +17 -0
  60. data/test/fixtures/responses/meta_carta/multiple.xml +33 -0
  61. data/test/fixtures/responses/meta_carta/success.xml +31 -0
  62. data/test/fixtures/responses/multimap/missing_params.xml +4 -0
  63. data/test/fixtures/responses/multimap/no_matches.xml +4 -0
  64. data/test/fixtures/responses/multimap/success.xml +19 -0
  65. data/test/fixtures/responses/postcode_anywhere/badkey.xml +9 -0
  66. data/test/fixtures/responses/postcode_anywhere/canada.xml +16 -0
  67. data/test/fixtures/responses/postcode_anywhere/empty.xml +16 -0
  68. data/test/fixtures/responses/postcode_anywhere/success.xml +16 -0
  69. data/test/fixtures/responses/postcode_anywhere/uk.xml +18 -0
  70. data/test/fixtures/responses/yahoo/success.xml +3 -0
  71. data/test/fixtures/responses/yahoo/unknown_address.xml +6 -0
  72. data/test/mocks/uri.rb +52 -0
  73. data/test/test_helper.rb +31 -0
  74. data/test/unit/graticule/distance_test.rb +58 -0
  75. data/test/unit/graticule/geocoder/geocoder_us_test.rb +43 -0
  76. data/test/unit/graticule/geocoder/geocoders.rb +56 -0
  77. data/test/unit/graticule/geocoder/google_test.rb +112 -0
  78. data/test/unit/graticule/geocoder/host_ip_test.rb +40 -0
  79. data/test/unit/graticule/geocoder/local_search_maps_test.rb +30 -0
  80. data/test/unit/graticule/geocoder/mapquest_test.rb +61 -0
  81. data/test/unit/graticule/geocoder/meta_carta_test.rb +44 -0
  82. data/test/unit/graticule/geocoder/multi_test.rb +43 -0
  83. data/test/unit/graticule/geocoder/multimap_test.rb +52 -0
  84. data/test/unit/graticule/geocoder/postcode_anywhere_test.rb +50 -0
  85. data/test/unit/graticule/geocoder/yahoo_test.rb +48 -0
  86. data/test/unit/graticule/geocoder_test.rb +27 -0
  87. data/test/unit/graticule/location_test.rb +73 -0
  88. metadata +166 -0
@@ -0,0 +1,73 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
+
3
+ module Graticule
4
+ class LocationTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @washington_dc = Location.new :latitude => 38.898748, :longitude => -77.037684,
8
+ :street => '1600 Pennsylvania Avenue, NW', :locality => 'Washington',
9
+ :region => 'DC', :postal_code => 20500, :country => 'US'
10
+ end
11
+
12
+ def test_distance_to
13
+ chicago = Location.new(:latitude => 41.85, :longitude => -87.65)
14
+ assert_in_delta 594.820, @washington_dc.distance_to(chicago), 1.0
15
+ end
16
+
17
+ def test_responds_to
18
+ [:latitude, :longitude, :street, :locality, :region, :postal_code, :country, :coordinates, :precision].each do |m|
19
+ assert Location.new.respond_to?(m), "should respond to #{m}"
20
+ end
21
+ end
22
+
23
+ def test_coordinates
24
+ l = Location.new(:latitude => 100, :longitude => 50)
25
+ assert_equal [100, 50], l.coordinates
26
+ end
27
+
28
+ def test_equal
29
+ assert_equal Location.new, Location.new
30
+
31
+ attrs = {:latitude => 100.5389, :longitude => -147.5893, :street => '123 A Street',
32
+ :locality => 'Somewhere', :region => 'NO', :postal_code => '12345', :country => 'USA'}
33
+
34
+ assert_equal Location.new(attrs), Location.new(attrs)
35
+ attrs.each do |k,v|
36
+ assert_equal Location.new(k => v), Location.new(k => v)
37
+ assert_not_equal Location.new, Location.new(k => v)
38
+ assert_not_equal Location.new(attrs), Location.new(attrs.update(k => nil))
39
+ end
40
+ end
41
+
42
+ def test_antipode
43
+ chicago = Location.new(:latitude => 41.85, :longitude => -87.65)
44
+
45
+ assert_equal [-38.898748, 102.962316], @washington_dc.antipode.coordinates
46
+ assert_equal [-41.85, 92.35], chicago.antipode.coordinates
47
+ assert_equal [-41, -180], Graticule::Location.new(:latitude => 41, :longitude => 0).antipode.coordinates
48
+ assert_equal [-41, 179], Graticule::Location.new(:latitude => 41, :longitude => -1).antipode.coordinates
49
+ assert_equal [-41, -179], Graticule::Location.new(:latitude => 41, :longitude => 1).antipode.coordinates
50
+
51
+ assert_equal @washington_dc.coordinates, @washington_dc.antipode.antipode.coordinates
52
+ assert_equal chicago.coordinates, chicago.antipode.antipode.coordinates
53
+ end
54
+
55
+ def test_to_s
56
+ assert_equal "1600 Pennsylvania Avenue, NW\nWashington, DC 20500 US",
57
+ @washington_dc.to_s
58
+ assert_equal "1600 Pennsylvania Avenue, NW\nWashington, DC 20500",
59
+ @washington_dc.to_s(:country => false)
60
+ assert_equal "1600 Pennsylvania Avenue, NW\nWashington, DC 20500",
61
+ @washington_dc.to_s(:country => false)
62
+ assert_equal "1600 Pennsylvania Avenue, NW\nWashington, DC 20500\nlatitude: 38.898748, longitude: -77.037684",
63
+ @washington_dc.to_s(:country => false, :coordinates => true)
64
+ end
65
+
66
+ def test_blank?
67
+ assert Location.new.blank?
68
+ [:latitude, :longitude, :street, :locality, :region, :postal_code, :country].each do |attr|
69
+ assert !Location.new(attr => 'Foo').blank?
70
+ end
71
+ end
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aub-graticule
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.11
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Keepers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-20 00:00:00 -07:00
13
+ default_executable: geocode
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.
26
+ email: brandon@opensoul.org
27
+ executables:
28
+ - geocode
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.txt
33
+ files:
34
+ - .gitignore
35
+ - CHANGELOG.txt
36
+ - LICENSE.txt
37
+ - Manifest.txt
38
+ - README.txt
39
+ - Rakefile
40
+ - VERSION
41
+ - bin/geocode
42
+ - graticule.gemspec
43
+ - init.rb
44
+ - lib/graticule.rb
45
+ - lib/graticule/cli.rb
46
+ - lib/graticule/core_ext.rb
47
+ - lib/graticule/distance.rb
48
+ - lib/graticule/distance/haversine.rb
49
+ - lib/graticule/distance/spherical.rb
50
+ - lib/graticule/distance/vincenty.rb
51
+ - lib/graticule/geocoder.rb
52
+ - lib/graticule/geocoder/base.rb
53
+ - lib/graticule/geocoder/bogus.rb
54
+ - lib/graticule/geocoder/geocoder_ca.rb
55
+ - lib/graticule/geocoder/geocoder_us.rb
56
+ - lib/graticule/geocoder/google.rb
57
+ - lib/graticule/geocoder/host_ip.rb
58
+ - lib/graticule/geocoder/local_search_maps.rb
59
+ - lib/graticule/geocoder/mapquest.rb
60
+ - lib/graticule/geocoder/meta_carta.rb
61
+ - lib/graticule/geocoder/multi.rb
62
+ - lib/graticule/geocoder/multimap.rb
63
+ - lib/graticule/geocoder/postcode_anywhere.rb
64
+ - lib/graticule/geocoder/rest.rb
65
+ - lib/graticule/geocoder/yahoo.rb
66
+ - lib/graticule/location.rb
67
+ - lib/graticule/version.rb
68
+ - site/index.html
69
+ - site/plugin.html
70
+ - site/stylesheets/style.css
71
+ - test/config.yml.default
72
+ - test/fixtures/responses/geocoder_us/success.xml
73
+ - test/fixtures/responses/geocoder_us/unknown.xml
74
+ - test/fixtures/responses/google/badkey.xml
75
+ - test/fixtures/responses/google/limit.xml
76
+ - test/fixtures/responses/google/missing_address.xml
77
+ - test/fixtures/responses/google/only_coordinates.xml
78
+ - test/fixtures/responses/google/partial.xml
79
+ - test/fixtures/responses/google/server_error.xml
80
+ - test/fixtures/responses/google/success.xml
81
+ - test/fixtures/responses/google/success_multiple_results.xml
82
+ - test/fixtures/responses/google/unavailable.xml
83
+ - test/fixtures/responses/google/unknown_address.xml
84
+ - test/fixtures/responses/host_ip/private.txt
85
+ - test/fixtures/responses/host_ip/success.txt
86
+ - test/fixtures/responses/host_ip/unknown.txt
87
+ - test/fixtures/responses/local_search_maps/empty.txt
88
+ - test/fixtures/responses/local_search_maps/not_found.txt
89
+ - test/fixtures/responses/local_search_maps/success.txt
90
+ - test/fixtures/responses/mapquest/multi_result.xml
91
+ - test/fixtures/responses/mapquest/success.xml
92
+ - test/fixtures/responses/meta_carta/bad_address.xml
93
+ - test/fixtures/responses/meta_carta/multiple.xml
94
+ - test/fixtures/responses/meta_carta/success.xml
95
+ - test/fixtures/responses/multimap/missing_params.xml
96
+ - test/fixtures/responses/multimap/no_matches.xml
97
+ - test/fixtures/responses/multimap/success.xml
98
+ - test/fixtures/responses/postcode_anywhere/badkey.xml
99
+ - test/fixtures/responses/postcode_anywhere/canada.xml
100
+ - test/fixtures/responses/postcode_anywhere/empty.xml
101
+ - test/fixtures/responses/postcode_anywhere/success.xml
102
+ - test/fixtures/responses/postcode_anywhere/uk.xml
103
+ - test/fixtures/responses/yahoo/success.xml
104
+ - test/fixtures/responses/yahoo/unknown_address.xml
105
+ - test/mocks/uri.rb
106
+ - test/test_helper.rb
107
+ - test/unit/graticule/distance_test.rb
108
+ - test/unit/graticule/geocoder/geocoder_us_test.rb
109
+ - test/unit/graticule/geocoder/geocoders.rb
110
+ - test/unit/graticule/geocoder/google_test.rb
111
+ - test/unit/graticule/geocoder/host_ip_test.rb
112
+ - test/unit/graticule/geocoder/local_search_maps_test.rb
113
+ - test/unit/graticule/geocoder/mapquest_test.rb
114
+ - test/unit/graticule/geocoder/meta_carta_test.rb
115
+ - test/unit/graticule/geocoder/multi_test.rb
116
+ - test/unit/graticule/geocoder/multimap_test.rb
117
+ - test/unit/graticule/geocoder/postcode_anywhere_test.rb
118
+ - test/unit/graticule/geocoder/yahoo_test.rb
119
+ - test/unit/graticule/geocoder_test.rb
120
+ - test/unit/graticule/location_test.rb
121
+ has_rdoc: false
122
+ homepage: http://github.com/collectiveidea/graticule
123
+ post_install_message:
124
+ rdoc_options:
125
+ - --main
126
+ - README.rdoc
127
+ - --inline-source
128
+ - --line-numbers
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: "0"
136
+ version:
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: "0"
142
+ version:
143
+ requirements: []
144
+
145
+ rubyforge_project: graticule
146
+ rubygems_version: 1.2.0
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: API for using all the popular geocoding services.
150
+ test_files:
151
+ - test/mocks/uri.rb
152
+ - test/test_helper.rb
153
+ - test/unit/graticule/distance_test.rb
154
+ - test/unit/graticule/geocoder/geocoder_us_test.rb
155
+ - test/unit/graticule/geocoder/geocoders.rb
156
+ - test/unit/graticule/geocoder/google_test.rb
157
+ - test/unit/graticule/geocoder/host_ip_test.rb
158
+ - test/unit/graticule/geocoder/local_search_maps_test.rb
159
+ - test/unit/graticule/geocoder/mapquest_test.rb
160
+ - test/unit/graticule/geocoder/meta_carta_test.rb
161
+ - test/unit/graticule/geocoder/multi_test.rb
162
+ - test/unit/graticule/geocoder/multimap_test.rb
163
+ - test/unit/graticule/geocoder/postcode_anywhere_test.rb
164
+ - test/unit/graticule/geocoder/yahoo_test.rb
165
+ - test/unit/graticule/geocoder_test.rb
166
+ - test/unit/graticule/location_test.rb