graticule 1.0.0.pre2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/bin/geocode +0 -0
  2. data/lib/graticule.rb +2 -0
  3. data/lib/graticule/geocoder/bogus.rb +1 -1
  4. data/lib/graticule/geocoder/geonames.rb +1 -1
  5. data/lib/graticule/geocoder/google.rb +4 -1
  6. data/lib/graticule/geocoder/host_ip.rb +1 -1
  7. data/lib/graticule/version.rb +3 -0
  8. metadata +73 -131
  9. data/.autotest +0 -13
  10. data/.gitignore +0 -6
  11. data/Rakefile +0 -123
  12. data/VERSION +0 -1
  13. data/graticule.gemspec +0 -199
  14. data/init.rb +0 -2
  15. data/site/index.html +0 -114
  16. data/site/plugin.html +0 -82
  17. data/site/stylesheets/style.css +0 -69
  18. data/test/config.yml.default +0 -33
  19. data/test/fixtures/responses/freethepostcode/not_found.txt +0 -3
  20. data/test/fixtures/responses/freethepostcode/success.txt +0 -2
  21. data/test/fixtures/responses/geocoder_ca/success.xml +0 -12
  22. data/test/fixtures/responses/geocoder_us/success.xml +0 -8
  23. data/test/fixtures/responses/geocoder_us/unknown.xml +0 -1
  24. data/test/fixtures/responses/geonames/missing.xml +0 -4
  25. data/test/fixtures/responses/geonames/success.xml +0 -14
  26. data/test/fixtures/responses/geonames/unknown.xml +0 -4
  27. data/test/fixtures/responses/google/badkey.xml +0 -1
  28. data/test/fixtures/responses/google/limit.xml +0 -10
  29. data/test/fixtures/responses/google/missing_address.xml +0 -1
  30. data/test/fixtures/responses/google/only_coordinates.xml +0 -1
  31. data/test/fixtures/responses/google/partial.xml +0 -16
  32. data/test/fixtures/responses/google/server_error.xml +0 -10
  33. data/test/fixtures/responses/google/success.xml +0 -16
  34. data/test/fixtures/responses/google/success_multiple_results.xml +0 -88
  35. data/test/fixtures/responses/google/unavailable.xml +0 -1
  36. data/test/fixtures/responses/google/unknown_address.xml +0 -8
  37. data/test/fixtures/responses/host_ip/private.txt +0 -4
  38. data/test/fixtures/responses/host_ip/success.txt +0 -4
  39. data/test/fixtures/responses/host_ip/unknown.txt +0 -4
  40. data/test/fixtures/responses/local_search_maps/empty.txt +0 -1
  41. data/test/fixtures/responses/local_search_maps/not_found.txt +0 -1
  42. data/test/fixtures/responses/local_search_maps/success.txt +0 -1
  43. data/test/fixtures/responses/mapquest/multi_result.xml +0 -1
  44. data/test/fixtures/responses/mapquest/success.xml +0 -1
  45. data/test/fixtures/responses/multimap/missing_params.xml +0 -4
  46. data/test/fixtures/responses/multimap/no_matches.xml +0 -4
  47. data/test/fixtures/responses/multimap/success.xml +0 -19
  48. data/test/fixtures/responses/yahoo/success.xml +0 -3
  49. data/test/fixtures/responses/yahoo/unknown_address.xml +0 -6
  50. data/test/graticule/distance_test.rb +0 -58
  51. data/test/graticule/geocoder/freethepostcode_test.rb +0 -36
  52. data/test/graticule/geocoder/geocoder_ca_test.rb +0 -41
  53. data/test/graticule/geocoder/geocoder_us_test.rb +0 -43
  54. data/test/graticule/geocoder/geocoders.rb +0 -55
  55. data/test/graticule/geocoder/geonames_test.rb +0 -48
  56. data/test/graticule/geocoder/google_test.rb +0 -107
  57. data/test/graticule/geocoder/host_ip_test.rb +0 -40
  58. data/test/graticule/geocoder/local_search_maps_test.rb +0 -30
  59. data/test/graticule/geocoder/mapquest_test.rb +0 -49
  60. data/test/graticule/geocoder/multi_test.rb +0 -51
  61. data/test/graticule/geocoder/multimap_test.rb +0 -52
  62. data/test/graticule/geocoder/yahoo_test.rb +0 -49
  63. data/test/graticule/geocoder_test.rb +0 -23
  64. data/test/graticule/location_test.rb +0 -86
  65. data/test/graticule/precision_test.rb +0 -37
  66. data/test/mocks/uri.rb +0 -52
  67. data/test/test_helper.rb +0 -30
