geocoder-izi-lookup 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/geocoder/izi_lookup/version.rb +1 -1
- data/lib/geocoder/lookups/izi_geoip.rb +12 -4
- data/lib/geocoder/results/izi_geoip.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56036667febb7a6e828ea6b065c0a24c982db1850e363da3eb143230a3833ca8
|
4
|
+
data.tar.gz: 65befb8851d8a14b7505c38850ee67a4ea5dce728c0ce0f66811c9ad4d14158d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84d2f3d57a18c329b9b9a466af001a9d2699e27fe8c89d240420b139b60a26dbc933853cf80a8a9c90ae4c153da7f547a60be8285b9572308464e94296dea7e
|
7
|
+
data.tar.gz: 22e1387f2e0eaba0fd781312a87720fb6da0ba2a3dbd63d87195382976e9943e73e626c91933e598884d02c6638c24ddc41fd397ee0a973fb68257fbe1cf91fc
|
@@ -6,11 +6,11 @@ module Geocoder
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def base_query_url(query)
|
9
|
-
"#{host}
|
9
|
+
"#{host}/#{path}?"
|
10
10
|
end
|
11
11
|
|
12
12
|
def query_url(query)
|
13
|
-
"#{host}
|
13
|
+
"#{host}/#{path}?#{param_name}=#{query.sanitized_text}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def cache_key(query)
|
@@ -25,7 +25,7 @@ module Geocoder
|
|
25
25
|
|
26
26
|
def results(query)
|
27
27
|
return [reserved_result(query.text)] if query.loopback_ip_address?
|
28
|
-
if (doc = fetch_data(query)).nil?
|
28
|
+
if (doc = fetch_data(query)).nil? || doc['country_code'].blank? || empty_result?(doc)
|
29
29
|
[]
|
30
30
|
else
|
31
31
|
[doc]
|
@@ -36,8 +36,16 @@ module Geocoder
|
|
36
36
|
configuration[:host] || 'localhost:3000'
|
37
37
|
end
|
38
38
|
|
39
|
+
def path
|
40
|
+
configuration[:path] || 'geocode.json'
|
41
|
+
end
|
42
|
+
|
43
|
+
def param_name
|
44
|
+
configuration[:param_name] || 'ip'
|
45
|
+
end
|
46
|
+
|
39
47
|
def empty_result?(doc)
|
40
|
-
!doc.is_a?(Hash)
|
48
|
+
!doc.is_a?(Hash) || doc.keys == ['ip']
|
41
49
|
end
|
42
50
|
|
43
51
|
def reserved_result(ip)
|
@@ -45,6 +45,7 @@ module Geocoder
|
|
45
45
|
|
46
46
|
def in_eu?
|
47
47
|
if @data['in_eu'].present?
|
48
|
+
return @data['in_eu'] unless @data['in_eu'].is_a?(String)
|
48
49
|
if defined?(ActiveRecord::ConnectionAdapters::Column.value_to_boolean)
|
49
50
|
ActiveRecord::ConnectionAdapters::Column.value_to_boolean(@data['in_eu'])
|
50
51
|
elsif ActiveRecord::Type::Boolean.method_defined?(:type_cast_from_database)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocoder-izi-lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IzikAJ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: geocoder
|