geocoder 1.6.6 → 1.6.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/README.md +2 -2
- data/lib/geocoder/lookup.rb +1 -0
- data/lib/geocoder/lookups/abstract_api.rb +46 -0
- data/lib/geocoder/lookups/uk_ordnance_survey_names.rb +1 -1
- data/lib/geocoder/results/abstract_api.rb +146 -0
- data/lib/geocoder/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17d8f44da8b584b65c5546df089f0c16e6d20045676d4a1fe3fef38cdf3c3c59
|
4
|
+
data.tar.gz: c527329b8d1f28a326092e3b3f6d2c9c143dacc2da2397fab5b4109ae7387f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 918ed290277a1aa7e57a102ad06b0cf733e1908e9f31ead6cd59c5d08e5cc5b7d2f581a9958961781e013b535763c92701ad02f2bd8268374e339a36fd75eb25
|
7
|
+
data.tar.gz: 14416b59a9f34890d9a466aad87a883651f13f58a1f0a972c7d48370daed0f70923b9534b13e489673dbbc19543c82fb9017dd274529ce3a587bebe1f230649d
|
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,15 @@ Changelog
|
|
3
3
|
|
4
4
|
Major changes to Geocoder for each release. Please see the Git log for complete list of changes.
|
5
5
|
|
6
|
-
1.6.
|
6
|
+
1.6.7 (2021 Apr 17)
|
7
|
+
-------------------
|
8
|
+
* Add support for Abstract API lookup (thanks github.com/randoum).
|
9
|
+
|
10
|
+
1.6.6 (2021 Mar 4)
|
7
11
|
-------------------
|
8
12
|
* Rescue from exception on cache read/write error. Issue warning instead.
|
9
13
|
|
10
|
-
1.6.5 (
|
14
|
+
1.6.5 (2021 Feb 10)
|
11
15
|
-------------------
|
12
16
|
* Fix backward coordinates bug in NationaalregisterNl lookup (thanks github.com/Marthyn).
|
13
17
|
* Allow removal of single stubs in test mode (thanks github.com/jmmastey).
|
data/README.md
CHANGED
@@ -51,8 +51,8 @@ The Rest:
|
|
51
51
|
* [Technical Discussions](#technical-discussions)
|
52
52
|
* [Troubleshooting](#troubleshooting)
|
53
53
|
* [Known Issues](#known-issues)
|
54
|
-
* [Reporting Issues](#reporting-
|
55
|
-
* [Contributing](#
|
54
|
+
* [Reporting Issues](https://github.com/alexreisner/geocoder/blob/master/CONTRIBUTING.md#reporting-bugs)
|
55
|
+
* [Contributing](https://github.com/alexreisner/geocoder/blob/master/CONTRIBUTING.md#making-changes)
|
56
56
|
|
57
57
|
See Also:
|
58
58
|
|
data/lib/geocoder/lookup.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'geocoder/lookups/base'
|
4
|
+
require 'geocoder/results/abstract_api'
|
5
|
+
|
6
|
+
module Geocoder::Lookup
|
7
|
+
class AbstractApi < Base
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Abstract API"
|
11
|
+
end
|
12
|
+
|
13
|
+
def required_api_key_parts
|
14
|
+
['api_key']
|
15
|
+
end
|
16
|
+
|
17
|
+
def supported_protocols
|
18
|
+
[:https]
|
19
|
+
end
|
20
|
+
|
21
|
+
private # ---------------------------------------------------------------
|
22
|
+
|
23
|
+
def base_query_url(query)
|
24
|
+
"#{protocol}://ipgeolocation.abstractapi.com/v1/?"
|
25
|
+
end
|
26
|
+
|
27
|
+
def query_url_params(query)
|
28
|
+
params = {api_key: configuration.api_key}
|
29
|
+
|
30
|
+
ip_address = query.sanitized_text
|
31
|
+
if ip_address.is_a?(String) && ip_address.length > 0
|
32
|
+
params[:ip_address] = ip_address
|
33
|
+
end
|
34
|
+
|
35
|
+
params.merge(super)
|
36
|
+
end
|
37
|
+
|
38
|
+
def results(query, reverse = false)
|
39
|
+
if doc = fetch_data(query)
|
40
|
+
[doc]
|
41
|
+
else
|
42
|
+
[]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder
|
4
|
+
module Result
|
5
|
+
class AbstractApi < Base
|
6
|
+
|
7
|
+
##
|
8
|
+
# Geolocation
|
9
|
+
|
10
|
+
def state
|
11
|
+
@data['region']
|
12
|
+
end
|
13
|
+
|
14
|
+
def state_code
|
15
|
+
@data['region_iso_code']
|
16
|
+
end
|
17
|
+
|
18
|
+
def city
|
19
|
+
@data["city"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def city_geoname_id
|
23
|
+
@data["city_geoname_id"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def region_geoname_id
|
27
|
+
@data["region_geoname_id"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def postal_code
|
31
|
+
@data["postal_code"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def country
|
35
|
+
@data["country"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def country_code
|
39
|
+
@data["country_code"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def country_geoname_id
|
43
|
+
@data["country_geoname_id"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def country_is_eu
|
47
|
+
@data["country_is_eu"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def continent
|
51
|
+
@data["continent"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def continent_code
|
55
|
+
@data["continent_code"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def continent_geoname_id
|
59
|
+
@data["continent_geoname_id"]
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Security
|
64
|
+
|
65
|
+
def is_vpn?
|
66
|
+
@data.dig "security", "is_vpn"
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Timezone
|
71
|
+
|
72
|
+
def timezone_name
|
73
|
+
@data.dig "timezone", "name"
|
74
|
+
end
|
75
|
+
|
76
|
+
def timezone_abbreviation
|
77
|
+
@data.dig "timezone", "abbreviation"
|
78
|
+
end
|
79
|
+
|
80
|
+
def timezone_gmt_offset
|
81
|
+
@data.dig "timezone", "gmt_offset"
|
82
|
+
end
|
83
|
+
|
84
|
+
def timezone_current_time
|
85
|
+
@data.dig "timezone", "current_time"
|
86
|
+
end
|
87
|
+
|
88
|
+
def timezone_is_dst
|
89
|
+
@data.dig "timezone", "is_dst"
|
90
|
+
end
|
91
|
+
|
92
|
+
##
|
93
|
+
# Flag
|
94
|
+
|
95
|
+
def flag_emoji
|
96
|
+
@data.dig "flag", "emoji"
|
97
|
+
end
|
98
|
+
|
99
|
+
def flag_unicode
|
100
|
+
@data.dig "flag", "unicode"
|
101
|
+
end
|
102
|
+
|
103
|
+
def flag_png
|
104
|
+
@data.dig "flag", "png"
|
105
|
+
end
|
106
|
+
|
107
|
+
def flag_svg
|
108
|
+
@data.dig "flag", "svg"
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Currency
|
113
|
+
|
114
|
+
def currency_currency_name
|
115
|
+
@data.dig "currency", "currency_name"
|
116
|
+
end
|
117
|
+
|
118
|
+
def currency_currency_code
|
119
|
+
@data.dig "currency", "currency_code"
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Connection
|
124
|
+
|
125
|
+
def connection_autonomous_system_number
|
126
|
+
@data.dig "connection", "autonomous_system_number"
|
127
|
+
end
|
128
|
+
|
129
|
+
def connection_autonomous_system_organization
|
130
|
+
@data.dig "connection", "autonomous_system_organization"
|
131
|
+
end
|
132
|
+
|
133
|
+
def connection_connection_type
|
134
|
+
@data.dig "connection", "connection_type"
|
135
|
+
end
|
136
|
+
|
137
|
+
def connection_isp_name
|
138
|
+
@data.dig "connection", "isp_name"
|
139
|
+
end
|
140
|
+
|
141
|
+
def connection_organization_name
|
142
|
+
@data.dig "connection", "organization_name"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
data/lib/geocoder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Object geocoding (by street or IP address), reverse geocoding (coordinates
|
14
14
|
to street address), distance queries for ActiveRecord and Mongoid, result caching,
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/geocoder/kernel_logger.rb
|
50
50
|
- lib/geocoder/logger.rb
|
51
51
|
- lib/geocoder/lookup.rb
|
52
|
+
- lib/geocoder/lookups/abstract_api.rb
|
52
53
|
- lib/geocoder/lookups/amap.rb
|
53
54
|
- lib/geocoder/lookups/baidu.rb
|
54
55
|
- lib/geocoder/lookups/baidu_ip.rb
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- lib/geocoder/query.rb
|
106
107
|
- lib/geocoder/railtie.rb
|
107
108
|
- lib/geocoder/request.rb
|
109
|
+
- lib/geocoder/results/abstract_api.rb
|
108
110
|
- lib/geocoder/results/amap.rb
|
109
111
|
- lib/geocoder/results/baidu.rb
|
110
112
|
- lib/geocoder/results/baidu_ip.rb
|