File without changes
@@ -1,7 +1,9 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
2
 
3
3
  require 'active_support'
4
+ require 'active_support/core_ext'
4
5
 
6
+ require 'graticule/version'
5
7
  require 'graticule/core_ext'
6
8
  require 'graticule/location'
7
9
  require 'graticule/precision'
@@ -3,7 +3,7 @@ module Graticule #:nodoc:
3
3
  # Bogus geocoder that can be used for test purposes
4
4
  class Bogus
5
5
  # A queue of canned responses
6
- class_inheritable_accessor :responses
6
+ class_attribute :responses
7
7
  self.responses = []
8
8
 
9
9
  # A default location to use if the responses queue is empty
@@ -35,7 +35,7 @@ module Graticule #:nodoc:
35
35
 
36
36
  # Extracts and raises an error from +xml+, if any.
37
37
  def check_error(response) #:nodoc:
38
- if response.status
38
+ if response && response.status
39
39
  case response.status.value
40
40
  when 14 then
41
41
  raise Error, reponse.status.message
@@ -52,7 +52,6 @@ module Graticule #:nodoc:
52
52
  has_one :address, Address
53
53
 
54
54
  attr_reader :longitude, :latitude
55
- delegate :accuracy, :to => :address, :allow_nil => true
56
55
 
57
56
  with_options :deep => true, :namespace => 'urn:oasis:names:tc:ciq:xsdschema:xAL:2.0' do |map|
58
57
  map.element :street, String, :tag => 'ThoroughfareName'
@@ -66,6 +65,10 @@ module Graticule #:nodoc:
66
65
  @longitude, @latitude, _ = coordinates.split(',').map { |v| v.to_f }
67
66
  end
68
67
 
68
+ def accuracy
69
+ address.accuracy if address
70
+ end
71
+
69
72
  def precision
70
73
  PRECISION[accuracy] || :unknown
71
74
  end
@@ -22,7 +22,7 @@ module Graticule #:nodoc:
22
22
  end
23
23
 
24
24
  def parse_response(response) #:nodoc:
25
- returning Location.new do |location|
25
+ Location.new.tap do |location|
26
26
  location.latitude = response['Latitude']
27
27
  location.longitude = response['Longitude']
28
28
  location.locality, location.region = response['City'].split(', ')
@@ -0,0 +1,3 @@
1
+ module Graticule
2
+ VERSION = '2.0.0' unless defined?(::Graticule::VERSION)
3
+ end
metadata CHANGED
@@ -1,37 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graticule
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre2
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 0
9
+ version: 2.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Brandon Keepers
13
+ - Daniel Morrison
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-04 00:00:00 -05:00
18
+ date: 2010-10-01 00:00:00 -04:00
13
19
  default_executable: geocode
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ requirement: *id001
16
32
  name: activesupport
33
+ - !ruby/object:Gem::Dependency
34
+ prerelease: false
17
35
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
20
37
  requirements:
21
38
  - - ">="
22
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
23
42
  version: "0"
24
- version:
43
+ requirement: *id002
44
+ name: i18n
25
45
  - !ruby/object:Gem::Dependency
26
- name: happymapper
46
+ prerelease: false
27
47
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
48
+ version_requirements: &id003 !ruby/object:Gem::Requirement
30
49
  requirements:
31
50
  - - ">="
32
51
  - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ - 3
55
+ - 0
33
56
  version: 0.3.0
34
- version:
57
+ requirement: *id003
58
+ name: happymapper
59
+ - !ruby/object:Gem::Dependency
60
+ prerelease: false
61
+ type: :development
62
+ version_requirements: &id004 !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirement: *id004
70
+ name: mocha
71
+ - !ruby/object:Gem::Dependency
72
+ prerelease: false
73
+ type: :development
74
+ version_requirements: &id005 !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirement: *id005
82
+ name: rcov
35
83
  description: Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.
36
84
  email: brandon@opensoul.org
37
85
  executables:
@@ -41,24 +89,13 @@ extensions: []
41
89
  extra_rdoc_files:
42
90
  - README.txt
43
91
  files:
