diff --git a/README_API_GUIDE.md b/README_API_GUIDE.md index 1a6ce9dbdedb835deb6413b695711811382128cc..da3db7c46cca8348061c216868da2815e4493526 100644 --- a/README_API_GUIDE.md +++ b/README_API_GUIDE.md @@ -463,7 +463,7 @@ IP Address Lookups * **Terms of Service**: https://ipdata.co/terms.html * **Limitations**: ? -### IP2Location Web Service (`:ip2location_api`) +### IP2Location Web Service (`:ip2location`) * **API key**: optional, see: https://www.ip2location.com/web-service * **Quota**: 20 query/day (up to 100k credits with paid API key) @@ -472,7 +472,7 @@ IP Address Lookups * **Languages**: English * **Documentation**: https://www.ip2location.com/web-service * **Terms of Service**: https://www.ip2location.com/web-service -* **Notes**: To use IP2Location Web Service with API Key set `Geocoder.configure(:ip_lookup => :ip2location_api, :api_key => "IP2LOCATION_WEB_SERVICE_API_KEY")`. Supports the optional param :package with `Geocoder.configure(:ip2location_api => {:package => "WSX"})` (see API documentation for package offered in details). +* **Notes**: To use IP2Location Web Service with API Key set `Geocoder.configure(:ip_lookup => :ip2location, :api_key => "IP2LOCATION_WEB_SERVICE_API_KEY")`. Supports the optional param :package with `Geocoder.configure(:ip2location => {:package => "WSX"})` (see API documentation for package offered in details). Local IP Address Lookups diff --git a/lib/geocoder/lookup.rb b/lib/geocoder/lookup.rb index e9802d073ab5a76f68c434eaf60f2e45570c6cfe..5ccae10227fcd99931c49b924adad5213b1e5c7b 100644 --- a/lib/geocoder/lookup.rb +++ b/lib/geocoder/lookup.rb @@ -73,7 +73,7 @@ module Geocoder :ipdata_co, :db_ip_com, :ipstack, - :ip2location_api, + :ip2location ] end diff --git a/lib/geocoder/lookups/ip2location_api.rb b/lib/geocoder/lookups/ip2location.rb similarity index 96% rename from lib/geocoder/lookups/ip2location_api.rb rename to lib/geocoder/lookups/ip2location.rb index 5650fe743bb9c4554e1473af55eedd8fe3cff385..019a6dad2da9c051c0847828c057e49af65ea6d4 100644 --- a/lib/geocoder/lookups/ip2location_api.rb +++ b/lib/geocoder/lookups/ip2location.rb @@ -1,8 +1,8 @@ require 'geocoder/lookups/base' -require 'geocoder/results/ip2location_api' +require 'geocoder/results/ip2location' module Geocoder::Lookup - class Ip2locationApi < Base + class Ip2location < Base def name "IP2LocationApi" diff --git a/lib/geocoder/results/ip2location_api.rb b/lib/geocoder/results/ip2location.rb similarity index 97% rename from lib/geocoder/results/ip2location_api.rb rename to lib/geocoder/results/ip2location.rb index 5b469af334c02fdc338288adf47eb47bd8460f8a..f6cbf74ef19119431648743772de9746ce9f5147 100644 --- a/lib/geocoder/results/ip2location_api.rb +++ b/lib/geocoder/results/ip2location.rb @@ -1,7 +1,7 @@ require 'geocoder/results/base' module Geocoder::Result - class Ip2locationApi < Base + class Ip2location < Base def address(format = :full) "#{city_name} #{zip_code}, #{country_name}".sub(/^[ ,]*/, '') diff --git a/test/fixtures/ip2location_api_8_8_8_8 b/test/fixtures/ip2location_8_8_8_8 similarity index 100% rename from test/fixtures/ip2location_api_8_8_8_8 rename to test/fixtures/ip2location_8_8_8_8 diff --git a/test/fixtures/ip2location_api_invalid_api_key b/test/fixtures/ip2location_invalid_api_key similarity index 100% rename from test/fixtures/ip2location_api_invalid_api_key rename to test/fixtures/ip2location_invalid_api_key diff --git a/test/fixtures/ip2location_api_no_results b/test/fixtures/ip2location_no_results similarity index 100% rename from test/fixtures/ip2location_api_no_results rename to test/fixtures/ip2location_no_results diff --git a/test/test_helper.rb b/test/test_helper.rb index c7063990bf87bef7442cc68c1430429ce0ca450f..d6243a919ea11ef14733539fc0c1a3148aafff04 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -217,11 +217,11 @@ module Geocoder end end - require 'geocoder/lookups/ip2location_api' - class Ip2locationApi + require 'geocoder/lookups/ip2location' + class Ip2location private def default_fixture_filename - "ip2location_api_8_8_8_8" + "ip2location_8_8_8_8" end end diff --git a/test/unit/lookups/ip2location_api_test.rb b/test/unit/lookups/ip2location_test.rb similarity index 62% rename from test/unit/lookups/ip2location_api_test.rb rename to test/unit/lookups/ip2location_test.rb index 6dab7372f4326131c4283bbf247032747ed68c93..392282208fd726981545aa14797cab603bf48d2b 100644 --- a/test/unit/lookups/ip2location_api_test.rb +++ b/test/unit/lookups/ip2location_test.rb @@ -1,24 +1,24 @@ # encoding: utf-8 require 'test_helper' -class Ip2locationApiTest < GeocoderTestCase +class Ip2locationTest < GeocoderTestCase def setup - Geocoder.configure(:ip_lookup => :ip2location_api) + Geocoder.configure(:ip_lookup => :ip2location) end - def test_ip2location_api_lookup_address + def test_ip2location_lookup_address result = Geocoder.search("8.8.8.8").first assert_equal "US", result.country_code end - def test_ip2location_api_lookup_loopback_address + def test_ip2location_lookup_loopback_address result = Geocoder.search("127.0.0.1").first assert_equal "INVALID IP ADDRESS", result.country_code end - def test_ip2location_api_extra_data - Geocoder.configure(:ip2location_api => {:package => "WS3"}) + def test_ip2location_extra_data + Geocoder.configure(:ip2location => {:package => "WS3"}) result = Geocoder.search("8.8.8.8").first assert_equal "United States", result.country_name assert_equal "California", result.region_name