From 19437aad523b04d51f3f60a23fe5800299931ea2 Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Sat, 8 Nov 2014 09:44:10 -0500
Subject: [PATCH] Rename from :geolite2 to :geoip2.

GeoLite2 is a free version of a product called GeoIP2. Both use the same
format.
---
 README.md                                              | 8 ++++----
 lib/geocoder/lookup.rb                                 | 2 +-
 lib/geocoder/lookups/{geolite2.rb => geoip2.rb}        | 8 ++++----
 lib/geocoder/results/{geolite2.rb => geoip2.rb}        | 2 +-
 test/test_helper.rb                                    | 4 ++--
 test/unit/cache_test.rb                                | 2 +-
 test/unit/error_handling_test.rb                       | 6 +++---
 test/unit/lookup_test.rb                               | 2 +-
 test/unit/lookups/{geolite2_test.rb => geoip2_test.rb} | 4 ++--
 9 files changed, 19 insertions(+), 19 deletions(-)
 rename lib/geocoder/lookups/{geolite2.rb => geoip2.rb} (81%)
 rename lib/geocoder/results/{geolite2.rb => geoip2.rb} (98%)
 rename test/unit/lookups/{geolite2_test.rb => geoip2_test.rb} (88%)

diff --git a/README.md b/README.md
index fd627490..7405f9e8 100644
--- a/README.md
+++ b/README.md
@@ -709,11 +709,11 @@ You can replace `city` with `country` in any of the above tasks, generators, and
 * **Limitations**: Only good for non-commercial use. For commercial usage please check http://developer.baidu.com/map/question.htm#qa0013
 * **Notes**: To use Baidu set `Geocoder.configure(:lookup => :baidu_ip, :api_key => "your_api_key")`.
 
