Skip to content

Commit

Permalink
Merge pull request #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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

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

class Base
def initialize
@cache = nil
end

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

def query_url_params(query)
params = {
{
:query => query.sanitized_text,
:return_location => true,
:return_geometry => false
Expand Down
4 changes: 2 additions & 2 deletions lib/geocoder/lookups/maxmind_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MaxmindLocal < Base
def initialize
begin
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.'
end

Expand Down Expand Up @@ -38,4 +38,4 @@ def results(query)
result.nil? ? [] : [result.to_hash]
end
end
end
end
2 changes: 1 addition & 1 deletion lib/geocoder/lookups/yahoo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions lib/geocoder/models/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'geocoder'

module Geocoder

##
Expand Down Expand Up @@ -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)
Expand All @@ -39,4 +37,3 @@ def geocoder_init(options)
end
end
end

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

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

module Geocoder
module Request

Expand Down
5 changes: 4 additions & 1 deletion lib/geocoder/results/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/geocoder/stores/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand Down

0 comments on commit 3c0859c

Please sign in to comment.