aub-graticule 0.2.11 → 0.3.0

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.
data/Rakefile CHANGED
@@ -9,19 +9,18 @@ require 'rake/rdoctask'
9
9
  require 'rcov/rcovtask'
10
10
 
11
11
  Jeweler::Tasks.new do |s|
12
- s.name = "graticule"
13
- s.rubyforge_project = "graticule"
12
+ s.name = "aub-graticule"
14
13
  s.author = 'Brandon Keepers'
15
14
  s.email = 'brandon@opensoul.org'
16
15
  s.summary = "API for using all the popular geocoding services."
17
16
  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"
17
+ s.homepage = "http://github.com/aub/graticule"
20
18
  s.has_rdoc = true
21
19
  s.extra_rdoc_files = ["README.txt"]
22
20
  s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
23
21
  s.test_files = Dir['test/**/*.{yml,rb}']
24
22
  end
23
+ Jeweler::GemcutterTasks.new
25
24
 
26
25
  desc 'Default: run unit tests.'
27
26
  task :default => :test
@@ -33,7 +32,7 @@ Rake::TestTask.new(:test) do |t|
33
32
  t.verbose = true
34
33
  end
35
34
 
36
- desc 'Generate documentatio'
35
+ desc 'Generate documentation'
37
36
  Rake::RDocTask.new(:rdoc) do |rdoc|
38
37
  rdoc.rdoc_dir = 'rdoc'
39
38
  rdoc.title = 'Graticule'
@@ -53,28 +52,6 @@ namespace :test do
53
52
  end
54
53
  end
55
54
 
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
55
  namespace :test do
79
56
  namespace :cache do
80
57
  desc 'Cache test responses from all the free geocoders'
@@ -140,4 +117,4 @@ def update_placeholders!(config, thing)
140
117
  config.each do |option, value|
141
118
  thing.gsub!(":#{option}", value) if value.is_a?(String)
142
119
  end
