rails-geocoder 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -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
@@ -69,6 +69,10 @@ module Geocoder
69
69
  name = name.to_s
70
70
  require "geocoder/lookups/#{name}"
71
71
  eval("Geocoder::Lookup::#{name[0...1].upcase + name[1..-1]}.new")
72
+ else
73
+ valids = valid_lookups.map{ |l| ":#{l}" }.join(", ")
74
+ raise ConfigurationError, "Please specify a valid lookup for Geocoder " +
75
+ "(#{name.inspect} is not one of: #{valids})."
72
76
  end
73
77
  end
74
78
 
@@ -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
@@ -11,5 +11,4 @@ Gem::Specification.new do |s|
11
11
  s.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."
12
12
  s.files = `git ls-files`.split("\n") - %w[geocoder.gemspec Gemfile init.rb]
13
13
  s.require_paths = ["lib"]
14
- s.add_dependency 'json', '>= 1.0.0'
15
14
  end
@@ -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: rails-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,39 +28,39 @@ 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
- - rails-geocoder.gemspec
71
- - test/fixtures/freegeoip_74_200_247_59.json
72
- - test/fixtures/google_garbage.json
73
- - test/fixtures/google_madison_square_garden.json
74
- - test/fixtures/google_no_results.json
75
- - test/fixtures/yahoo_garbage.json
76
- - test/fixtures/yahoo_madison_square_garden.json
77
- - test/fixtures/yahoo_no_results.json
78
- - test/geocoder_test.rb
79
- - 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
+ - rails-geocoder.gemspec
55
+ - test/fixtures/freegeoip_74_200_247_59.json
56
+ - test/fixtures/google_garbage.json
57
+ - test/fixtures/google_madison_square_garden.json
58
+ - test/fixtures/google_no_results.json
59
+ - test/fixtures/yahoo_garbage.json
60
+ - test/fixtures/yahoo_madison_square_garden.json
61
+ - test/fixtures/yahoo_no_results.json
62
+ - test/geocoder_test.rb
63
+ - test/test_helper.rb
80
64
  has_rdoc: true
81
65
  homepage: http://github.com/alexreisner/geocoder
82
66
  licenses: []
@@ -85,29 +69,25 @@ post_install_message:
85
69
  rdoc_options: []
86
70
 
87
71
  require_paths:
88
- - lib
72
+ - lib
89
73
  required_ruby_version: !ruby/object:Gem::Requirement
90
- none: false
91
74
  requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
98
80
  required_rubygems_version: !ruby/object:Gem::Requirement
99
- none: false
100
81
  requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
107
87
  requirements: []
108
88
 
109
89
  rubyforge_project:
110
- rubygems_version: 1.3.7
90
+ rubygems_version: 1.3.6
111
91
  signing_key:
112
92
  specification_version: 3
113
93
  summary: Complete geocoding solution for Ruby.