ip2location_ruby 8.7.0 → 8.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07d9738099db961a6661f7266017f4f5cf8156cb0b0e2063bf1e2a246dfe39f4
4
- data.tar.gz: 9f4e8c1f7c60a58687e8d922816e69e6ddbaa4f4bd06dd9b0938a194278f8188
3
+ metadata.gz: 9172b1c0b6b238c12d44df60b765218045e6fc3d27e3b2c551e2613bd9cf23cd
4
+ data.tar.gz: 4a45aad55ad12dbd2a80b6093d3f228e0fc57399f78a5238fa738a5fbaff3f27
5
5
  SHA512:
6
- metadata.gz: 5417dcb43c59394ad2500f0e79ec109fc75bb70b0afca917c3150cd0ac6da7168e94b4381e01624fa8ee43ef05a9ed5bd148a4539c6d90ab23ed927cd2ff4cd2
7
- data.tar.gz: 7a60ef9c3759e47b1c2699378103fbfbf3fde9e8007ecfee424739a9226cd0b9e24852e1e11b4f758f2fb67e9eeefc06845688da98d42043b02aaa4d9c8187c3
6
+ metadata.gz: 1d83b024d3f3357b35552f236e55ab482f8fdbc3cd059b8ed27d5cd5b02eeb2e2ccf535fb5cde230b0b9445ea0c5dc5326a6fc9f706d5745f9adbaf60a6f7d9b
7
+ data.tar.gz: cac3c8810e8b30a65d0b6a92e75ef872169b1f4880c1dbc2758be3bc79645fed97ed962afa2fabddbfa104d7664af6b3f0fd4ec1bf26a75219eda45e1fc584fc
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
  [![Total Downloads](https://img.shields.io/gem/dt/ip2location_ruby.svg)](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, US ZIP 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, IP address type and IAB advertising category from IP address using IP2Location database. The library reads the geo location information from **IP2Location BIN data** file or web service.
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
- # INSTALLATION
13
- Install this package using the command as below:
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.0
1
+ 8.7.2
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ip2location_ruby"
3
- s.version = "8.7.0"
3
+ s.version = "8.7.2"
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, longitude, zip code, time zone, ISP, domain, area code, usage type, mobile data, weather data and elevation from an IP address. Supported both IPv4 and IPv6 lookup."
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",
@@ -33,8 +33,8 @@ class DbConfig
33
33
  memo
34
34
  }
35
35
  # order by value
36
- col_array = cols.sort_by {|key,value| value}
36
+ cols.sort_by {|key,value| value}
37
37
  end
38
38
 
39
39
  end
40
-
40
+
@@ -1,7 +1,7 @@
1
1
  class I2lFloatData < BinData::BasePrimitive
2
2
 
3
3
  def read_and_return_value(io)
4
- addr = BinData::FloatLe.read(io)
4
+ BinData::FloatLe.read(io)
5
5
  end
6
6
 
7
- end
7
+ end
@@ -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
- addr = BinData::Uint32le.read(io)
5
+ BinData::Uint32le.read(io)
6
6
  elsif iv == 6
7
- addr = BinData::Uint128le.read(io)
7
+ BinData::Uint128le.read(io)
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -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.0'
17
+ VERSION = '8.7.2'
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
@@ -988,7 +988,7 @@ class Ip2locationIpTools
988
988
 
989
989
  def cidr_to_ipv6(cidr)
990
990
  if cidr.include? "/"
991
- ip_start = IPAddr.new(cidr.to_s.split('/').first).to_i.to_s(16).scan(/.{4}/)
991
+ ip_start = IPAddr.new(cidr).to_i.to_s(16).scan(/.{4}/)
992
992
  ip_start = ip_start[0] + ':' + ip_start[1] + ':' + ip_start[2] + ':' + ip_start[3] + ':' + ip_start[4] + ':' + ip_start[5] + ':' + ip_start[6] + ':' + ip_start[7]
993
993
 
994
994
  cidr_new = IPAddr.new(cidr)
@@ -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.0
4
+ version: 8.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ip2location
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-04 00:00:00.000000000 Z
11
+ date: 2023-11-15 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, longitude, zip code, time zone,
71
- ISP, domain, area code, usage type, mobile data, weather data and elevation from
72
- an IP address. Supported both IPv4 and IPv6 lookup.
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: []