geocoder 1.6.3 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -0
- data/LICENSE +1 -1
- data/README.md +329 -233
- data/examples/app_defined_lookup_services.rb +22 -0
- data/lib/generators/geocoder/config/templates/initializer.rb +6 -1
- data/lib/geocoder/cache.rb +16 -33
- data/lib/geocoder/cache_stores/base.rb +40 -0
- data/lib/geocoder/cache_stores/generic.rb +35 -0
- data/lib/geocoder/cache_stores/redis.rb +34 -0
- data/lib/geocoder/configuration.rb +19 -5
- data/lib/geocoder/configuration_hash.rb +4 -4
- data/lib/geocoder/ip_address.rb +6 -0
- data/lib/geocoder/lookup.rb +32 -4
- data/lib/geocoder/lookups/abstract_api.rb +46 -0
- data/lib/geocoder/lookups/amap.rb +2 -2
- data/lib/geocoder/lookups/amazon_location_service.rb +54 -0
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +1 -1
- data/lib/geocoder/lookups/base.rb +2 -1
- data/lib/geocoder/lookups/bing.rb +1 -1
- data/lib/geocoder/lookups/esri.rb +4 -0
- data/lib/geocoder/lookups/freegeoip.rb +8 -6
- data/lib/geocoder/lookups/geoapify.rb +78 -0
- data/lib/geocoder/lookups/geocodio.rb +1 -1
- data/lib/geocoder/lookups/geoip2.rb +4 -0
- data/lib/geocoder/lookups/geoportail_lu.rb +1 -1
- data/lib/geocoder/lookups/google.rb +7 -2
- data/lib/geocoder/lookups/google_places_details.rb +26 -12
- data/lib/geocoder/lookups/google_places_search.rb +45 -2
- data/lib/geocoder/lookups/google_premier.rb +4 -0
- data/lib/geocoder/lookups/here.rb +25 -20
- data/lib/geocoder/lookups/ip2location.rb +10 -6
- data/lib/geocoder/lookups/ipbase.rb +49 -0
- data/lib/geocoder/lookups/ipdata_co.rb +1 -1
- data/lib/geocoder/lookups/ipqualityscore.rb +50 -0
- data/lib/geocoder/lookups/location_iq.rb +5 -1
- data/lib/geocoder/lookups/maxmind_local.rb +7 -1
- data/lib/geocoder/lookups/melissa_street.rb +41 -0
- data/lib/geocoder/lookups/photon.rb +89 -0
- data/lib/geocoder/lookups/test.rb +5 -0
- data/lib/geocoder/lookups/twogis.rb +58 -0
- data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +1 -1
- data/lib/geocoder/lookups/yandex.rb +3 -3
- data/lib/geocoder/results/abstract_api.rb +146 -0
- data/lib/geocoder/results/amazon_location_service.rb +57 -0
- data/lib/geocoder/results/ban_data_gouv_fr.rb +26 -1
- data/lib/geocoder/results/db_ip_com.rb +1 -1
- data/lib/geocoder/results/esri.rb +5 -2
- data/lib/geocoder/results/geoapify.rb +179 -0
- data/lib/geocoder/results/here.rb +20 -25
- data/lib/geocoder/results/ipbase.rb +40 -0
- data/lib/geocoder/results/ipqualityscore.rb +54 -0
- data/lib/geocoder/results/ipregistry.rb +4 -8
- data/lib/geocoder/results/mapbox.rb +10 -4
- data/lib/geocoder/results/melissa_street.rb +46 -0
- data/lib/geocoder/results/nationaal_georegister_nl.rb +1 -1
- data/lib/geocoder/results/nominatim.rb +27 -15
- data/lib/geocoder/results/photon.rb +119 -0
- data/lib/geocoder/results/twogis.rb +76 -0
- data/lib/geocoder/util.rb +29 -0
- data/lib/geocoder/version.rb +1 -1
- metadata +24 -6
- data/examples/autoexpire_cache_dalli.rb +0 -62
- data/examples/autoexpire_cache_redis.rb +0 -30
- data/lib/hash_recursive_merge.rb +0 -73
data/lib/hash_recursive_merge.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = Hash Recursive Merge
|
3
|
-
#
|
4
|
-
# Merges a Ruby Hash recursively, Also known as deep merge.
|
5
|
-
# Recursive version of Hash#merge and Hash#merge!.
|
6
|
-
#
|
7
|
-
# Category:: Ruby
|
8
|
-
# Package:: Hash
|
9
|
-
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
-
# Copyright:: 2007-2008 The Authors
|
11
|
-
# License:: MIT License
|
12
|
-
# Link:: http://www.simonecarletti.com/
|
13
|
-
# Source:: http://gist.github.com/gists/6391/
|
14
|
-
#
|
15
|
-
module HashRecursiveMerge
|
16
|
-
|
17
|
-
#
|
18
|
-
# Recursive version of Hash#merge!
|
19
|
-
#
|
20
|
-
# Adds the contents of +other_hash+ to +hsh+,
|
21
|
-
# merging entries in +hsh+ with duplicate keys with those from +other_hash+.
|
22
|
-
#
|
23
|
-
# Compared with Hash#merge!, this method supports nested hashes.
|
24
|
-
# When both +hsh+ and +other_hash+ contains an entry with the same key,
|
25
|
-
# it merges and returns the values from both arrays.
|
26
|
-
#
|
27
|
-
# h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
|
28
|
-
# h2 = {"b" => 254, "c" => {"c1" => 16, "c3" => 94}}
|
29
|
-
# h1.rmerge!(h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
|
30
|
-
#
|
31
|
-
# Simply using Hash#merge! would return
|
32
|
-
#
|
33
|
-
# h1.merge!(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
|
34
|
-
#
|
35
|
-
def rmerge!(other_hash)
|
36
|
-
merge!(other_hash) do |key, oldval, newval|
|
37
|
-
oldval.class == self.class ? oldval.rmerge!(newval) : newval
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# Recursive version of Hash#merge
|
43
|
-
#
|
44
|
-
# Compared with Hash#merge!, this method supports nested hashes.
|
45
|
-
# When both +hsh+ and +other_hash+ contains an entry with the same key,
|
46
|
-
# it merges and returns the values from both arrays.
|
47
|
-
#
|
48
|
-
# Compared with Hash#merge, this method provides a different approch
|
49
|
-
# for merging nasted hashes.
|
50
|
-
# If the value of a given key is an Hash and both +other_hash+ abd +hsh
|
51
|
-
# includes the same key, the value is merged instead replaced with
|
52
|
-
# +other_hash+ value.
|
53
|
-
#
|
54
|
-
# h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
|
55
|
-
# h2 = {"b" => 254, "c" => {"c1" => 16, "c3" => 94}}
|
56
|
-
# h1.rmerge(h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
|
57
|
-
#
|
58
|
-
# Simply using Hash#merge would return
|
59
|
-
#
|
60
|
-
# h1.merge(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
|
61
|
-
#
|
62
|
-
def rmerge(other_hash)
|
63
|
-
merge(other_hash) do |key, oldval, newval|
|
64
|
-
oldval.class == self.class ? oldval.rmerge(newval) : newval
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
class Hash
|
72
|
-
include HashRecursiveMerge
|
73
|
-
end
|