ip2location_ruby 8.7.0 → 8.7.1
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/Gemfile.lock +24 -24
- data/README.md +3 -90
- data/VERSION +1 -1
- data/ip2location_ruby.gemspec +2 -2
- data/lib/ip2location_ruby/database_config.rb +2 -2
- data/lib/ip2location_ruby/i2l_float_data.rb +2 -2
- data/lib/ip2location_ruby/i2l_ip_data.rb +3 -3
- data/lib/ip2location_ruby.rb +3 -3
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b86068ea70a1da30468fab1bbd5407f81cd48c9438ce187358c86612794c027d
|
4
|
+
data.tar.gz: 29d1d716f253f9c2ff4a64701733cc2a7c64ea8a8b18492e6c172ae74be53d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a68a0213618700b4c52af2c1a406b3ada8650de49f519f17152dacc8dc537ef46105cd5f6029f76e1920873579a9b0828f4a8d5932d758566051f7c5d8e8b843
|
7
|
+
data.tar.gz: 77ffe92c332344206f1d62dffeeb6898eb9bf90277a9aa161c95987128fe85c531a84fd5c7b32cb933d8d6da4a20187c4c0a4902dfbfeeeace401f875ca54f7e
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
bindata (2.4.10)
|
5
|
-
diff-lcs (1.1.3)
|
6
|
-
json (>= 2.3.0)
|
7
|
-
rdoc (>= 6.3.1)
|
8
|
-
json (~> 1.4)
|
9
|
-
rspec (2.8.0)
|
10
|
-
rspec-core (~> 2.8.0)
|
11
|
-
rspec-expectations (~> 2.8.0)
|
12
|
-
rspec-mocks (~> 2.8.0)
|
13
|
-
rspec-core (2.8.0)
|
14
|
-
rspec-expectations (2.8.0)
|
15
|
-
diff-lcs (~> 1.1.2)
|
16
|
-
rspec-mocks (2.8.0)
|
17
|
-
|
18
|
-
PLATFORMS
|
19
|
-
ruby
|
20
|
-
|
21
|
-
DEPENDENCIES
|
22
|
-
bindata
|
23
|
-
bundler (>= 1.2.0)
|
24
|
-
rdoc (>= 6.3.1)
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
bindata (2.4.10)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
json (>= 2.3.0)
|
7
|
+
rdoc (>= 6.3.1)
|
8
|
+
json (~> 1.4)
|
9
|
+
rspec (2.8.0)
|
10
|
+
rspec-core (~> 2.8.0)
|
11
|
+
rspec-expectations (~> 2.8.0)
|
12
|
+
rspec-mocks (~> 2.8.0)
|
13
|
+
rspec-core (2.8.0)
|
14
|
+
rspec-expectations (2.8.0)
|
15
|
+
diff-lcs (~> 1.1.2)
|
16
|
+
rspec-mocks (2.8.0)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
bindata
|
23
|
+
bundler (>= 1.2.0)
|
24
|
+
rdoc (>= 6.3.1)
|
25
25
|
rspec (~> 2.8.0)
|
data/README.md
CHANGED
@@ -2,102 +2,15 @@
|
|
2
2
|
[](https://rubygems.org/gems/ip2location_ruby)
|
3
3
|
|
4
4
|
# IP2Location Ruby Library
|
5
|
-
This is IP2Location Ruby library that enables the user to find the country, region or state, city, latitude and longitude,
|
5
|
+
This is IP2Location Ruby library that enables the user to find the country, region or state, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN from IP address using IP2Location database. The library reads the geo location information from **IP2Location BIN data** file or web service.
|
6
6
|
|
7
7
|
Supported IPv4 and IPv6 address.
|
8
8
|
|
9
9
|
For more details, please visit:
|
10
10
|
[https://www.ip2location.com/developers/ruby](https://www.ip2location.com/developers/ruby)
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
```
|
16
|
-
gem install ip2location_ruby
|
17
|
-
```
|
18
|
-
|
19
|
-
# Usage
|
20
|
-
You can check the **example.rb** file to learn more about usage.
|
21
|
-
|
22
|
-
## BIN Database
|
23
|
-
An outdated BIN database was provided in the library for your testing. You are recommended to visit the [links](#dependencies) to download the latest BIN database and save it in the ```rb``` folder.
|
24
|
-
|
25
|
-
Below is the description of the functions available in the **BIN Database** lookup.
|
26
|
-
|
27
|
-
| Function Name | Description |
|
28
|
-
|---|---|
|
29
|
-
| open | Open the IP2Location BIN data for lookup. |
|
30
|
-
| close | Close and clean up the file pointer. |
|
31
|
-
| get_package_version | Get the package version (1 to 25 for DB1 to DB25 respectively). |
|
32
|
-
| get_module_version | Get the module version. |
|
33
|
-
| get_database_version | Get the database version. |
|
34
|
-
| get_last_error_message | Return the last error message. |
|
35
|
-
| get_all | Return the geolocation information in array. |
|
36
|
-
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
|
37
|
-
| get_country_long | Return the ISO3166-1 country name of the IP address. |
|
38
|
-
| get_region | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
|
39
|
-
| get_city | Return the city name of the IP address. |
|
40
|
-
| get_latitude | Return the city latitude of the IP address. |
|
41
|
-
| get_longitude | Return the city longtitude of the IP address. |
|
42
|
-
| get_isp | Return the ISP name of the IP address. |
|
43
|
-
| get_domain | Return the domain name of IP address. |
|
44
|
-
| get_zipcode | Return the zipcode of the city. |
|
45
|
-
| get_timezone | Return the UTC time zone (with DST supported). |
|
46
|
-
| get_netspeed | Return the Internet connection type. |
|
47
|
-
| get_iddcode | Return the IDD prefix to call the city from another country. |
|
48
|
-
| get_areacode | Return the area code of the city. |
|
49
|
-
| get_weathercode | Return the nearest weather observation station code. |
|
50
|
-
| get_weathername | Return the nearest weather observation station name. |
|
51
|
-
| get_mcc | Return the Mobile Country Codes (MCC). |
|
52
|
-
| get_mnc | Return the Mobile Network Code (MNC). |
|
53
|
-
| get_mobilebrand | Commercial brand associated with the mobile carrier. |
|
54
|
-
| get_elevation | Return average height of city above sea level in meters (m). |
|
55
|
-
| get_usagetype | Return the ISP's usage type of IP address. |
|
56
|
-
| get_addresstype | Returns the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
|
57
|
-
| get_category | Returns the IAB content taxonomy category of IP address or domain name. |
|
58
|
-
|
59
|
-
## Web Service
|
60
|
-
Below is the description of the functions available in the **Web Service** lookup.
|
61
|
-
|
62
|
-
| Function Name | Description |
|
63
|
-
|---|---|
|
64
|
-
| Constructor | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li></li><li>Use HTTPS or HTTP</li></ol> |
|
65
|
-
| lookup | Return the IP information in array.<ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
|
66
|
-
| get_credit | Return remaining credit of the web service account. |
|
67
|
-
|
68
|
-
## IpTools
|
69
|
-
Below is the description of the functions available in the **IpTools** class.
|
70
|
-
|
71
|
-
| Function Name | Description |
|
72
|
-
|---|---|
|
73
|
-
| is_ipv4 | Return either true or false. Verify if a string is a valid IPv4 address. |
|
74
|
-
| is_ipv6 | Return either true or false. Verify if a string is a valid IPv6 address. |
|
75
|
-
| ipv4_to_decimal | Translate IPv4 address from dotted-decimal address to decimal format. Return null on error. |
|
76
|
-
| decimal_to_ipv4 | Translate IPv4 address from decimal number to dotted-decimal address. Return null on error. |
|
77
|
-
| ipv6_to_decimal | Translate IPv6 address from hexadecimal address to decimal format. Return null on error. |
|
78
|
-
| decimal_to_ipv6 | Translate IPv6 address from decimal number into hexadecimal address. Return null on error. |
|
79
|
-
| ipv4_to_cidr | Convert IPv4 range into a list of IPv4 CIDR notation. |
|
80
|
-
| cidr_to_ipv4 | Convert IPv4 CIDR notation into a list of IPv4 addresses. |
|
81
|
-
| ipv6_to_cidr | Convert IPv6 range into a list of IPv6 CIDR notation. |
|
82
|
-
| cidr_to_ipv6 | Convert IPv6 CIDR notation into a list of IPv6 addresses. |
|
83
|
-
| compress_ipv6 | Compress a IPv6 to shorten the length. |
|
84
|
-
| expand_ipv6 | Expand a shorten IPv6 to full length. |
|
85
|
-
|
86
|
-
## Country
|
87
|
-
Below is the description of the functions available in the **Country** class.
|
88
|
-
|
89
|
-
| Function Name | Description |
|
90
|
-
|---|---|
|
91
|
-
| Constructor | Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information |
|
92
|
-
| get_country_info | Provide a ISO 3166 country code to get the country information in array. Will return a full list of countries information if country code not provided. Below is the information returned: <ul><li>country_code</li><li>country_alpha3_code</li><li>country_numeric_code</li><li>capital</li><li>country_demonym</li><li>total_area</li><li>population</li><li>idd_code</li><li>currency_code</li><li>currency_name</li><li>currency_symbol</li><li>lang_code</li><li>lang_name</li><li>cctld</li></ul> |
|
93
|
-
|
94
|
-
## Region
|
95
|
-
Below is the description of the functions available in the **Region** class.
|
96
|
-
|
97
|
-
| Function Name | Description |
|
98
|
-
|---|---|
|
99
|
-
| Constructor | Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2 |
|
100
|
-
| get_region_code | Provide a ISO 3166 country code and the region name to get ISO 3166-2 subdivision code for the region. |
|
12
|
+
## Developer Documentation
|
13
|
+
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2location-ruby.readthedocs.io/en/latest/index.html.](https://ip2location-ruby.readthedocs.io/en/latest/index.html)
|
101
14
|
|
102
15
|
# Dependencies
|
103
16
|
This library requires IP2Location BIN data file to function. You may download the BIN data file at
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
8.7.
|
1
|
+
8.7.1
|
data/ip2location_ruby.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ip2location_ruby"
|
3
|
-
s.version = "8.7.
|
3
|
+
s.version = "8.7.1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.require_paths = ["lib"]
|
7
7
|
s.authors = ["ip2location"]
|
8
8
|
s.email = ["support@ip2location.com"]
|
9
|
-
s.description = "The official IP2Location Ruby library to geolocate an IP address. You can lookup for country, region, city, latitude
|
9
|
+
s.description = "The official IP2Location Ruby library to geolocate an IP address. You can lookup for country, region, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN from an IP address. Supported both IPv4 and IPv6 lookup."
|
10
10
|
s.email = "support@ip2location.com"
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE.txt",
|
@@ -2,9 +2,9 @@ class I2lIpData < BinData::BasePrimitive
|
|
2
2
|
def read_and_return_value(io)
|
3
3
|
iv = eval_parameter(:ip_version)
|
4
4
|
if iv == 4
|
5
|
-
|
5
|
+
BinData::Uint32le.read(io)
|
6
6
|
elsif iv == 6
|
7
|
-
|
7
|
+
BinData::Uint128le.read(io)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
data/lib/ip2location_ruby.rb
CHANGED
@@ -14,7 +14,7 @@ require 'ip2location_ruby/ip2location_record'
|
|
14
14
|
class Ip2location
|
15
15
|
attr_accessor :record_class4, :record_class6, :v4, :file, :db_index, :count, :base_addr, :ipno, :count, :record, :database, :columns, :ip_version, :ipv4databasecount, :ipv4databaseaddr, :ipv4indexbaseaddr, :ipv6databasecount, :ipv6databaseaddr, :ipv6indexbaseaddr, :databaseyear, :databasemonth, :databaseday, :last_err_msg
|
16
16
|
|
17
|
-
VERSION = '8.7.
|
17
|
+
VERSION = '8.7.1'
|
18
18
|
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
|
19
19
|
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
|
20
20
|
INVALID_BIN_DATABASE = 'Incorrect IP2Location BIN file format. Please make sure that you are using the latest IP2Location BIN file.'
|
@@ -29,7 +29,7 @@ class Ip2location
|
|
29
29
|
begin
|
30
30
|
self.file = File.open(File.expand_path url, 'rb')
|
31
31
|
rescue
|
32
|
-
self.last_err_msg = 'Ip2location.new.open() error in opening ' + url +'.'
|
32
|
+
self.last_err_msg = 'Ip2location.new.open() error in opening ' + url + '.'
|
33
33
|
abort('Ip2location.new.open() error in opening ' + url + '. No such file in the /your_ip2location_ruby_library_path/rb/ folder.')
|
34
34
|
else
|
35
35
|
end
|
@@ -1154,4 +1154,4 @@ class Ip2locationRegion
|
|
1154
1154
|
end
|
1155
1155
|
end
|
1156
1156
|
end
|
1157
|
-
end
|
1157
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ip2location_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.7.
|
4
|
+
version: 8.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ip2location
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -67,9 +67,11 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.2.0
|
69
69
|
description: The official IP2Location Ruby library to geolocate an IP address. You
|
70
|
-
can lookup for country, region, city, latitude
|
71
|
-
|
72
|
-
|
70
|
+
can lookup for country, region, district, city, latitude and longitude, ZIP/Postal
|
71
|
+
code, time zone, Internet Service Provider (ISP) or company name, domain name, net
|
72
|
+
speed, area code, weather station code, weather station name, mobile country code
|
73
|
+
(MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address
|
74
|
+
type, IAB category and ASN from an IP address. Supported both IPv4 and IPv6 lookup.
|
73
75
|
email: support@ip2location.com
|
74
76
|
executables: []
|
75
77
|
extensions: []
|