Skip to content

Commit

Permalink
Merge pull request alexreisner#608 from exviva/fix_warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
alexreisner committed Feb 24, 2014
2 parents 2203be0 + 11f515c commit 3c0859c
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions lib/geocoder/cache.rb
Expand Up @@ -49,7 +49,8 @@ def expire(url)


private # ---------------------------------------------------------------- private # ----------------------------------------------------------------


attr_reader :prefix, :store def prefix; @prefix; end
def store; @store; end


## ##
# Cache key for a given URL. # Cache key for a given URL.
Expand All @@ -63,7 +64,7 @@ def key_for(url)
# that have non-nil values. # that have non-nil values.
# #
def keys 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 end


## ##
Expand Down
3 changes: 3 additions & 0 deletions lib/geocoder/lookups/base.rb
Expand Up @@ -15,6 +15,9 @@ module Geocoder
module Lookup module Lookup


class Base class Base
def initialize
@cache = nil
end


## ##
# Human-readable name of the geocoding API. # Human-readable name of the geocoding API.
Expand Down
2 changes: 1 addition & 1 deletion lib/geocoder/lookups/cloudmade.rb
Expand Up @@ -24,7 +24,7 @@ def results(query)
end end


def query_url_params(query) def query_url_params(query)
params = { {
:query => query.sanitized_text, :query => query.sanitized_text,
:return_location => true, :return_location => true,
:return_geometry => false :return_geometry => false
Expand Down
4 changes: 2 additions & 2 deletions lib/geocoder/lookups/maxmind_local.rb
Expand Up @@ -7,7 +7,7 @@ class MaxmindLocal < Base
def initialize def initialize
begin begin
require 'geoip' require 'geoip'
rescue LoadError => e rescue LoadError
raise 'Could not load geoip dependency. To use MaxMind Local lookup you must add geoip gem to your Gemfile or have it installed in your system.' raise 'Could not load geoip dependency. To use MaxMind Local lookup you must add geoip gem to your Gemfile or have it installed in your system.'
end end


Expand Down Expand Up @@ -38,4 +38,4 @@ def results(query)
result.nil? ? [] : [result.to_hash] result.nil? ? [] : [result.to_hash]
end end
end end
end end
2 changes: 1 addition & 1 deletion lib/geocoder/lookups/yahoo.rb
Expand Up @@ -50,7 +50,7 @@ def results(query)
# to warning message. # to warning message.
# #
def parse_raw_data(raw_data) def parse_raw_data(raw_data)
if raw_data.match /^<\?xml/ if raw_data.match(/^<\?xml/)
if raw_data.include?("Rate Limit Exceeded") if raw_data.include?("Rate Limit Exceeded")
raise_error(Geocoder::OverQueryLimitError) || warn("Over API query limit.") raise_error(Geocoder::OverQueryLimitError) || warn("Over API query limit.")
elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i
Expand Down
5 changes: 1 addition & 4 deletions lib/geocoder/models/base.rb
@@ -1,5 +1,3 @@
require 'geocoder'

module Geocoder module Geocoder


## ##
Expand Down Expand Up @@ -29,7 +27,7 @@ def reverse_geocoded_by
private # ---------------------------------------------------------------- private # ----------------------------------------------------------------


def geocoder_init(options) def geocoder_init(options)
unless @geocoder_options unless defined?(@geocoder_options)
@geocoder_options = {} @geocoder_options = {}
require "geocoder/stores/#{geocoder_file_name}" require "geocoder/stores/#{geocoder_file_name}"
include Geocoder::Store.const_get(geocoder_module_name) include Geocoder::Store.const_get(geocoder_module_name)
Expand All @@ -39,4 +37,3 @@ def geocoder_init(options)
end end
end end
end end

1 change: 0 additions & 1 deletion lib/geocoder/railtie.rb
@@ -1,4 +1,3 @@
require 'geocoder'
require 'geocoder/models/active_record' require 'geocoder/models/active_record'


module Geocoder module Geocoder
Expand Down
2 changes: 0 additions & 2 deletions lib/geocoder/request.rb
@@ -1,5 +1,3 @@
require 'geocoder'

module Geocoder module Geocoder
module Request module Request


Expand Down
5 changes: 4 additions & 1 deletion lib/geocoder/results/test.rb
Expand Up @@ -5,7 +5,10 @@ module Result
class Test < Base class Test < Base


def self.add_result_attribute(attr) 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 define_method(attr) do
@data[attr.to_s] || @data[attr.to_sym] @data[attr.to_s] || @data[attr.to_sym]
Expand Down
2 changes: 1 addition & 1 deletion lib/geocoder/stores/active_record.rb
Expand Up @@ -219,7 +219,7 @@ def add_exclude_condition(conditions, exclude)
end end


def using_sqlite? def using_sqlite?
connection.adapter_name.match /sqlite/i connection.adapter_name.match(/sqlite/i)
end end


## ##
Expand Down

0 comments on commit 3c0859c

Please sign in to comment.