-#### GeoLite2 (`:geolite2`) - EXPERIMENTAL
+#### GeoLite2 (`:geoip2`) - EXPERIMENTAL
 
 This lookup provides methods for geocoding IP addresses without making a call to a remote API (improves speed and availability). It works, but support is new and should not be considered production-ready. Please [report any bugs](https://github.com/alexreisner/geocoder/issues) you encounter.
 
-* **API key**: none (requires the free GeoLite2 City or Country MaxMind DB binary database which can be downloaded from [MaxMind](http://dev.maxmind.com/geoip/geoip2/geolite2/))
+* **API key**: none (requires the free GeoLite2 City or Country MaxMind DB binary database which can be downloaded from [MaxMind](http://dev.maxmind.com/geoip/geoip2/geoip2/))
 * **Quota**: none
 * **Region**: world
 * **SSL support**: N/A
@@ -726,11 +726,11 @@ This lookup provides methods for geocoding IP addresses without making a call to
 **To use the binary database** you must add either the *[hive_geoip2](https://rubygems.org/gems/hive_geoip2)* gem (native extension that relies on libmaxminddb) or the *[maxminddb](http://rubygems.org/gems/maxminddb)* gem (pure Ruby implementation) to your Gemfile or have it installed in your system.
 Then specify which gem to use with the `:maxminddb_gem` configuration option, and specify the path of the MaxMind database in your configuration. The pure Ruby gem (maxminddb) will be used as default. For example to use the maxminddb gem:
 
-    Geocoder.configure(ip_lookup: :geolite2, geolite2: { file: File.join('folder', 'GeoLite2-City.mmdb') })
+    Geocoder.configure(ip_lookup: :geoip2, geoip2: { file: File.join('folder', 'GeoLite2-City.mmdb') })
 
 To use the hive_geoip2 gem:
 
-    Geocoder.configure(ip_lookup: :geolite2, geolite2: { maxminddb_gem: 'hive_geoip2', file: File.join('folder', 'GeoLite2-City.mmdb') })
+    Geocoder.configure(ip_lookup: :geoip2, geoip2: { maxminddb_gem: 'hive_geoip2', file: File.join('folder', 'GeoLite2-City.mmdb') })
 
 Caching
 -------
diff --git a/lib/geocoder/lookup.rb b/lib/geocoder/lookup.rb
index 3a6e7a78..651cb5b8 100644
--- a/lib/geocoder/lookup.rb
+++ b/lib/geocoder/lookup.rb
@@ -52,7 +52,7 @@ module Geocoder
       [
         :baidu_ip,
         :freegeoip,
-        :geolite2,
+        :geoip2,
         :maxmind,
         :maxmind_local,
         :telize,
diff --git a/lib/geocoder/lookups/geolite2.rb b/lib/geocoder/lookups/geoip2.rb
similarity index 81%
rename from lib/geocoder/lookups/geolite2.rb
rename to lib/geocoder/lookups/geoip2.rb
index 5733d2be..acfdfe40 100644
--- a/lib/geocoder/lookups/geolite2.rb
+++ b/lib/geocoder/lookups/geoip2.rb
@@ -1,23 +1,23 @@
 require 'geocoder/lookups/base'
-require 'geocoder/results/geolite2'
+require 'geocoder/results/geoip2'
 
 module Geocoder
   module Lookup
-    class Geolite2 < Base
+    class Geoip2 < Base
       def initialize
         unless configuration[:file].nil?
           begin
             @gem_name = configuration[:maxminddb_gem] || 'maxminddb'
             require @gem_name
           rescue LoadError
-            raise "Could not load Maxmind DB dependency. To use GeoLite2 lookup you must add the #{@gem_name} gem to your Gemfile or have it installed in your system."
+            raise "Could not load Maxmind DB dependency. To use the GeoIP2 lookup you must add the #{@gem_name} gem to your Gemfile or have it installed in your system."
           end
         end
         super
       end
 
       def name
-        'GeoLite2'
+        'GeoIP2'
       end
 
       def required_api_key_parts
diff --git a/lib/geocoder/results/geolite2.rb b/lib/geocoder/results/geoip2.rb
similarity index 98%
rename from lib/geocoder/results/geolite2.rb
rename to lib/geocoder/results/geoip2.rb
index 3f3d027c..928514c4 100644
--- a/lib/geocoder/results/geolite2.rb
+++ b/lib/geocoder/results/geoip2.rb
@@ -2,7 +2,7 @@ require 'geocoder/results/base'
 
 module Geocoder
   module Result
-    class Geolite2 < Base
+    class Geoip2 < Base
       def address(format = :full)
         s = state.to_s == '' ? '' : ", #{state_code}"
         "#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, '')
diff --git a/test/test_helper.rb b/test/test_helper.rb
index b447cf21..bcd31d21 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -150,7 +150,7 @@ module Geocoder
       end
     end
 
-    class Geolite2
+    class Geoip2
       private
 
       remove_method(:results)
@@ -165,7 +165,7 @@ module Geocoder
       end
 
       def default_fixture_filename
-        'geolite2_74_200_247_59'
+        'geoip2_74_200_247_59'
       end
     end
 
diff --git a/test/unit/cache_test.rb b/test/unit/cache_test.rb
index 6ad4a11e..43fa9c2f 100644
--- a/test/unit/cache_test.rb
+++ b/test/unit/cache_test.rb
@@ -7,7 +7,7 @@ class CacheTest < GeocoderTestCase
   def test_second_occurrence_of_request_is_cache_hit
     Geocoder.configure(:cache => {})
     Geocoder::Lookup.all_services_except_test.each do |l|
-      next if l == :maxmind_local || l == :geolite2 # local, does not use cache
+      next if l == :maxmind_local || l == :geoip2 # local, does not use cache
       Geocoder.configure(:lookup => l)
       set_api_key!(l)
       results = Geocoder.search("Madison Square Garden")
diff --git a/test/unit/error_handling_test.rb b/test/unit/error_handling_test.rb
index 63d63461..493d0ba0 100644
--- a/test/unit/error_handling_test.rb
+++ b/test/unit/error_handling_test.rb
@@ -21,7 +21,7 @@ class ErrorHandlingTest < GeocoderTestCase
   def test_always_raise_timeout_error
     Geocoder.configure(:always_raise => [TimeoutError])
     Geocoder::Lookup.all_services_except_test.each do |l|
-      next if l == :maxmind_local || l == :geolite2 # local, does not use cache
+      next if l == :maxmind_local || l == :geoip2 # local, does not use cache
       lookup = Geocoder::Lookup.get(l)
       set_api_key!(l)
       assert_raises TimeoutError do
@@ -33,7 +33,7 @@ class ErrorHandlingTest < GeocoderTestCase
   def test_always_raise_socket_error
     Geocoder.configure(:always_raise => [SocketError])
     Geocoder::Lookup.all_services_except_test.each do |l|
-      next if l == :maxmind_local || l == :geolite2 # local, does not use cache
+      next if l == :maxmind_local || l == :geoip2 # local, does not use cache
       lookup = Geocoder::Lookup.get(l)
       set_api_key!(l)
       assert_raises SocketError do
@@ -45,7 +45,7 @@ class ErrorHandlingTest < GeocoderTestCase
   def test_always_raise_connection_refused_error
     Geocoder.configure(:always_raise => [Errno::ECONNREFUSED])
     Geocoder::Lookup.all_services_except_test.each do |l|
-      next if l == :maxmind_local || l == :geolite2 # local, does not use cache
+      next if l == :maxmind_local || l == :geoip2 # local, does not use cache
       lookup = Geocoder::Lookup.get(l)
       set_api_key!(l)
       assert_raises Errno::ECONNREFUSED do
diff --git a/test/unit/lookup_test.rb b/test/unit/lookup_test.rb
index 4b36713f..489d5db3 100644
--- a/test/unit/lookup_test.rb
+++ b/test/unit/lookup_test.rb
@@ -23,7 +23,7 @@ class LookupTest < GeocoderTestCase
 
   def test_query_url_contains_values_in_params_hash
     Geocoder::Lookup.all_services_except_test.each do |l|
-      next if [:freegeoip, :maxmind_local, :telize, :pointpin, :geolite2].include? l # does not use query string
+      next if [:freegeoip, :maxmind_local, :telize, :pointpin, :geoip2].include? l # does not use query string
       set_api_key!(l)
       url = Geocoder::Lookup.get(l).query_url(Geocoder::Query.new(
         "test", :params => {:one_in_the_hand => "two in the bush"}
diff --git a/test/unit/lookups/geolite2_test.rb b/test/unit/lookups/geoip2_test.rb
similarity index 88%
rename from test/unit/lookups/geolite2_test.rb
rename to test/unit/lookups/geoip2_test.rb
index ac9267aa..3345c81a 100644
--- a/test/unit/lookups/geolite2_test.rb
+++ b/test/unit/lookups/geoip2_test.rb
@@ -1,9 +1,9 @@
 # encoding: utf-8
 require 'test_helper'
 
-class Geolite2Test < GeocoderTestCase
+class Geoip2Test < GeocoderTestCase
   def setup
-    Geocoder.configure(ip_lookup: :geolite2, file: 'test_file')
+    Geocoder.configure(ip_lookup: :geoip2, file: 'test_file')
   end
 
   def test_result_attributes
-- 
GitLab