Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace deprecated uses of GeoKit (capital K) with Geokit

  • Loading branch information...
commit abdfd16d08b100170e404933624cb40a7e639cf3 1 parent 29a7df8
@mnoack mnoack authored
View
2  README.markdown
@@ -11,7 +11,7 @@ Geokit
The Geokit gem provides:
- * Distance calculations between two points on the earth. Calculate the distance in miles, kilometers, or nautical miles, with all the trigonometry abstracted away by GeoKit.
+ * Distance calculations between two points on the earth. Calculate the distance in miles, kilometers, or nautical miles, with all the trigonometry abstracted away by Geokit.
* Geocoding from multiple providers. It supports Google, Yahoo, Geocoder.us, and Geocoder.ca geocoders, and others. It provides a uniform response structure from all of them.
It also provides a fail-over mechanism, in case your input fails to geocode in one service.
* Rectangular bounds calculations: is a point within a given rectangular bounds?
View
3  lib/geokit.rb
@@ -24,6 +24,3 @@ def self.#{sym}=(obj)
$:.unshift path unless $:.include?(path)
require 'geokit/geocoders'
require 'geokit/mappable'
-
-# make old-style module name "GeoKit" equivalent to new-style "Geokit"
-GeoKit=Geokit
View
8 lib/geokit/geocoders.rb
@@ -136,10 +136,10 @@ def self.do_get(url)
req = Net::HTTP::Get.new(url)
req.basic_auth(uri.user, uri.password) if uri.userinfo
res = Net::HTTP::new(uri.host, uri.port,
- GeoKit::Geocoders::proxy_addr,
- GeoKit::Geocoders::proxy_port,
- GeoKit::Geocoders::proxy_user,
- GeoKit::Geocoders::proxy_pass).start { |http| http.request(req) }
+ Geokit::Geocoders::proxy_addr,
+ Geokit::Geocoders::proxy_port,
+ Geokit::Geocoders::proxy_user,
+ Geokit::Geocoders::proxy_pass).start { |http| http.request(req) }
return res
end
View
2  lib/geokit/services/fcc.rb
@@ -16,7 +16,7 @@ def self.do_reverse_geocode(latlng)
# Template method which does the geocode lookup.
#
# ==== EXAMPLES
- # ll=GeoKit::LatLng.new(40, -85)
+ # ll=Geokit::LatLng.new(40, -85)
# Geokit::Geocoders::FCCGeocoder.geocode(ll) #
# JSON result looks like this
View
4 lib/geokit/services/geonames.rb
@@ -13,8 +13,8 @@ def self.do_geocode(address, options = {})
address_str.gsub!(/,/, " ")
params = "/postalCodeSearch?placename=#{Geokit::Inflector::url_escape(address_str)}&maxRows=10"
- if(GeoKit::Geocoders::geonames)
- url = "http://ws.geonames.net#{params}&username=#{GeoKit::Geocoders::geonames}"
+ if(Geokit::Geocoders::geonames)
+ url = "http://ws.geonames.net#{params}&username=#{Geokit::Geocoders::geonames}"
else
url = "http://ws.geonames.org#{params}"
end
View
4 lib/geokit/services/us_geocoder.rb
@@ -10,8 +10,8 @@ def self.do_geocode(address, options = {})
address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
query = (address_str =~ /^\d{5}(?:-\d{4})?$/ ? "zip" : "address") + "=#{Geokit::Inflector::url_escape(address_str)}"
- url = if GeoKit::Geocoders::geocoder_us
- "http://#{GeoKit::Geocoders::geocoder_us}@geocoder.us/member/service/csv/geocode"
+ url = if Geokit::Geocoders::geocoder_us
+ "http://#{Geokit::Geocoders::geocoder_us}@geocoder.us/member/service/csv/geocode"
else
"http://geocoder.us/service/csv/geocode"
end
View
10 test/test_geoplugin_geocoder.rb
@@ -29,8 +29,8 @@ def test_successful_lookup
success = MockSuccess.new
success.expects(:body).returns(IP_SUCCESS)
url = 'http://www.geoplugin.net/xml.gp?ip=200.150.38.66'
- GeoKit::Geocoders::GeoPluginGeocoder.expects(:call_geocoder_service).with(url).returns(success)
- location = GeoKit::Geocoders::GeoPluginGeocoder.geocode('200.150.38.66')
+ Geokit::Geocoders::GeoPluginGeocoder.expects(:call_geocoder_service).with(url).returns(success)
+ location = Geokit::Geocoders::GeoPluginGeocoder.geocode('200.150.38.66')
assert_not_nil location
assert_equal(-19.916700, location.lat)
assert_equal(-43.933300, location.lng)
@@ -42,7 +42,7 @@ def test_successful_lookup
end
def test_invalid_ip
- location = GeoKit::Geocoders::GeoPluginGeocoder.geocode("pixrum")
+ location = Geokit::Geocoders::GeoPluginGeocoder.geocode("pixrum")
assert_not_nil location
assert !location.success?
end
@@ -50,8 +50,8 @@ def test_invalid_ip
def test_service_unavailable
failure = MockFailure.new
url = 'http://www.geoplugin.net/xml.gp?ip=10.10.10.10'
- GeoKit::Geocoders::GeoPluginGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
- location = GeoKit::Geocoders::GeoPluginGeocoder.geocode("10.10.10.10")
+ Geokit::Geocoders::GeoPluginGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
+ location = Geokit::Geocoders::GeoPluginGeocoder.geocode("10.10.10.10")
assert_not_nil location
assert !location.success?
end
View
2  test/test_inflector.rb
@@ -20,7 +20,7 @@ def test_titleize_with_unicode
end
def test_url_escape
- assert_equal '%E4%B8%8A%E6%B5%B7%E5%B8%82%E5%BE%90%E6%B1%87%E5%8C%BA%E6%BC%95%E6%BA%AA%E5%8C%97%E8%B7%AF1111%E5%8F%B7', GeoKit::Inflector.url_escape('上海市徐汇区漕溪北路1111号')
+ assert_equal '%E4%B8%8A%E6%B5%B7%E5%B8%82%E5%BE%90%E6%B1%87%E5%8C%BA%E6%BC%95%E6%BA%AA%E5%8C%97%E8%B7%AF1111%E5%8F%B7', Geokit::Inflector.url_escape('上海市徐汇区漕溪北路1111号')
assert_equal '%C3%BC%C3%B6%C3%A4', Geokit::Inflector.url_escape('üöä')
end
end
View
28 test/test_ipgeocoder.rb
@@ -52,8 +52,8 @@ def test_successful_lookup
success = MockSuccess.new
success.expects(:body).returns(IP_SUCCESS)
url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true'
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
- location = GeoKit::Geocoders::IpGeocoder.geocode('12.215.42.19')
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
+ location = Geokit::Geocoders::IpGeocoder.geocode('12.215.42.19')
assert_not_nil location
assert_equal 41.7696, location.lat
assert_equal(-88.4588, location.lng)
@@ -68,8 +68,8 @@ def test_unicoded_lookup
success = MockSuccess.new
success.expects(:body).returns(IP_UNICODED)
url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true'
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
- location = GeoKit::Geocoders::IpGeocoder.geocode('12.215.42.19')
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
+ location = Geokit::Geocoders::IpGeocoder.geocode('12.215.42.19')
assert_not_nil location
assert_equal 57.7167, location.lat
assert_equal 12.9167, location.lng
@@ -85,8 +85,8 @@ def test_non_unicoded_lookup
success.stubs(:body).returns(IP_LATIN)
success.stubs(:[]).with('content-type').returns('text/plain; charset=iso-8859-1')
url = 'http://api.hostip.info/get_html.php?ip=201.23.177.144&position=true'
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
- location = GeoKit::Geocoders::IpGeocoder.geocode('201.23.177.144')
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
+ location = Geokit::Geocoders::IpGeocoder.geocode('201.23.177.144')
assert_not_nil location
assert_equal -20.8, location.lat
assert_equal -49.3833, location.lng
@@ -101,24 +101,24 @@ def test_failed_lookup
failure = MockSuccess.new
failure.expects(:body).returns(IP_FAILURE)
url = 'http://api.hostip.info/get_html.php?ip=128.178.0.0&position=true'
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
- location = GeoKit::Geocoders::IpGeocoder.geocode("128.178.0.0")
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
+ location = Geokit::Geocoders::IpGeocoder.geocode("128.178.0.0")
assert_not_nil location
assert !location.success?
end
def test_private_ips
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).never
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).never
PRIVATE_IPS_TO_TEST.each do |ip|
- location = GeoKit::Geocoders::IpGeocoder.geocode(ip)
+ location = Geokit::Geocoders::IpGeocoder.geocode(ip)
assert_not_nil location
assert !location.success?
end
end
def test_invalid_ip
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).never
- location = GeoKit::Geocoders::IpGeocoder.geocode("blah")
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).never
+ location = Geokit::Geocoders::IpGeocoder.geocode("blah")
assert_not_nil location
assert !location.success?
end
@@ -126,8 +126,8 @@ def test_invalid_ip
def test_service_unavailable
failure = MockFailure.new
url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true'
- GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
- location = GeoKit::Geocoders::IpGeocoder.geocode("12.215.42.19")
+ Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
+ location = Geokit::Geocoders::IpGeocoder.geocode("12.215.42.19")
assert_not_nil location
assert !location.success?
end
Please sign in to comment.
Something went wrong with that request. Please try again.