CodeMonkeySteve-graticule 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG.txt +61 -0
- data/LICENSE.txt +30 -0
- data/Manifest.txt +85 -0
- data/README.txt +41 -0
- data/Rakefile +143 -0
- data/VERSION +1 -0
- data/bin/geocode +5 -0
- data/graticule.gemspec +144 -0
- data/init.rb +2 -0
- data/lib/graticule.rb +26 -0
- data/lib/graticule/cli.rb +64 -0
- data/lib/graticule/core_ext.rb +15 -0
- data/lib/graticule/distance.rb +18 -0
- data/lib/graticule/distance/haversine.rb +40 -0
- data/lib/graticule/distance/spherical.rb +52 -0
- data/lib/graticule/distance/vincenty.rb +76 -0
- data/lib/graticule/geocoder.rb +21 -0
- data/lib/graticule/geocoder/base.rb +112 -0
- data/lib/graticule/geocoder/bogus.rb +15 -0
- data/lib/graticule/geocoder/geocoder_ca.rb +54 -0
- data/lib/graticule/geocoder/geocoder_us.rb +51 -0
- data/lib/graticule/geocoder/google.rb +104 -0
- data/lib/graticule/geocoder/host_ip.rb +41 -0
- data/lib/graticule/geocoder/local_search_maps.rb +45 -0
- data/lib/graticule/geocoder/mapquest.rb +87 -0
- data/lib/graticule/geocoder/meta_carta.rb +33 -0
- data/lib/graticule/geocoder/multi.rb +46 -0
- data/lib/graticule/geocoder/multimap.rb +73 -0
- data/lib/graticule/geocoder/postcode_anywhere.rb +63 -0
- data/lib/graticule/geocoder/rest.rb +18 -0
- data/lib/graticule/geocoder/yahoo.rb +84 -0
- data/lib/graticule/location.rb +61 -0
- data/lib/graticule/version.rb +9 -0
- data/site/index.html +114 -0
- data/site/plugin.html +82 -0
- data/site/stylesheets/style.css +69 -0
- data/test/config.yml.default +37 -0
- data/test/fixtures/responses/geocoder_us/success.xml +18 -0
- data/test/fixtures/responses/geocoder_us/unknown.xml +1 -0
- data/test/fixtures/responses/google/badkey.xml +1 -0
- data/test/fixtures/responses/google/limit.xml +10 -0
- data/test/fixtures/responses/google/missing_address.xml +1 -0
- data/test/fixtures/responses/google/only_coordinates.xml +1 -0
- data/test/fixtures/responses/google/partial.xml +1 -0
- data/test/fixtures/responses/google/server_error.xml +10 -0
- data/test/fixtures/responses/google/success.xml +1 -0
- data/test/fixtures/responses/google/success_multiple_results.xml +88 -0
- data/test/fixtures/responses/google/success_on_options.xml +16 -0
- data/test/fixtures/responses/google/unavailable.xml +1 -0
- data/test/fixtures/responses/google/unknown_address.xml +1 -0
- data/test/fixtures/responses/host_ip/private.txt +4 -0
- data/test/fixtures/responses/host_ip/success.txt +4 -0
- data/test/fixtures/responses/host_ip/unknown.txt +4 -0
- data/test/fixtures/responses/local_search_maps/empty.txt +1 -0
- data/test/fixtures/responses/local_search_maps/not_found.txt +1 -0
- data/test/fixtures/responses/local_search_maps/success.txt +1 -0
- data/test/fixtures/responses/mapquest/multi_result.xml +1 -0
- data/test/fixtures/responses/mapquest/success.xml +1 -0
- data/test/fixtures/responses/meta_carta/bad_address.xml +17 -0
- data/test/fixtures/responses/meta_carta/multiple.xml +33 -0
- data/test/fixtures/responses/meta_carta/success.xml +31 -0
- data/test/fixtures/responses/multimap/missing_params.xml +4 -0
- data/test/fixtures/responses/multimap/no_matches.xml +4 -0
- data/test/fixtures/responses/multimap/success.xml +19 -0
- data/test/fixtures/responses/postcode_anywhere/badkey.xml +9 -0
- data/test/fixtures/responses/postcode_anywhere/canada.xml +16 -0
- data/test/fixtures/responses/postcode_anywhere/empty.xml +16 -0
- data/test/fixtures/responses/postcode_anywhere/success.xml +16 -0
- data/test/fixtures/responses/postcode_anywhere/uk.xml +18 -0
- data/test/fixtures/responses/yahoo/success.xml +3 -0
- data/test/fixtures/responses/yahoo/unknown_address.xml +6 -0
- data/test/mocks/uri.rb +52 -0
- data/test/test_helper.rb +31 -0
- data/test/unit/graticule/distance_test.rb +58 -0
- data/test/unit/graticule/geocoder/geocoder_us_test.rb +43 -0
- data/test/unit/graticule/geocoder/geocoders.rb +56 -0
- data/test/unit/graticule/geocoder/google_test.rb +127 -0
- data/test/unit/graticule/geocoder/host_ip_test.rb +40 -0
- data/test/unit/graticule/geocoder/local_search_maps_test.rb +30 -0
- data/test/unit/graticule/geocoder/mapquest_test.rb +47 -0
- data/test/unit/graticule/geocoder/meta_carta_test.rb +44 -0
- data/test/unit/graticule/geocoder/multi_test.rb +43 -0
- data/test/unit/graticule/geocoder/multimap_test.rb +52 -0
- data/test/unit/graticule/geocoder/postcode_anywhere_test.rb +50 -0
- data/test/unit/graticule/geocoder/yahoo_test.rb +48 -0
- data/test/unit/graticule/geocoder_test.rb +27 -0
- data/test/unit/graticule/location_test.rb +73 -0
- metadata +167 -0
data/.gitignore
ADDED
data/CHANGELOG.txt
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
0.2.11 (2009-07-15)
|
2
|
+
* Add new MapQuest geocoder [Aubrey Holland]
|
3
|
+
|
4
|
+
0.2.10 (2009-04-17)
|
5
|
+
* Added #blank? to Location
|
6
|
+
|
7
|
+
0.2.9 (2009-04-14)
|
8
|
+
* Remove retired MapQuest geocoder
|
9
|
+
* Slightly more aggressive error handling for Geocoder.us
|
10
|
+
* Extend Numeric with #to_radians and #to_degrees
|
11
|
+
|
12
|
+
0.2.8 (2008-10-03)
|
13
|
+
* fixed missing files from gem
|
14
|
+
|
15
|
+
0.2.7 (2008-10-03)
|
16
|
+
* Adding Multimap geocoder [Tom Taylor]
|
17
|
+
* Added MapQuest geocoder [Andrew Selder]
|
18
|
+
* Fix google geocoder for responses that only return coordinates [Andrew Selder]
|
19
|
+
|
20
|
+
0.2.5
|
21
|
+
* fixed address mapping for local search maps (again)
|
22
|
+
|
23
|
+
0.2.4 (2007-05-15)
|
24
|
+
* fixed address mapping for local search maps (Tom Taylor)
|
25
|
+
|
26
|
+
0.2.3 (2007-04-27)
|
27
|
+
* fixed Google for less precise queries
|
28
|
+
* added User-Agent to coerce Google into returning UTF-8 (Jonathan Tron)
|
29
|
+
|
30
|
+
0.2.2 (2007-03-27)
|
31
|
+
* fixed LocalSearchMaps
|
32
|
+
|
33
|
+
0.2.1 (2007-03-19)
|
34
|
+
* fixed error in command line interface
|
35
|
+
|
36
|
+
0.2.0 (2007-03-17)
|
37
|
+
* changed city to locality, state to region, and zip to postal_code
|
38
|
+
* added support for PostcodeAnywhere
|
39
|
+
* added support for Local Search Maps (James Stewart)
|
40
|
+
* added IP-based geocoder
|
41
|
+
* moved geocoders to Graticule::Geocoder namespace
|
42
|
+
* fixed Google geocoder (again)
|
43
|
+
* made Yahoo geocoder consistent with others by returning 1 result
|
44
|
+
* geocoders can how take a Hash (:street, :locality, :region, :postal_code, :country)
|
45
|
+
or a Graticule::Location for the #locate call
|
46
|
+
|
47
|
+
0.1.3 (2007-02-14)
|
48
|
+
* fixed Google geocoder
|
49
|
+
* fixed CLI
|
50
|
+
|
51
|
+
0.1.2 (2007-02-12)
|
52
|
+
* added "geocode" executable. See "geocode --help" for more information
|
53
|
+
* declared dependency on ActiveSupport
|
54
|
+
|
55
|
+
0.1.1 (2006-12-16)
|
56
|
+
* fixed bug in Yahoo that raised error when street address not returned
|
57
|
+
* migrated to Hoe (http://seattlerb.rubyforge.org/hoe/)
|
58
|
+
* added Haversine, Spherical and Vincenty distance calculations
|
59
|
+
|
60
|
+
0.1 (2006-10-31)
|
61
|
+
* Initial release
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Copyright 2006 Brandon Keepers, Collective Idea. All rights reserved.
|
2
|
+
|
3
|
+
Original geocoding code:
|
4
|
+
Copyright 2006 Eric Hodel, The Robot Co-op. All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions
|
8
|
+
are met:
|
9
|
+
|
10
|
+
1. Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
3. Neither the names of the authors nor the names of their contributors
|
16
|
+
may be used to endorse or promote products derived from this software
|
17
|
+
without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
20
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
|
23
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
25
|
+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
26
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
27
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
28
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
29
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
CHANGELOG.txt
|
2
|
+
LICENSE.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
bin/geocode
|
7
|
+
init.rb
|
8
|
+
lib/graticule.rb
|
9
|
+
lib/graticule/cli.rb
|
10
|
+
lib/graticule/core_ext.rb
|
11
|
+
lib/graticule/distance.rb
|
12
|
+
lib/graticule/distance/haversine.rb
|
13
|
+
lib/graticule/distance/spherical.rb
|
14
|
+
lib/graticule/distance/vincenty.rb
|
15
|
+
lib/graticule/geocoder.rb
|
16
|
+
lib/graticule/geocoder/base.rb
|
17
|
+
lib/graticule/geocoder/bogus.rb
|
18
|
+
lib/graticule/geocoder/geocoder_ca.rb
|
19
|
+
lib/graticule/geocoder/geocoder_us.rb
|
20
|
+
lib/graticule/geocoder/google.rb
|
21
|
+
lib/graticule/geocoder/host_ip.rb
|
22
|
+
lib/graticule/geocoder/local_search_maps.rb
|
23
|
+
lib/graticule/geocoder/mapquest.rb
|
24
|
+
lib/graticule/geocoder/meta_carta.rb
|
25
|
+
lib/graticule/geocoder/multi.rb
|
26
|
+
lib/graticule/geocoder/multimap.rb
|
27
|
+
lib/graticule/geocoder/postcode_anywhere.rb
|
28
|
+
lib/graticule/geocoder/rest.rb
|
29
|
+
lib/graticule/geocoder/yahoo.rb
|
30
|
+
lib/graticule/location.rb
|
31
|
+
lib/graticule/version.rb
|
32
|
+
site/index.html
|
33
|
+
site/plugin.html
|
34
|
+
site/stylesheets/style.css
|
35
|
+
test/config.yml.default
|
36
|
+
test/fixtures/responses/geocoder_us/success.xml
|
37
|
+
test/fixtures/responses/geocoder_us/unknown.xml
|
38
|
+
test/fixtures/responses/google/badkey.xml
|
39
|
+
test/fixtures/responses/google/limit.xml
|
40
|
+
test/fixtures/responses/google/missing_address.xml
|
41
|
+
test/fixtures/responses/google/only_coordinates.xml
|
42
|
+
test/fixtures/responses/google/partial.xml
|
43
|
+
test/fixtures/responses/google/server_error.xml
|
44
|
+
test/fixtures/responses/google/success.xml
|
45
|
+
test/fixtures/responses/google/success_on_options.xml
|
46
|
+
test/fixtures/responses/google/success_multiple_results.xml
|
47
|
+
test/fixtures/responses/google/unavailable.xml
|
48
|
+
test/fixtures/responses/google/unknown_address.xml
|
49
|
+
test/fixtures/responses/host_ip/private.txt
|
50
|
+
test/fixtures/responses/host_ip/success.txt
|
51
|
+
test/fixtures/responses/host_ip/unknown.txt
|
52
|
+
test/fixtures/responses/local_search_maps/empty.txt
|
53
|
+
test/fixtures/responses/local_search_maps/not_found.txt
|
54
|
+
test/fixtures/responses/local_search_maps/success.txt
|
55
|
+
test/fixtures/responses/mapquest/multi_result.xml
|
56
|
+
test/fixtures/responses/mapquest/success.xml
|
57
|
+
test/fixtures/responses/meta_carta/bad_address.xml
|
58
|
+
test/fixtures/responses/meta_carta/multiple.xml
|
59
|
+
test/fixtures/responses/meta_carta/success.xml
|
60
|
+
test/fixtures/responses/multimap/missing_params.xml
|
61
|
+
test/fixtures/responses/multimap/no_matches.xml
|
62
|
+
test/fixtures/responses/multimap/success.xml
|
63
|
+
test/fixtures/responses/postcode_anywhere/badkey.xml
|
64
|
+
test/fixtures/responses/postcode_anywhere/canada.xml
|
65
|
+
test/fixtures/responses/postcode_anywhere/empty.xml
|
66
|
+
test/fixtures/responses/postcode_anywhere/success.xml
|
67
|
+
test/fixtures/responses/postcode_anywhere/uk.xml
|
68
|
+
test/fixtures/responses/yahoo/success.xml
|
69
|
+
test/fixtures/responses/yahoo/unknown_address.xml
|
70
|
+
test/mocks/uri.rb
|
71
|
+
test/test_helper.rb
|
72
|
+
test/unit/graticule/distance_test.rb
|
73
|
+
test/unit/graticule/geocoder/geocoder_us_test.rb
|
74
|
+
test/unit/graticule/geocoder/geocoders.rb
|
75
|
+
test/unit/graticule/geocoder/google_test.rb
|
76
|
+
test/unit/graticule/geocoder/host_ip_test.rb
|
77
|
+
test/unit/graticule/geocoder/local_search_maps_test.rb
|
78
|
+
test/unit/graticule/geocoder/mapquest_test.rb
|
79
|
+
test/unit/graticule/geocoder/meta_carta_test.rb
|
80
|
+
test/unit/graticule/geocoder/multi_test.rb
|
81
|
+
test/unit/graticule/geocoder/multimap_test.rb
|
82
|
+
test/unit/graticule/geocoder/postcode_anywhere_test.rb
|
83
|
+
test/unit/graticule/geocoder/yahoo_test.rb
|
84
|
+
test/unit/graticule/geocoder_test.rb
|
85
|
+
test/unit/graticule/location_test.rb
|
data/README.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= Graticule
|
2
|
+
|
3
|
+
Graticule is a geocoding API for looking up address coordinates. It supports many popular APIs, including Yahoo, Google, Geocoder.ca, Geocoder.us, PostcodeAnywhere and MetaCarta.
|
4
|
+
|
5
|
+
= Usage
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'graticule'
|
9
|
+
geocoder = Graticule.service(:google).new "api_key"
|
10
|
+
location = geocoder.locate "61 East 9th Street, Holland, MI"
|
11
|
+
|
12
|
+
= Distance Calculation
|
13
|
+
|
14
|
+
Graticule includes 3 different distance formulas, Spherical (simplest but least accurate), Vincenty (most accurate and most complicated), and Haversine (somewhere inbetween).
|
15
|
+
|
16
|
+
geocoder.locate("Holland, MI").distance_to(geocoder.locate("Chicago, IL"))
|
17
|
+
#=> 101.997458788177
|
18
|
+
|
19
|
+
= Command Line
|
20
|
+
|
21
|
+
Graticule includes a command line interface (CLI).
|
22
|
+
|
23
|
+
$ geocode -s yahoo -a yahookey Washington, DC
|
24
|
+
Washington, DC US
|
25
|
+
latitude: 38.895222, longitude: -77.036758
|
26
|
+
|
27
|
+
= How to contribute
|
28
|
+
|
29
|
+
If you find what you might think is a bug:
|
30
|
+
|
31
|
+
1. Check the GitHub issue tracker to see if anyone else has had the same issue.
|
32
|
+
http://github.com/collectiveidea/graticule/issues/
|
33
|
+
2. If you don't see anything, create an issue with information on how to reproduce it.
|
34
|
+
|
35
|
+
If you want to contribute an enhancement or a fix:
|
36
|
+
|
37
|
+
1. Fork the project on github.
|
38
|
+
http://github.com/collectiveidea/graticule/
|
39
|
+
2. Make your changes with tests.
|
40
|
+
3. Commit the changes without making changes to the Rakefile, VERSION, or any other files that aren't related to your enhancement or fix
|
41
|
+
4. Send a pull request.
|
data/Rakefile
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
5
|
+
exit 1
|
6
|
+
end
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
require 'rcov/rcovtask'
|
10
|
+
|
11
|
+
Jeweler::Tasks.new do |s|
|
12
|
+
s.name = "graticule"
|
13
|
+
s.rubyforge_project = "graticule"
|
14
|
+
s.author = 'Brandon Keepers'
|
15
|
+
s.email = 'brandon@opensoul.org'
|
16
|
+
s.summary = "API for using all the popular geocoding services."
|
17
|
+
s.description = 'Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.'
|
18
|
+
s.homepage = "http://github.com/collectiveidea/graticule"
|
19
|
+
s.add_dependency "activesupport"
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.extra_rdoc_files = ["README.txt"]
|
22
|
+
s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
|
23
|
+
s.test_files = Dir['test/**/*.{yml,rb}']
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Default: run unit tests.'
|
27
|
+
task :default => :test
|
28
|
+
|
29
|
+
desc 'Run the unit tests'
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Generate documentatio'
|
37
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
38
|
+
rdoc.rdoc_dir = 'rdoc'
|
39
|
+
rdoc.title = 'Graticule'
|
40
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
41
|
+
rdoc.rdoc_files.include('README.txt')
|
42
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
+
end
|
44
|
+
|
45
|
+
namespace :test do
|
46
|
+
desc "just rcov minus html output"
|
47
|
+
Rcov::RcovTask.new(:coverage) do |t|
|
48
|
+
# t.libs << 'test'
|
49
|
+
t.test_files = FileList['test/**/*_test.rb']
|
50
|
+
t.output_dir = 'coverage'
|
51
|
+
t.verbose = true
|
52
|
+
t.rcov_opts = %w(--exclude test,/usr/lib/ruby,/Library/Ruby,$HOME/.gem --sort coverage)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
require 'rake/contrib/sshpublisher'
|
57
|
+
namespace :rubyforge do
|
58
|
+
|
59
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
60
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
61
|
+
|
62
|
+
namespace :release do
|
63
|
+
desc "Publish RDoc to RubyForge."
|
64
|
+
task :docs => [:rdoc] do
|
65
|
+
config = YAML.load(
|
66
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
67
|
+
)
|
68
|
+
|
69
|
+
host = "#{config['username']}@rubyforge.org"
|
70
|
+
remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
|
71
|
+
local_dir = 'rdoc'
|
72
|
+
|
73
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
namespace :test do
|
79
|
+
namespace :cache do
|
80
|
+
desc 'Cache test responses from all the free geocoders'
|
81
|
+
task :free => [:google, :geocoder_us, :host_ip, :local_search_maps, :meta_carta, :yahoo]
|
82
|
+
|
83
|
+
desc 'Cache test responses from Google'
|
84
|
+
task :google do
|
85
|
+
cache_responses('google')
|
86
|
+
end
|
87
|
+
|
88
|
+
desc 'Cache test responses from Geocoder.us'
|
89
|
+
task :geocoder_us do
|
90
|
+
cache_responses('geocoder_us')
|
91
|
+
end
|
92
|
+
|
93
|
+
desc 'Cache test responses from HostIP'
|
94
|
+
task :host_ip do
|
95
|
+
cache_responses('host_ip')
|
96
|
+
end
|
97
|
+
|
98
|
+
desc 'Cache test responses from Local Search Maps'
|
99
|
+
task :local_search_maps do
|
100
|
+
cache_responses('local_search_maps')
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'Cache test responses from Meta Carta'
|
104
|
+
task :meta_carta do
|
105
|
+
cache_responses('meta_carta')
|
106
|
+
end
|
107
|
+
|
108
|
+
desc 'Cache test responses from Yahoo'
|
109
|
+
task :yahoo do
|
110
|
+
cache_responses('yahoo')
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
require 'active_support'
|
117
|
+
require 'net/http'
|
118
|
+
require 'uri'
|
119
|
+
RESPONSES_PATH = File.dirname(__FILE__) + '/test/fixtures/responses'
|
120
|
+
|
121
|
+
def cache_responses(service)
|
122
|
+
test_config[service.to_s]['responses'].each do |file,url|
|
123
|
+
File.open("#{RESPONSES_PATH}/#{service}/#{file}", 'w') do |f|
|
124
|
+
f.puts Net::HTTP.get(URI.parse(url))
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_config
|
130
|
+
file = File.dirname(__FILE__) + '/test/config.yml'
|
131
|
+
raise "Copy config.yml.default to config.yml and set the API keys" unless File.exists?(file)
|
132
|
+
@test_config ||= returning(YAML.load(File.read(file))) do |config|
|
133
|
+
config.each do |service,values|
|
134
|
+
values['responses'].each {|file,url| update_placeholders!(values, url) }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def update_placeholders!(config, thing)
|
140
|
+
config.each do |option, value|
|
141
|
+
thing.gsub!(":#{option}", value) if value.is_a?(String)
|
142
|
+
end
|
143
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.11
|
data/bin/geocode
ADDED
data/graticule.gemspec
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{graticule}
|
5
|
+
s.version = "0.2.11"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Brandon Keepers"]
|
9
|
+
s.date = %q{2009-07-22}
|
10
|
+
s.default_executable = %q{geocode}
|
11
|
+
s.description = %q{Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.}
|
12
|
+
s.email = %q{brandon@opensoul.org}
|
13
|
+
s.executables = ["geocode"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.txt"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"CHANGELOG.txt",
|
20
|
+
"LICENSE.txt",
|
21
|
+
"Manifest.txt",
|
22
|
+
"README.txt",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"bin/geocode",
|
26
|
+
"graticule.gemspec",
|
27
|
+
"init.rb",
|
28
|
+
"lib/graticule.rb",
|
29
|
+
"lib/graticule/cli.rb",
|
30
|
+
"lib/graticule/core_ext.rb",
|
31
|
+
"lib/graticule/distance.rb",
|
32
|
+
"lib/graticule/distance/haversine.rb",
|
33
|
+
"lib/graticule/distance/spherical.rb",
|
34
|
+
"lib/graticule/distance/vincenty.rb",
|
35
|
+
"lib/graticule/geocoder.rb",
|
36
|
+
"lib/graticule/geocoder/base.rb",
|
37
|
+
"lib/graticule/geocoder/bogus.rb",
|
38
|
+
"lib/graticule/geocoder/geocoder_ca.rb",
|
39
|
+
"lib/graticule/geocoder/geocoder_us.rb",
|
40
|
+
"lib/graticule/geocoder/google.rb",
|
41
|
+
"lib/graticule/geocoder/host_ip.rb",
|
42
|
+
"lib/graticule/geocoder/local_search_maps.rb",
|
43
|
+
"lib/graticule/geocoder/mapquest.rb",
|
44
|
+
"lib/graticule/geocoder/meta_carta.rb",
|
45
|
+
"lib/graticule/geocoder/multi.rb",
|
46
|
+
"lib/graticule/geocoder/multimap.rb",
|
47
|
+
"lib/graticule/geocoder/postcode_anywhere.rb",
|
48
|
+
"lib/graticule/geocoder/rest.rb",
|
49
|
+
"lib/graticule/geocoder/yahoo.rb",
|
50
|
+
"lib/graticule/location.rb",
|
51
|
+
"lib/graticule/version.rb",
|
52
|
+
"site/index.html",
|
53
|
+
"site/plugin.html",
|
54
|
+
"site/stylesheets/style.css",
|
55
|
+
"test/config.yml.default",
|
56
|
+
"test/fixtures/responses/geocoder_us/success.xml",
|
57
|
+
"test/fixtures/responses/geocoder_us/unknown.xml",
|
58
|
+
"test/fixtures/responses/google/badkey.xml",
|
59
|
+
"test/fixtures/responses/google/limit.xml",
|
60
|
+
"test/fixtures/responses/google/missing_address.xml",
|
61
|
+
"test/fixtures/responses/google/only_coordinates.xml",
|
62
|
+
"test/fixtures/responses/google/partial.xml",
|
63
|
+
"test/fixtures/responses/google/server_error.xml",
|
64
|
+
"test/fixtures/responses/google/success.xml",
|
65
|
+
"test/fixtures/responses/google/success_multiple_results.xml",
|
66
|
+
"test/fixtures/responses/google/success_on_options.xml",
|
67
|
+
"test/fixtures/responses/google/unavailable.xml",
|
68
|
+
"test/fixtures/responses/google/unknown_address.xml",
|
69
|
+
"test/fixtures/responses/host_ip/private.txt",
|
70
|
+
"test/fixtures/responses/host_ip/success.txt",
|
71
|
+
"test/fixtures/responses/host_ip/unknown.txt",
|
72
|
+
"test/fixtures/responses/local_search_maps/empty.txt",
|
73
|
+
"test/fixtures/responses/local_search_maps/not_found.txt",
|
74
|
+
"test/fixtures/responses/local_search_maps/success.txt",
|
75
|
+
"test/fixtures/responses/mapquest/multi_result.xml",
|
76
|
+
"test/fixtures/responses/mapquest/success.xml",
|
77
|
+
"test/fixtures/responses/meta_carta/bad_address.xml",
|
78
|
+
"test/fixtures/responses/meta_carta/multiple.xml",
|
79
|
+
"test/fixtures/responses/meta_carta/success.xml",
|
80
|
+
"test/fixtures/responses/multimap/missing_params.xml",
|
81
|
+
"test/fixtures/responses/multimap/no_matches.xml",
|
82
|
+
"test/fixtures/responses/multimap/success.xml",
|
83
|
+
"test/fixtures/responses/postcode_anywhere/badkey.xml",
|
84
|
+
"test/fixtures/responses/postcode_anywhere/canada.xml",
|
85
|
+
"test/fixtures/responses/postcode_anywhere/empty.xml",
|
86
|
+
"test/fixtures/responses/postcode_anywhere/success.xml",
|
87
|
+
"test/fixtures/responses/postcode_anywhere/uk.xml",
|
88
|
+
"test/fixtures/responses/yahoo/success.xml",
|
89
|
+
"test/fixtures/responses/yahoo/unknown_address.xml",
|
90
|
+
"test/mocks/uri.rb",
|
91
|
+
"test/test_helper.rb",
|
92
|
+
"test/unit/graticule/distance_test.rb",
|
93
|
+
"test/unit/graticule/geocoder/geocoder_us_test.rb",
|
94
|
+
"test/unit/graticule/geocoder/geocoders.rb",
|
95
|
+
"test/unit/graticule/geocoder/google_test.rb",
|
96
|
+
"test/unit/graticule/geocoder/host_ip_test.rb",
|
97
|
+
"test/unit/graticule/geocoder/local_search_maps_test.rb",
|
98
|
+
"test/unit/graticule/geocoder/mapquest_test.rb",
|
99
|
+
"test/unit/graticule/geocoder/meta_carta_test.rb",
|
100
|
+
"test/unit/graticule/geocoder/multi_test.rb",
|
101
|
+
"test/unit/graticule/geocoder/multimap_test.rb",
|
102
|
+
"test/unit/graticule/geocoder/postcode_anywhere_test.rb",
|
103
|
+
"test/unit/graticule/geocoder/yahoo_test.rb",
|
104
|
+
"test/unit/graticule/geocoder_test.rb",
|
105
|
+
"test/unit/graticule/location_test.rb"
|
106
|
+
]
|
107
|
+
s.homepage = %q{http://github.com/collectiveidea/graticule}
|
108
|
+
s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
|
109
|
+
s.require_paths = ["lib"]
|
110
|
+
s.rubyforge_project = %q{graticule}
|
111
|
+
s.rubygems_version = %q{1.3.4}
|
112
|
+
s.summary = %q{API for using all the popular geocoding services.}
|
113
|
+
s.test_files = [
|
114
|
+
"test/test_helper.rb",
|
115
|
+
"test/unit/graticule/geocoder_test.rb",
|
116
|
+
"test/unit/graticule/distance_test.rb",
|
117
|
+
"test/unit/graticule/location_test.rb",
|
118
|
+
"test/unit/graticule/geocoder/multimap_test.rb",
|
119
|
+
"test/unit/graticule/geocoder/meta_carta_test.rb",
|
120
|
+
"test/unit/graticule/geocoder/geocoder_us_test.rb",
|
121
|
+
"test/unit/graticule/geocoder/postcode_anywhere_test.rb",
|
122
|
+
"test/unit/graticule/geocoder/google_test.rb",
|
123
|
+
"test/unit/graticule/geocoder/multi_test.rb",
|
124
|
+
"test/unit/graticule/geocoder/mapquest_test.rb",
|
125
|
+
"test/unit/graticule/geocoder/geocoders.rb",
|
126
|
+
"test/unit/graticule/geocoder/yahoo_test.rb",
|
127
|
+
"test/unit/graticule/geocoder/host_ip_test.rb",
|
128
|
+
"test/unit/graticule/geocoder/local_search_maps_test.rb",
|
129
|
+
"test/mocks/uri.rb"
|
130
|
+
]
|
131
|
+
|
132
|
+
if s.respond_to? :specification_version then
|
133
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
134
|
+
s.specification_version = 3
|
135
|
+
|
136
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
137
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
138
|
+
else
|
139
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
140
|
+
end
|
141
|
+
else
|
142
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
143
|
+
end
|
144
|
+
end
|