143
- end
120
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.11
1
+ 0.3.0
@@ -0,0 +1,144 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{aub-graticule}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Brandon Keepers"]
12
+ s.date = %q{2010-03-04}
13
+ s.default_executable = %q{geocode}
14
+ 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.}
15
+ s.email = %q{brandon@opensoul.org}
16
+ s.executables = ["geocode"]
17
+ s.extra_rdoc_files = [
18
+ "README.txt"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "CHANGELOG.txt",
23
+ "LICENSE.txt",
24
+ "Manifest.txt",
25
+ "README.txt",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "aub-graticule.gemspec",
29
+ "bin/geocode",
30
+ "graticule.gemspec",
31
+ "init.rb",
32
+ "lib/graticule.rb",
33
+ "lib/graticule/cli.rb",
34
+ "lib/graticule/core_ext.rb",
35
+ "lib/graticule/distance.rb",
36
+ "lib/graticule/distance/haversine.rb",
37
+ "lib/graticule/distance/spherical.rb",
38
+ "lib/graticule/distance/vincenty.rb",
39
+ "lib/graticule/geocoder.rb",
40
+ "lib/graticule/geocoder/base.rb",
41
+ "lib/graticule/geocoder/bogus.rb",
42
+ "lib/graticule/geocoder/geocoder_ca.rb",
43
+ "lib/graticule/geocoder/geocoder_us.rb",
44
+ "lib/graticule/geocoder/google.rb",
45
+ "lib/graticule/geocoder/host_ip.rb",
46
+ "lib/graticule/geocoder/local_search_maps.rb",
47
+ "lib/graticule/geocoder/mapquest.rb",
48
+ "lib/graticule/geocoder/meta_carta.rb",
49
+ "lib/graticule/geocoder/multi.rb",
50
+ "lib/graticule/geocoder/multimap.rb",
51
+ "lib/graticule/geocoder/postcode_anywhere.rb",
52
+ "lib/graticule/geocoder/rest.rb",
53
+ "lib/graticule/geocoder/yahoo.rb",
54
+ "lib/graticule/location.rb",
55
+ "lib/graticule/version.rb",
56
+ "site/index.html",
57
+ "site/plugin.html",
58
+ "site/stylesheets/style.css",
59
+ "test/config.yml.default",
60
+ "test/fixtures/responses/geocoder_us/success.xml",
61
+ "test/fixtures/responses/geocoder_us/unknown.xml",
62
+ "test/fixtures/responses/google/badkey.xml",
63
+ "test/fixtures/responses/google/limit.xml",
64
+ "test/fixtures/responses/google/missing_address.xml",
65
+ "test/fixtures/responses/google/only_coordinates.xml",
66
+ "test/fixtures/responses/google/partial.xml",
67
+ "test/fixtures/responses/google/server_error.xml",
68
+ "test/fixtures/responses/google/success.xml",
69
+ "test/fixtures/responses/google/success_multiple_results.xml",
70
+ "test/fixtures/responses/google/unavailable.xml",
71
+ "test/fixtures/responses/google/unknown_address.xml",
72
+ "test/fixtures/responses/host_ip/private.txt",
73
+ "test/fixtures/responses/host_ip/success.txt",
74
+ "test/fixtures/responses/host_ip/unknown.txt",
75
+ "test/fixtures/responses/local_search_maps/empty.txt",
76
+ "test/fixtures/responses/local_search_maps/not_found.txt",
77
+ "test/fixtures/responses/local_search_maps/success.txt",
78
+ "test/fixtures/responses/mapquest/multi_result.xml",
79
+ "test/fixtures/responses/mapquest/success.xml",
80
+ "test/fixtures/responses/meta_carta/bad_address.xml",
81
+ "test/fixtures/responses/meta_carta/multiple.xml",
82
+ "test/fixtures/responses/meta_carta/success.xml",
83
+ "test/fixtures/responses/multimap/missing_params.xml",
84
+ "test/fixtures/responses/multimap/no_matches.xml",
85
+ "test/fixtures/responses/multimap/success.xml",
86
+ "test/fixtures/responses/postcode_anywhere/badkey.xml",
87
+ "test/fixtures/responses/postcode_anywhere/canada.xml",
88
+ "test/fixtures/responses/postcode_anywhere/empty.xml",
89
+ "test/fixtures/responses/postcode_anywhere/success.xml",
90
+ "test/fixtures/responses/postcode_anywhere/uk.xml",
91
+ "test/fixtures/responses/yahoo/success.xml",
92
+ "test/fixtures/responses/yahoo/unknown_address.xml",
93
+ "test/mocks/uri.rb",
94
+ "test/test_helper.rb",
95
+ "test/unit/graticule/distance_test.rb",
96
+ "test/unit/graticule/geocoder/geocoder_us_test.rb",
97
+ "test/unit/graticule/geocoder/geocoders.rb",
98
+ "test/unit/graticule/geocoder/google_test.rb",
99
+ "test/unit/graticule/geocoder/host_ip_test.rb",
100
+ "test/unit/graticule/geocoder/local_search_maps_test.rb",
101
+ "test/unit/graticule/geocoder/mapquest_test.rb",
102
+ "test/unit/graticule/geocoder/meta_carta_test.rb",
103
+ "test/unit/graticule/geocoder/multi_test.rb",
104
+ "test/unit/graticule/geocoder/multimap_test.rb",
105
+ "test/unit/graticule/geocoder/postcode_anywhere_test.rb",
106
+ "test/unit/graticule/geocoder/yahoo_test.rb",
107
+ "test/unit/graticule/geocoder_test.rb",
108
+ "test/unit/graticule/location_test.rb"
109
+ ]
110
+ s.homepage = %q{http://github.com/aub/graticule}
111
+ s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
112
+ s.require_paths = ["lib"]
113
+ s.rubygems_version = %q{1.3.6}
114
+ s.summary = %q{API for using all the popular geocoding services.}
115
+ s.test_files = [
116
+ "test/mocks/uri.rb",
117
+ "test/test_helper.rb",
118
+ "test/unit/graticule/distance_test.rb",
119
+ "test/unit/graticule/geocoder/geocoder_us_test.rb",
120
+ "test/unit/graticule/geocoder/geocoders.rb",
121
+ "test/unit/graticule/geocoder/google_test.rb",
122
+ "test/unit/graticule/geocoder/host_ip_test.rb",
123
+ "test/unit/graticule/geocoder/local_search_maps_test.rb",
124
+ "test/unit/graticule/geocoder/mapquest_test.rb",
125
+ "test/unit/graticule/geocoder/meta_carta_test.rb",
126
+ "test/unit/graticule/geocoder/multi_test.rb",
127
+ "test/unit/graticule/geocoder/multimap_test.rb",
128
+ "test/unit/graticule/geocoder/postcode_anywhere_test.rb",
129
+ "test/unit/graticule/geocoder/yahoo_test.rb",
130
+ "test/unit/graticule/geocoder_test.rb",
131
+ "test/unit/graticule/location_test.rb"
132
+ ]
133
+
134
+ if s.respond_to? :specification_version then
135
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
136
+ s.specification_version = 3
137
+
138
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
139
+ else
140
+ end
141
+ else
142
+ end
143
+ end
144
+
data/lib/graticule.rb CHANGED
@@ -1,26 +1,33 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
2
 
3
- require 'active_support'
4
-
5
- require 'graticule/version'
6
3
  require 'graticule/core_ext'
7
- require 'graticule/location'
8
4
  require 'graticule/geocoder'
9
- require 'graticule/geocoder/base'
10
- require 'graticule/geocoder/bogus'
11
- require 'graticule/geocoder/rest'
12
- require 'graticule/geocoder/google'
13
- require 'graticule/geocoder/host_ip'
14
- require 'graticule/geocoder/multi'
15
- require 'graticule/geocoder/yahoo'
16
- require 'graticule/geocoder/geocoder_ca'
17
- require 'graticule/geocoder/geocoder_us'
18
- require 'graticule/geocoder/local_search_maps'
19
- require 'graticule/geocoder/meta_carta'
20
- require 'graticule/geocoder/postcode_anywhere'
21
- require 'graticule/geocoder/multimap'
22
- require 'graticule/geocoder/mapquest'
23
- require 'graticule/distance'
24
- require 'graticule/distance/haversine'
25
- require 'graticule/distance/spherical'
26
- require 'graticule/distance/vincenty'
5
+
6
+ module Graticule
7
+ autoload :Version, 'graticule/version'
8
+ autoload :Location, 'graticule/location'
9
+ autoload :Distance, 'graticule/distance'
10
+
11
+ module Geocoder
12
+ autoload :Base, 'graticule/geocoder/base'
13
+ autoload :Bogus, 'graticule/geocoder/bogus'
14
+ autoload :GeocoderCa, 'graticule/geocoder/geocoder_ca'
15
+ autoload :GeocoderUs, 'graticule/geocoder/geocoder_us'
16
+ autoload :Google, 'graticule/geocoder/google'
17
+ autoload :HostIp, 'graticule/geocoder/host_ip'
18
+ autoload :LocalSearchMaps, 'graticule/geocoder/local_search_maps'
19
+ autoload :Mapquest, 'graticule/geocoder/mapquest'
20
+ autoload :MetaCarta, 'graticule/geocoder/meta_carta'
21
+ autoload :Multi, 'graticule/geocoder/multi'
22
+ autoload :Multimap, 'graticule/geocoder/multimap'
23
+ autoload :PostcodeAnywhere, 'graticule/geocoder/postcode_anywhere'
24
+ autoload :Rest, 'graticule/geocoder/rest'
25
+ autoload :Yahoo, 'graticule/geocoder/yahoo'
26
+ end
27
+
28
+ module Distance
29
+ autoload :Haversine, 'graticule/distance/haversine'
30
+ autoload :Spherical, 'graticule/distance/spherical'
31
+ autoload :Vincenty, 'graticule/distance/vincenty'
32
+ end
33
+ end
@@ -12,4 +12,12 @@ module Graticule
12
12
  end
13
13
  end
14
14
 
15
- Numeric.send :include, Graticule::RadiansAndDegrees
15
+ unless Object.respond_to?(:blank?)
16
+ class Object
17
+ def blank?
18
+ respond_to?(:empty?) ? empty? : !self
19
+ end
20
+ end
21
+ end
22
+
23
+ Numeric.send :include, Graticule::RadiansAndDegrees
@@ -8,7 +8,8 @@ module Graticule
8
8
  # See the documentation for your specific geocoder for more information
9
9
  #
10
10
  def self.service(name)
11
- Geocoder.const_get name.to_s.camelize
11
+ clazz_name = name.to_s.gsub(/_(.)/) { $1.upcase }.gsub(/^(.)/) { $1.upcase }
12
+ Geocoder.const_get clazz_name
12
13
  end
13
14
 
14
15
  # Base error class
@@ -18,4 +19,4 @@ module Graticule
18
19
  # Raised when you try to locate an invalid address.
19
20
  class AddressError < Error; end
20
21
 
21
- end
22
+ end
@@ -41,9 +41,10 @@ module Graticule #:nodoc:
41
41
  end
42
42
 
43
43
  def check_error(xml) #:nodoc:
44
- raise AddressError, xml.text if xml.text =~ /couldn't find this address! sorry/
45
- raise Error, xml.text if xml.text =~ /Your browser sent a request that this server could not understand./
46
- raise Error, xml.text if !(xml.text =~ /geo:Point/)
44
+ text = xml.to_s
45
+ raise AddressError, text if text =~ /couldn't find this address! sorry/
46
+ raise Error, text if text =~ /Your browser sent a request that this server could not understand./
47
+ raise Error, text if !(text =~ /geo:Point/)
47
48
  end
48
49
 
49
50
  end
@@ -52,9 +52,15 @@ module Graticule #:nodoc:
52
52
  location = Location.new
53
53
  location.precision = PRECISION[r.attributes['geocodeQuality']] || :unknown
54
54
 
55
- location.street = r.elements['Address/Street'].text.titleize unless r.elements['Address/Street'].nil?
56
- location.locality = r.elements['Address/Areas/Area'].text.titleize unless r.elements['Address/Areas/Area'].nil?
57
- location.region = r.elements['Address/State'].text.titleize unless r.elements['Address/State'].nil?
55
+ location.street = r.elements['Address/Street'].text unless r.elements['Address/Street'].nil?
56
+ location.street.gsub!(/([A-Z])([A-Z]+)/) { "#{$1}#{$2.downcase}" } if location.street
57
+
58
+ location.locality = r.elements['Address/Areas/Area'].text unless r.elements['Address/Areas/Area'].nil?
59
+ location.locality.gsub!(/([A-Z])([A-Z]+)/) { "#{$1}#{$2.downcase}" } if location.locality
60
+
61
+ location.region = r.elements['Address/State'].text unless r.elements['Address/State'].nil?
62
+ location.region.gsub!(/([A-Z])([A-Z]+)/) { "#{$1}#{$2.downcase}" } if location.region
63
+
58
64
  location.postal_code = r.elements['Address/PostalCode'].text unless r.elements['Address/PostalCode'].nil?
59
65
  location.country = r.elements['Address/CountryCode'].text
60
66
 
@@ -55,8 +55,12 @@ module Graticule #:nodoc:
55
55
  location.latitude = r.elements['Latitude'].text.to_f
56
56
  location.longitude = r.elements['Longitude'].text.to_f
57
57
 
58
- location.street = r.elements['Address'].text.titleize unless r.elements['Address'].text.blank?
59
- location.locality = r.elements['City'].text.titleize unless r.elements['City'].text.blank?
58
+ location.street = r.elements['Address'].text
59
+ location.street.gsub!(/([A-Z])([A-Z]+)/) { "#{$1}#{$2.downcase}" } if location.street
60
+
61
+ location.locality = r.elements['City'].text
62
+ location.locality.gsub!(/([A-Z])([A-Z]+)/) { "#{$1}#{$2.downcase}" } if location.locality
63
+
60
64
  location.region = r.elements['State'].text
61
65
  location.postal_code = r.elements['Zip'].text
62
66
  location.country = r.elements['Country'].text
@@ -74,11 +78,8 @@ module Graticule #:nodoc:
74
78
  def make_url(params) #:nodoc:
75
79
  params[:appid] = @appid
76
80
  params[:output] = 'xml'
77
-
78
81
  super params
79
82
  end
80
-
81
83
  end
82
-
83
84
  end
84
85
  end
@@ -22,7 +22,7 @@ module Graticule
22
22
  end
23
23
 
24
24
  def blank?
25
- attributes.except(:precision).empty?
25
+ (attributes.keys - [:precision]).empty?
26
26
  end
27
27
 
28
28
  # Returns an Array with latitude and longitude.
@@ -37,8 +37,8 @@ module Graticule
37
37
  # Calculate the distance to another location. See the various Distance formulas
38
38
  # for more information
39
39
  def distance_to(destination, options = {})
40
- options = {:formula => :haversine, :units => :miles}.merge(options)
41
- "Graticule::Distance::#{options[:formula].to_s.titleize}".constantize.distance(self, destination, options[:units])
40
+ formula = (options[:formula] || :haversine).to_s.gsub(/^(.)/) { $1.upcase }.gsub(/_(.)/) { $1.upcase }
41
+ Distance.const_get(formula).distance(self, destination, options[:units] || :miles)
42
42
  end
43
43
 
44
44
  # Where would I be if I dug through the center of the earth?
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aub-graticule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Brandon Keepers
@@ -9,19 +14,10 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-07-20 00:00:00 -07:00
17
+ date: 2010-03-04 00:00:00 -05:00
13
18
  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:
19
+ dependencies: []
20
+
25
21
  description: Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.
26
22
  email: brandon@opensoul.org
27
23
  executables:
@@ -38,6 +34,7 @@ files:
38
34
  - README.txt
39
35
  - Rakefile
40
36
  - VERSION
37
+ - aub-graticule.gemspec
41
38
  - bin/geocode
42
39
  - graticule.gemspec
43
40
  - init.rb
@@ -118,8 +115,10 @@ files:
118
115
  - test/unit/graticule/geocoder/yahoo_test.rb
119
116
  - test/unit/graticule/geocoder_test.rb
120
117
  - test/unit/graticule/location_test.rb
121
- has_rdoc: false
122
- homepage: http://github.com/collectiveidea/graticule
118
+ has_rdoc: true
119
+ homepage: http://github.com/aub/graticule
120
+ licenses: []
121
+
123
122
  post_install_message:
124
123
  rdoc_options:
125
124
  - --main
@@ -132,18 +131,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
131
  requirements:
133
132
  - - ">="
134
133
  - !ruby/object:Gem::Version
134
+ segments:
135
+ - 0
135
136
  version: "0"
136
- version:
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
+ segments:
142
+ - 0
141
143
  version: "0"
142
- version:
143
144
  requirements: []
144
145
 
145
- rubyforge_project: graticule
146
- rubygems_version: 1.2.0
146
+ rubyforge_project:
147
+ rubygems_version: 1.3.6
147
148
  signing_key:
148
149
  specification_version: 3
149
150
  summary: API for using all the popular geocoding services.