Permalink
Browse files

Merge branch 'master' of github.com:alexreisner/geocoder

Conflicts:
	lib/geocoder/lookups/maxmind_local.rb
  • Loading branch information...
2 parents 5699eeb + 3c0859c commit f651b827f6d1f6bfffaba183ed126088e48dc077 @alexreisner alexreisner committed Feb 24, 2014
View
@@ -49,7 +49,8 @@ def expire(url)
private # ----------------------------------------------------------------
- attr_reader :prefix, :store
+ def prefix; @prefix; end
+ def store; @store; end
##
# Cache key for a given URL.
@@ -63,7 +64,7 @@ def key_for(url)
# that have non-nil values.
#
def keys
- store.keys.select{ |k| k.match /^#{prefix}/ and interpret(store[k]) }
+ store.keys.select{ |k| k.match(/^#{prefix}/) and interpret(store[k]) }
end
##
@@ -15,6 +15,9 @@ module Geocoder
module Lookup
class Base
+ def initialize
+ @cache = nil
+ end
##
# Human-readable name of the geocoding API.
@@ -24,7 +24,7 @@ def results(query)
end
def query_url_params(query)
- params = {
+ {
:query => query.sanitized_text,
:return_location => true,
:return_geometry => false
@@ -8,7 +8,7 @@ def initialize
begin
gem = RUBY_PLATFORM == 'java' ? 'jgeoip' : 'geoip'
require gem
- rescue LoadError => e
+ rescue LoadError
raise 'Could not load geoip dependency. To use MaxMind Local lookup you must add the #{gem} gem to your Gemfile or have it installed in your system.'
end
super
@@ -50,7 +50,7 @@ def results(query)
# to warning message.
#
def parse_raw_data(raw_data)
- if raw_data.match /^<\?xml/
+ if raw_data.match(/^<\?xml/)
if raw_data.include?("Rate Limit Exceeded")
raise_error(Geocoder::OverQueryLimitError) || warn("Over API query limit.")
elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i
@@ -1,5 +1,3 @@
-require 'geocoder'
-
module Geocoder
##
@@ -29,7 +27,7 @@ def reverse_geocoded_by
private # ----------------------------------------------------------------
def geocoder_init(options)
- unless @geocoder_options
+ unless defined?(@geocoder_options)
@geocoder_options = {}
require "geocoder/stores/#{geocoder_file_name}"
include Geocoder::Store.const_get(geocoder_module_name)
@@ -39,4 +37,3 @@ def geocoder_init(options)
end
end
end
-
View
@@ -1,4 +1,3 @@
-require 'geocoder'
require 'geocoder/models/active_record'
module Geocoder
View
@@ -1,5 +1,3 @@
-require 'geocoder'
-
module Geocoder
module Request
@@ -5,7 +5,10 @@ module Result
class Test < Base
def self.add_result_attribute(attr)
- return if respond_to?(attr.to_sym)
+ begin
+ remove_method(attr) if method_defined?(attr)
+ rescue NameError # method defined on superclass
+ end
define_method(attr) do
@data[attr.to_s] || @data[attr.to_sym]
@@ -219,7 +219,7 @@ def add_exclude_condition(conditions, exclude)
end
def using_sqlite?
- connection.adapter_name.match /sqlite/i
+ connection.adapter_name.match(/sqlite/i)
end
##

0 comments on commit f651b82

Please sign in to comment.