44
- - .autotest
45
- - .gitignore
46
- - CHANGELOG.txt
47
- - LICENSE.txt
48
- - README.txt
49
- - Rakefile
50
- - VERSION
51
92
  - bin/geocode
52
- - graticule.gemspec
53
- - init.rb
54
- - lib/graticule.rb
55
93
  - lib/graticule/cli.rb
56
94
  - lib/graticule/core_ext.rb
57
- - lib/graticule/distance.rb
58
95
  - lib/graticule/distance/haversine.rb
59
96
  - lib/graticule/distance/spherical.rb
60
97
  - lib/graticule/distance/vincenty.rb
61
- - lib/graticule/geocoder.rb
98
+ - lib/graticule/distance.rb
62
99
  - lib/graticule/geocoder/base.rb
63
100
  - lib/graticule/geocoder/bogus.rb
64
101
  - lib/graticule/geocoder/freethepostcode.rb
@@ -72,61 +109,14 @@ files:
72
109
  - lib/graticule/geocoder/multi.rb
73
110
  - lib/graticule/geocoder/multimap.rb
74
111
  - lib/graticule/geocoder/yahoo.rb
112
+ - lib/graticule/geocoder.rb
75
113
  - lib/graticule/location.rb
76
114
  - lib/graticule/precision.rb
77
- - site/index.html
78
- - site/plugin.html
79
- - site/stylesheets/style.css
80
- - test/config.yml.default
81
- - test/fixtures/responses/freethepostcode/not_found.txt
82
- - test/fixtures/responses/freethepostcode/success.txt
83
- - test/fixtures/responses/geocoder_ca/success.xml
84
- - test/fixtures/responses/geocoder_us/success.xml
85
- - test/fixtures/responses/geocoder_us/unknown.xml
86
- - test/fixtures/responses/geonames/missing.xml
87
- - test/fixtures/responses/geonames/success.xml
88
- - test/fixtures/responses/geonames/unknown.xml
89
- - test/fixtures/responses/google/badkey.xml
90
- - test/fixtures/responses/google/limit.xml
91
- - test/fixtures/responses/google/missing_address.xml
92
- - test/fixtures/responses/google/only_coordinates.xml
93
- - test/fixtures/responses/google/partial.xml
94
- - test/fixtures/responses/google/server_error.xml
95
- - test/fixtures/responses/google/success.xml
96
- - test/fixtures/responses/google/success_multiple_results.xml
97
- - test/fixtures/responses/google/unavailable.xml
98
- - test/fixtures/responses/google/unknown_address.xml
99
- - test/fixtures/responses/host_ip/private.txt
100
- - test/fixtures/responses/host_ip/success.txt
101
- - test/fixtures/responses/host_ip/unknown.txt
102
- - test/fixtures/responses/local_search_maps/empty.txt
103
- - test/fixtures/responses/local_search_maps/not_found.txt
104
- - test/fixtures/responses/local_search_maps/success.txt
105
- - test/fixtures/responses/mapquest/multi_result.xml
106
- - test/fixtures/responses/mapquest/success.xml
107
- - test/fixtures/responses/multimap/missing_params.xml
108
- - test/fixtures/responses/multimap/no_matches.xml
109
- - test/fixtures/responses/multimap/success.xml
110
- - test/fixtures/responses/yahoo/success.xml
111
- - test/fixtures/responses/yahoo/unknown_address.xml
112
- - test/graticule/distance_test.rb
113
- - test/graticule/geocoder/freethepostcode_test.rb
114
- - test/graticule/geocoder/geocoder_ca_test.rb
115
- - test/graticule/geocoder/geocoder_us_test.rb
116
- - test/graticule/geocoder/geocoders.rb
117
- - test/graticule/geocoder/geonames_test.rb
118
- - test/graticule/geocoder/google_test.rb
119
- - test/graticule/geocoder/host_ip_test.rb
120
- - test/graticule/geocoder/local_search_maps_test.rb
121
- - test/graticule/geocoder/mapquest_test.rb
122
- - test/graticule/geocoder/multi_test.rb
123
- - test/graticule/geocoder/multimap_test.rb
124
- - test/graticule/geocoder/yahoo_test.rb
125
- - test/graticule/geocoder_test.rb
126
- - test/graticule/location_test.rb
127
- - test/graticule/precision_test.rb
128
- - test/mocks/uri.rb
129
- - test/test_helper.rb
115
+ - lib/graticule/version.rb
116
+ - lib/graticule.rb
117
+ - CHANGELOG.txt
118
+ - LICENSE.txt
119
+ - README.txt
130
120
  has_rdoc: true
