geocoder 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of geocoder might be problematic. Click here for more details.

data/CHANGELOG.rdoc CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Per-release changes to Geocoder.
4
4
 
5
+ == 0.9.10 (2011 Mar 9)
6
+
7
+ * Fix broken scopes (github.com/mikepinde).
8
+ * Fix broken Ruby 1.9 and JRuby compatibility (don't require json gem).
9
+
5
10
  == 0.9.9 (2011 Mar 9)
6
11
 
7
12
  * Add support for IP address geocoding via FreeGeoIp.net.
data/README.rdoc CHANGED
@@ -5,6 +5,8 @@ Geocoder is a complete geocoding solution for Ruby. With Rails it adds object ge
5
5
 
6
6
  == Compatibility
7
7
 
8
+ Geocoder has been successfully tested with Ruby (MRI) 1.8.7, 1.9.2, and JRuby 1.5.3.
9
+
8
10
  Geocoder is compatible with Rails 3. If you need to use it with Rails 2 please see the <tt>rails2</tt> branch (no longer maintained, limited feature set).
9
11
 
10
12
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.9
1
+ 0.9.10
data/lib/geocoder.rb CHANGED
@@ -68,6 +68,10 @@ module Geocoder
68
68
  name = name.to_s
69
69
  require "geocoder/lookups/#{name}"
70
70
  eval("Geocoder::Lookup::#{name[0...1].upcase + name[1..-1]}.new")
71
+ else
72
+ valids = valid_lookups.map{ |l| ":#{l}" }.join(", ")
73
+ raise ConfigurationError, "Please specify a valid lookup for Geocoder " +
74
+ "(#{name.inspect} is not one of: #{valids})."
71
75
  end
72
76
  end
73
77
 
@@ -1,9 +1,9 @@
1
1
  require 'net/http'
2
- unless defined? ActiveSupport::JSON
2
+ unless defined?(ActiveSupport::JSON)
3
3
  begin
4
4
  require 'json'
5
5
  rescue LoadError
6
- raise LoadError, "Please install the json gem to parse geocoder results."
6
+ raise LoadError, "Please install the 'json' or 'json_pure' gem to parse geocoder results."
7
7
  end
8
8
  end
9
9
 
@@ -67,17 +67,14 @@ module Geocoder
67
67
  # Parses a raw search result (returns hash or array).
68
68
  #
69
69
  def parse_raw_data(raw_data)
70
- if defined?(JSON) and defined?(JSON.parse)
70
+ if defined?(ActiveSupport::JSON)
71
+ ActiveSupport::JSON.decode(raw_data)
72
+ else
71
73
  begin
72
74
  JSON.parse(raw_data)
73
75
  rescue
74
76
  warn "Geocoding API's response was not valid JSON."
75
77
  end
76
- elsif defined?(ActiveSupport::JSON)
77
- ActiveSupport::JSON.decode(raw_data)
78
- else
79
- raise Geocoder::Error, "No JSON-parsing library found. " +
80
- "Please install either the 'json' or 'activesupport' gem."
81
78
  end
82
79
  end
83
80
 
@@ -17,14 +17,14 @@ module Geocoder::Orm
17
17
  base.class_eval do
18
18
 
19
19
  # scope: geocoded objects
20
- scope :geocoded,
21
- :conditions => "#{geocoder_options[:latitude]} IS NOT NULL " +
22
- "AND #{geocoder_options[:longitude]} IS NOT NULL"
20
+ scope :geocoded, lambda {
21
+ {:conditions => "#{geocoder_options[:latitude]} IS NOT NULL " +
22
+ "AND #{geocoder_options[:longitude]} IS NOT NULL"}}
23
23
 
24
24
  # scope: not-geocoded objects
25
- scope :not_geocoded,
26
- :conditions => "#{geocoder_options[:latitude]} IS NULL " +
27
- "OR #{geocoder_options[:longitude]} IS NULL"
25
+ scope :not_geocoded, lambda {
26
+ {:conditions => "#{geocoder_options[:latitude]} IS NULL " +
27
+ "OR #{geocoder_options[:longitude]} IS NULL"}}
28
28
 
29
29
  ##
30
30
  # Find all objects within a radius (in miles) of the given location
@@ -7,6 +7,16 @@ class GeocoderTest < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
 
10
+ # --- configuration ---
11
+ #
12
+ def test_exception_raised_on_bad_lookup_config
13
+ Geocoder::Configuration.lookup = :stoopid
14
+ assert_raises Geocoder::ConfigurationError do
15
+ Geocoder.search "something dumb"
16
+ end
17
+ end
18
+
19
+
10
20
  # --- sanity checks ---
11
21
 
12
22
  def test_distance_between
metadata CHANGED
@@ -1,42 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
5
4
  prerelease: false
6
5
  segments:
7
- - 0
8
- - 9
9
- - 9
10
- version: 0.9.9
6
+ - 0
7
+ - 9
8
+ - 10
9
+ version: 0.9.10
11
10
  platform: ruby
12
11
  authors:
13
- - Alex Reisner
12
+ - Alex Reisner
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
17
  date: 2011-03-09 00:00:00 -05:00
19
18
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: json
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
34
- version: 1.0.0
35
- type: :runtime
36
- version_requirements: *id001
19
+ dependencies: []
20
+
37
21
  description: Provides object geocoding (by street or IP address), reverse geocoding (coordinates to street address), and distance calculations for geocoded objects. Designed for Rails but works with other frameworks too.
38
22
  email:
39
- - alex@alexreisner.com
23
+ - alex@alexreisner.com
40
24
  executables: []
41
25
 
42
26
  extensions: []
@@ -44,38 +28,38 @@ extensions: []
44
28
  extra_rdoc_files: []
45
29
 
46
30
  files:
47
- - .gitignore
48
- - CHANGELOG.rdoc
49
- - LICENSE
50
- - README.rdoc
51
- - Rakefile
52
- - VERSION
53
- - lib/geocoder.rb
54
- - lib/geocoder/calculations.rb
55
- - lib/geocoder/configuration.rb
56
- - lib/geocoder/lookups/base.rb
57
- - lib/geocoder/lookups/freegeoip.rb
58
- - lib/geocoder/lookups/google.rb
59
- - lib/geocoder/lookups/yahoo.rb
60
- - lib/geocoder/orms/active_record.rb
61
- - lib/geocoder/orms/active_record_legacy.rb
62
- - lib/geocoder/orms/base.rb
63
- - lib/geocoder/railtie.rb
64
- - lib/geocoder/request.rb
65
- - lib/geocoder/results/base.rb
66
- - lib/geocoder/results/freegeoip.rb
67
- - lib/geocoder/results/google.rb
68
- - lib/geocoder/results/yahoo.rb
69
- - lib/tasks/geocoder.rake
70
- - test/fixtures/freegeoip_74_200_247_59.json
71
- - test/fixtures/google_garbage.json
72
- - test/fixtures/google_madison_square_garden.json
73
- - test/fixtures/google_no_results.json
74
- - test/fixtures/yahoo_garbage.json
75
- - test/fixtures/yahoo_madison_square_garden.json
76
- - test/fixtures/yahoo_no_results.json
77
- - test/geocoder_test.rb
78
- - test/test_helper.rb
31
+ - .gitignore
32
+ - CHANGELOG.rdoc
33
+ - LICENSE
34
+ - README.rdoc
35
+ - Rakefile
36
+ - VERSION
37
+ - lib/geocoder.rb
38
+ - lib/geocoder/calculations.rb
39
+ - lib/geocoder/configuration.rb
40
+ - lib/geocoder/lookups/base.rb
41
+ - lib/geocoder/lookups/freegeoip.rb
42
+ - lib/geocoder/lookups/google.rb
43
+ - lib/geocoder/lookups/yahoo.rb
44
+ - lib/geocoder/orms/active_record.rb
45
+ - lib/geocoder/orms/active_record_legacy.rb
46
+ - lib/geocoder/orms/base.rb
47
+ - lib/geocoder/railtie.rb
48
+ - lib/geocoder/request.rb
49
+ - lib/geocoder/results/base.rb
50
+ - lib/geocoder/results/freegeoip.rb
51
+ - lib/geocoder/results/google.rb
52
+ - lib/geocoder/results/yahoo.rb
53
+ - lib/tasks/geocoder.rake
54
+ - test/fixtures/freegeoip_74_200_247_59.json
55
+ - test/fixtures/google_garbage.json
56
+ - test/fixtures/google_madison_square_garden.json
57
+ - test/fixtures/google_no_results.json
58
+ - test/fixtures/yahoo_garbage.json
59
+ - test/fixtures/yahoo_madison_square_garden.json
60
+ - test/fixtures/yahoo_no_results.json
61
+ - test/geocoder_test.rb
62
+ - test/test_helper.rb
79
63
  has_rdoc: true
80
64
  homepage: http://github.com/alexreisner/geocoder
81
65
  licenses: []
@@ -84,29 +68,25 @@ post_install_message:
84
68
  rdoc_options: []
85
69
 
86
70
  require_paths:
87
- - lib
71
+ - lib
88
72
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
73
  requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- hash: 3
94
- segments:
95
- - 0
96
- version: "0"
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ segments:
77
+ - 0
78
+ version: "0"
97
79
  required_rubygems_version: !ruby/object:Gem::Requirement
98
- none: false
99
80
  requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
106
86
  requirements: []
107
87
 
108
88
  rubyforge_project:
109
- rubygems_version: 1.3.7
89
+ rubygems_version: 1.3.6
110
90
  signing_key:
111
91
  specification_version: 3
112
92
  summary: Complete geocoding solution for Ruby.