Skip to content

Commit 977447c

Browse files
Added supports for address type and category fields. Added exception handling for incorrect BIN database.
1 parent fa7c889 commit 977447c

13 files changed

Lines changed: 234 additions & 59 deletions

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 IP2Location ( support@ip2location.com )
1+
Copyright (c) 2021 IP2Location ( support@ip2location.com )
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Total Downloads](https://img.shields.io/gem/dt/ip2location_ruby.svg)](https://rubygems.org/gems/ip2location_ruby)
33

44
# 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, and usage type by IP address or hostname originates from. 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, 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.
66

77
Supported IPv4 and IPv6 address.
88

@@ -19,6 +19,10 @@ Below is the description of the functions available in the **BIN Database** look
1919
|---|---|
2020
| open | Open the IP2Location BIN data for lookup. |
2121
| close | Close and clean up the file pointer. |
22+
| get_package_version | Get the package version (1 to 25 for DB1 to DB25 respectively). |
23+
| get_module_version | Get the module version. |
24+
| get_database_version | Get the database version. |
25+
| get_last_error_message | Return the last error message. |
2226
| get_all | Return the geolocation information in array. |
2327
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
2428
| get_country_long | Return the ISO3166-1 country name of the IP address. |
@@ -40,15 +44,17 @@ Below is the description of the functions available in the **BIN Database** look
4044
| get_mobilebrand | Commercial brand associated with the mobile carrier. |
4145
| get_elevation | Return average height of city above sea level in meters (m). |
4246
| get_usagetype | Return the ISP's usage type of IP address. |
47+
| get_addresstype | Returns the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
48+
| category | Returns the IAB content taxonomy category of IP address or domain name. |
4349

4450

4551
## Web Service
4652
Below is the description of the functions available in the **Web Service** lookup.
4753

4854
| Function Name | Description |
4955
|---|---|
50-
| Constructor | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS24)</li></li><li>Use HTTPS or HTTP</li></ol> |
51-
| 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>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> |
56+
| Constructor | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li></li><li>Use HTTPS or HTTP</li></ol> |
57+
| 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> |
5258
| get_credit | Return remaining credit of the web service account. |
5359

5460
# Dependencies

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.3
1+
8.3.0

example.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
print record['elevation']
3131
print "\n"
3232
print 'Usage Type: ' + record['usagetype'] + "\n"
33+
print 'Address Type: ' + record['addresstype'] + "\n"
34+
print 'Category: ' + record['category'] + "\n"
3335

3436
i2l.close()
3537

3638
# Web Service
37-
ws = Ip2locationWebService.new('demo', 'WS24', true)
39+
ws = Ip2locationWebService.new('demo', 'WS25', true)
3840
record = ws.lookup('8.8.8.8', 'continent,country,region,city,geotargeting,country_groupings,time_zone_info', 'en')
3941
print record
4042
print "\n"

ip2location_ruby-8.3.0.gem

2 MB
Binary file not shown.

ip2location_ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Gem::Specification.new do |s|
77
s.name = "ip2location_ruby"
8-
s.version = "8.2.3"
8+
s.version = "8.3.0"
99

1010
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
1111
s.require_paths = ["lib"]

0 commit comments

Comments
 (0)