131
121
  homepage: http://github.com/collectiveidea/graticule
132
122
  licenses: []
@@ -143,70 +133,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
133
  requirements:
144
134
  - - ">="
145
135
  - !ruby/object:Gem::Version
136
+ segments:
137
+ - 0
146
138
  version: "0"
147
- version:
148
139
  required_rubygems_version: !ruby/object:Gem::Requirement
149
140
  requirements:
150
- - - ">"
141
+ - - ">="
151
142
  - !ruby/object:Gem::Version
152
- version: 1.3.1
153
- version:
143
+ segments:
144
+ - 0
145
+ version: "0"
154
146
  requirements: []
155
147
 
156
148
  rubyforge_project: graticule
157
- rubygems_version: 1.3.5
149
+ rubygems_version: 1.3.6
158
150
  signing_key:
159
151
  specification_version: 3
160
152
  summary: API for using all the popular geocoding services.
161
- test_files:
162
- - test/config.yml
163
- - test/config.yml.default
164
- - test/fixtures/responses/freethepostcode/not_found.txt
165
- - test/fixtures/responses/freethepostcode/success.txt
166
- - test/fixtures/responses/geocoder_ca/success.xml
167
- - test/fixtures/responses/geocoder_us/success.xml
168
- - test/fixtures/responses/geocoder_us/unknown.xml
169
- - test/fixtures/responses/geonames/missing.xml
170
- - test/fixtures/responses/geonames/success.xml
171
- - test/fixtures/responses/geonames/unknown.xml
172
- - test/fixtures/responses/google/badkey.xml
173
- - test/fixtures/responses/google/limit.xml
174
- - test/fixtures/responses/google/missing_address.xml
175
- - test/fixtures/responses/google/only_coordinates.xml
176
- - test/fixtures/responses/google/partial.xml
177
- - test/fixtures/responses/google/server_error.xml
178
- - test/fixtures/responses/google/success.xml
179
- - test/fixtures/responses/google/success_multiple_results.xml
180
- - test/fixtures/responses/google/unavailable.xml
181
- - test/fixtures/responses/google/unknown_address.xml
182
- - test/fixtures/responses/host_ip/private.txt
183
- - test/fixtures/responses/host_ip/success.txt
184
- - test/fixtures/responses/host_ip/unknown.txt
185
- - test/fixtures/responses/local_search_maps/empty.txt
186
- - test/fixtures/responses/local_search_maps/not_found.txt
187
- - test/fixtures/responses/local_search_maps/success.txt
188
- - test/fixtures/responses/mapquest/multi_result.xml
189
- - test/fixtures/responses/mapquest/success.xml
190
- - test/fixtures/responses/multimap/missing_params.xml
191
- - test/fixtures/responses/multimap/no_matches.xml
192
- - test/fixtures/responses/multimap/success.xml
193
- - test/fixtures/responses/yahoo/success.xml
194
- - test/fixtures/responses/yahoo/unknown_address.xml
195
- - test/graticule/distance_test.rb
196
- - test/graticule/geocoder/freethepostcode_test.rb
197
- - test/graticule/geocoder/geocoder_ca_test.rb
198
- - test/graticule/geocoder/geocoder_us_test.rb
199
- - test/graticule/geocoder/geocoders.rb
200
- - test/graticule/geocoder/geonames_test.rb
201
- - test/graticule/geocoder/google_test.rb
202
- - test/graticule/geocoder/host_ip_test.rb
203
- - test/graticule/geocoder/local_search_maps_test.rb
204
- - test/graticule/geocoder/mapquest_test.rb
205
- - test/graticule/geocoder/multi_test.rb
206
- - test/graticule/geocoder/multimap_test.rb
207
- - test/graticule/geocoder/yahoo_test.rb
208
- - test/graticule/geocoder_test.rb
209
- - test/graticule/location_test.rb
210
- - test/graticule/precision_test.rb
211
- - test/mocks/uri.rb
212
- - test/test_helper.rb
153
+ test_files: []
154
+
data/.autotest DELETED
@@ -1,13 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- at.clear_mappings
3
-
4
- at.add_mapping %r%^lib/(.*)\.rb$% do |_, m|
5
- at.files_matching %r%^test/#{m[1]}_test.rb$%
6
- end
7
-
8
- at.add_mapping(%r%^test/.*\.rb$%) {|filename, _| filename }
9
-
10
- at.add_mapping %r%^test/fixtures/(.*)s.yml% do |_, _|
11
- at.files_matching %r%^test/.*\.rb$%
12
- end
13
- end
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- test/config.yml
2
- *.gem
3
- pkg
4
- coverage
5
- rdoc
6
- .DS_Store
data/Rakefile DELETED
@@ -1,123 +0,0 @@
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 'rubygems'
8
- require 'activesupport'
9
- require 'rake/testtask'
10
- require 'rake/rdoctask'
11
- require 'rcov/rcovtask'
12
-
13
- Jeweler::Tasks.new do |s|
14
- s.name = "graticule"
15
- s.rubyforge_project = "graticule"
16
- s.author = 'Brandon Keepers'
17
- s.email = 'brandon@opensoul.org'
18
- s.summary = "API for using all the popular geocoding services."
19
- s.description = 'Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.'
20
- s.homepage = "http://github.com/collectiveidea/graticule"
21
- s.add_dependency "activesupport"
22
- s.add_dependency 'happymapper', '>=0.3.0'
23
- s.has_rdoc = true
24
- s.extra_rdoc_files = ["README.txt"]
25
- s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
26
- s.test_files = Dir['test/**/*']
27
- end
28
-
29
- desc 'Default: run unit tests.'
30
- task :default => :test
31
-
32
- desc 'Run the unit tests'
33
- Rake::TestTask.new(:test) do |t|
34
- t.libs << 'lib' << 'test'
35
- t.pattern = 'test/**/*_test.rb'
36
- t.verbose = true
37
- end
38
-
39
- desc 'Generate documentatio'
40
- Rake::RDocTask.new(:rdoc) do |rdoc|
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = 'Graticule'
43
- rdoc.options << '--line-numbers' << '--inline-source'
44
- rdoc.rdoc_files.include('README.txt')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
47
-
48
- namespace :test do
49
- desc "just rcov minus html output"
50
- Rcov::RcovTask.new(:coverage) do |t|
51
- # t.libs << 'test'
52
- t.test_files = FileList['test/**/*_test.rb']
53
- t.output_dir = 'coverage'
54
- t.verbose = true
55
- t.rcov_opts = %w(--exclude test,/usr/lib/ruby,/Library/Ruby,$HOME/.gem --sort coverage)
56
- end
57
- end
58
-
59
- require 'rake/contrib/sshpublisher'
60
- namespace :rubyforge do
61
-
62
- desc "Release gem and RDoc documentation to RubyForge"
63
- task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
64
-
65
- namespace :release do
66
- desc "Publish RDoc to RubyForge."
67
- task :docs => [:rdoc] do
68
- config = YAML.load(
69
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
70
- )
71
-
72
- host = "#{config['username']}@rubyforge.org"
73
- remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
74
- local_dir = 'rdoc'
75
-
76
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
77
- end
78
- end
79
- end
80
-
81
- require 'active_support'
82
- require 'net/http'
83
- require 'uri'
84
- RESPONSES_PATH = File.dirname(__FILE__) + '/test/fixtures/responses'
85
-
86
- def cache_responses(service)
87
- test_config[service.to_s]['responses'].each do |file,url|
88
- File.open("#{RESPONSES_PATH}/#{service}/#{file}", 'w') do |f|
89
- f.puts Net::HTTP.get(URI.parse(url))
90
- end
91
- end
92
- end
93
-
94
- def test_config
95
- file = File.dirname(__FILE__) + '/test/config.yml'
96
- raise "Copy config.yml.default to config.yml and set the API keys" unless File.exists?(file)
97
- @test_config ||= returning(YAML.load(File.read(file))) do |config|
98
- config.each do |service,values|
99
- values['responses'].each {|file,url| update_placeholders!(values, url) }
100
- end
101
- end
102
- end
103
-
104
- def update_placeholders!(config, thing)
105
- config.each do |option, value|
106
- thing.gsub!(":#{option}", value) if value.is_a?(String)
107
- end
108
- end
109
-
110
- namespace :test do
111
- namespace :cache do
112
- desc 'Cache test responses from all the geocoders'
113
- task :all => test_config.keys
114
-
115
- test_config.keys.each do |service|
116
- desc "Cache test responses for #{service}"
117
- task service do
118
- cache_responses(service)
119
- end
120
- end
121
- end
122
- end
123
-