geocoder 1.1.3 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +4 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +109 -35
- data/README.md +645 -0
- data/examples/autoexpire_cache.rb +28 -0
- data/lib/generators/geocoder/config/templates/initializer.rb +18 -22
- data/lib/geocoder/cache.rb +2 -1
- data/lib/geocoder/calculations.rb +13 -13
- data/lib/geocoder/cli.rb +17 -19
- data/lib/geocoder/configuration.rb +68 -42
- data/lib/geocoder/configuration_hash.rb +11 -0
- data/lib/geocoder/exceptions.rb +3 -0
- data/lib/geocoder/lookup.rb +81 -0
- data/lib/geocoder/lookups/base.rb +106 -56
- data/lib/geocoder/lookups/bing.rb +25 -11
- data/lib/geocoder/lookups/freegeoip.rb +11 -7
- data/lib/geocoder/lookups/geocoder_ca.rb +17 -9
- data/lib/geocoder/lookups/google.rb +29 -8
- data/lib/geocoder/lookups/google_premier.rb +20 -11
- data/lib/geocoder/lookups/mapquest.rb +29 -19
- data/lib/geocoder/lookups/maxmind.rb +72 -0
- data/lib/geocoder/lookups/nominatim.rb +21 -13
- data/lib/geocoder/lookups/test.rb +12 -6
- data/lib/geocoder/lookups/yahoo.rb +63 -13
- data/lib/geocoder/lookups/yandex.rb +26 -11
- data/lib/geocoder/models/mongoid.rb +1 -2
- data/lib/geocoder/query.rb +103 -0
- data/lib/geocoder/request.rb +7 -1
- data/lib/geocoder/results/base.rb +8 -2
- data/lib/geocoder/results/google.rb +6 -0
- data/lib/geocoder/results/mapquest.rb +19 -34
- data/lib/geocoder/results/maxmind.rb +136 -0
- data/lib/geocoder/results/nominatim.rb +14 -3
- data/lib/geocoder/results/yahoo.rb +9 -2
- data/lib/geocoder/sql.rb +106 -0
- data/lib/geocoder/stores/active_record.rb +75 -142
- data/lib/geocoder/stores/base.rb +3 -2
- data/lib/geocoder/stores/mongo_base.rb +2 -2
- data/lib/geocoder/version.rb +1 -1
- data/lib/geocoder.rb +11 -89
- data/lib/hash_recursive_merge.rb +74 -0
- data/lib/oauth_util.rb +112 -0
- data/test/active_record_test.rb +15 -0
- data/test/cache_test.rb +19 -0
- data/test/calculations_test.rb +11 -4
- data/test/configuration_test.rb +26 -51
- data/test/error_handling_test.rb +15 -11
- data/test/fixtures/bing_invalid_key +1 -0
- data/test/fixtures/mapquest_madison_square_garden +52 -0
- data/test/fixtures/mapquest_no_results +7 -0
- data/test/fixtures/maxmind_24_24_24_21 +1 -0
- data/test/fixtures/maxmind_24_24_24_22 +1 -0
- data/test/fixtures/maxmind_24_24_24_23 +1 -0
- data/test/fixtures/maxmind_24_24_24_24 +1 -0
- data/test/fixtures/maxmind_74_200_247_59 +1 -0
- data/test/fixtures/maxmind_invalid_key +1 -0
- data/test/fixtures/maxmind_no_results +1 -0
- data/test/fixtures/yahoo_error +1 -0
- data/test/fixtures/yahoo_invalid_key +2 -0
- data/test/fixtures/yahoo_madison_square_garden +52 -0
- data/test/fixtures/yahoo_no_results +10 -0
- data/test/fixtures/yahoo_over_limit +2 -0
- data/test/https_test.rb +3 -3
- data/test/integration/smoke_test.rb +8 -6
- data/test/lookup_test.rb +92 -13
- data/test/near_test.rb +11 -0
- data/test/oauth_util_test.rb +30 -0
- data/test/proxy_test.rb +2 -2
- data/test/query_test.rb +42 -0
- data/test/result_test.rb +4 -3
- data/test/services_test.rb +164 -26
- data/test/test_helper.rb +93 -112
- data/test/test_mode_test.rb +3 -4
- metadata +52 -35
- data/README.rdoc +0 -552
- data/test/fixtures/mapquest_madison_square_garden.json +0 -27
- data/test/fixtures/mapquest_no_results.json +0 -1
- data/test/fixtures/yahoo_garbage.json +0 -50
- data/test/fixtures/yahoo_madison_square_garden.json +0 -46
- data/test/fixtures/yahoo_no_results.json +0 -10
- data/test/input_handling_test.rb +0 -43
- /data/test/fixtures/{bing_madison_square_garden.json → bing_madison_square_garden} +0 -0
- /data/test/fixtures/{bing_no_results.json → bing_no_results} +0 -0
- /data/test/fixtures/{bing_reverse.json → bing_reverse} +0 -0
- /data/test/fixtures/{freegeoip_74_200_247_59.json → freegeoip_74_200_247_59} +0 -0
- /data/test/fixtures/{freegeoip_no_results.json → freegeoip_no_results} +0 -0
- /data/test/fixtures/{geocoder_ca_madison_square_garden.json → geocoder_ca_madison_square_garden} +0 -0
- /data/test/fixtures/{geocoder_ca_no_results.json → geocoder_ca_no_results} +0 -0
- /data/test/fixtures/{geocoder_ca_reverse.json → geocoder_ca_reverse} +0 -0
- /data/test/fixtures/{google_garbage.json → google_garbage} +0 -0
- /data/test/fixtures/{google_madison_square_garden.json → google_madison_square_garden} +0 -0
- /data/test/fixtures/{google_no_city_data.json → google_no_city_data} +0 -0
- /data/test/fixtures/{google_no_locality.json → google_no_locality} +0 -0
- /data/test/fixtures/{google_no_results.json → google_no_results} +0 -0
- /data/test/fixtures/{nominatim_madison_square_garden.json → nominatim_madison_square_garden} +0 -0
- /data/test/fixtures/{nominatim_no_results.json → nominatim_no_results} +0 -0
- /data/test/fixtures/{yandex_invalid_key.json → yandex_invalid_key} +0 -0
- /data/test/fixtures/{yandex_kremlin.json → yandex_kremlin} +0 -0
- /data/test/fixtures/{yandex_no_results.json → yandex_no_results} +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ResultSet":{
|
|
3
|
-
"version":"1.0",
|
|
4
|
-
"Error":0,
|
|
5
|
-
"ErrorMessage":"No error",
|
|
6
|
-
"Locale":"us_US",
|
|
7
|
-
"Quality":90,
|
|
8
|
-
"Found":1,
|
|
9
|
-
"Results":[{
|
|
10
|
-
"quality":90,
|
|
11
|
-
"latitude":"40.750381",
|
|
12
|
-
"longitude":"-73.993988",
|
|
13
|
-
"offsetlat":"40.750381",
|
|
14
|
-
"offsetlon":"-73.993988",
|
|
15
|
-
"radius":100,
|
|
16
|
-
"name":"Madison Square Garden",
|
|
17
|
-
"line1":"Madison Square Garden",
|
|
18
|
-
"line2":"New York, NY 10001",
|
|
19
|
-
"line3":"",
|
|
20
|
-
"line4":"United States",
|
|
21
|
-
"house":"",
|
|
22
|
-
"street":"",
|
|
23
|
-
"xstreet":"",
|
|
24
|
-
"unittype":"",
|
|
25
|
-
"unit":"",
|
|
26
|
-
"postal":"10001",
|
|
27
|
-
"neighborhood":"",
|
|
28
|
-
"city":"New York",
|
|
29
|
-
"county":"New York County",
|
|
30
|
-
"state":"New York",
|
|
31
|
-
"country":"United States",
|
|
32
|
-
"countrycode":"US",
|
|
33
|
-
"statecode":"NY",
|
|
34
|
-
"countycode":"",
|
|
35
|
-
"uzip":"10001",
|
|
36
|
-
"hash":"",
|
|
37
|
-
"woeid":23617041,
|
|
38
|
-
"woetype":20,
|
|
39
|
-
"cross":"",
|
|
40
|
-
"timezone":"America/New_York",
|
|
41
|
-
"neighborhood":"Garment District|Midtown|Midtown West|Manhattan",
|
|
42
|
-
"areacode":"212",
|
|
43
|
-
"boundingbox":{"north":"40.750832","south":"40.749931","east":"-73.993393","west":"-73.994591"}
|
|
44
|
-
}]
|
|
45
|
-
}
|
|
46
|
-
}
|
data/test/input_handling_test.rb
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'test_helper'
|
|
3
|
-
|
|
4
|
-
class InputHandlingTest < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
def test_ip_address_detection
|
|
7
|
-
assert Geocoder.send(:ip_address?, "232.65.123.94")
|
|
8
|
-
assert Geocoder.send(:ip_address?, "666.65.123.94") # technically invalid
|
|
9
|
-
assert Geocoder.send(:ip_address?, "::ffff:12.34.56.78")
|
|
10
|
-
assert !Geocoder.send(:ip_address?, "232.65.123.94.43")
|
|
11
|
-
assert !Geocoder.send(:ip_address?, "232.65.123")
|
|
12
|
-
assert !Geocoder.send(:ip_address?, "::ffff:123.456.789")
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_blank_query_detection
|
|
16
|
-
assert Geocoder.send(:blank_query?, nil)
|
|
17
|
-
assert Geocoder.send(:blank_query?, "")
|
|
18
|
-
assert Geocoder.send(:blank_query?, "\t ")
|
|
19
|
-
assert !Geocoder.send(:blank_query?, "a")
|
|
20
|
-
assert !Geocoder.send(:blank_query?, "Москва") # no ASCII characters
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_coordinates_detection
|
|
24
|
-
lookup = Geocoder::Lookup::Google.new
|
|
25
|
-
assert lookup.send(:coordinates?, "51.178844,5")
|
|
26
|
-
assert lookup.send(:coordinates?, "51.178844, -1.826189")
|
|
27
|
-
assert !lookup.send(:coordinates?, "232.65.123")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_does_not_choke_on_nil_address
|
|
31
|
-
all_lookups.each do |l|
|
|
32
|
-
Geocoder::Configuration.lookup = l
|
|
33
|
-
assert_nothing_raised { Venue.new("Venue", nil).geocode }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_extract_coordinates
|
|
38
|
-
coords = [-23,47]
|
|
39
|
-
l = Landmark.new("Madagascar", coords[0], coords[1])
|
|
40
|
-
assert_equal coords, Geocoder::Calculations.extract_coordinates(l)
|
|
41
|
-
assert_equal coords, Geocoder::Calculations.extract_coordinates(coords)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/data/test/fixtures/{geocoder_ca_madison_square_garden.json → geocoder_ca_madison_square_garden}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/data/test/fixtures/{nominatim_madison_square_garden.json → nominatim_madison_square_garden}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|