ip2location_rails 1.0.0 → 1.1.0
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/LICENSE.txt +1 -1
- data/README.md +9 -0
- data/ip2location_rails.gemspec +28 -20
- data/lib/ip2location_rails.rb +124 -112
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c2eaa6af9e2b19c4e3564406b69a7e21bf38458166a45beaee9cf6335de3827
|
|
4
|
+
data.tar.gz: 89ecb1996b2a4f469550c2524a3ad2b8141074fde4eea3efe9af79f193df1b47
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d4a8ba257c47ad48815fd9fdfd426c5f38c2f491c066befc3b37e92e031f15bc426801c057d80e05c6d13293ec96494117b4d6cd68a9d9b892321c198f291fc
|
|
7
|
+
data.tar.gz: 6756ecfb73aa17e3782a96a659dde2997950bca17bf4ee15b0376f170c9cb8125a9d0ccbfb7ef5481363e0e1640cce5b1df69a6e99efbbecab928a4bf3dea6d5
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
[](https://rubygems.org/gems/ip2location_rails)
|
|
2
|
+
[](https://rubygems.org/gems/ip2location_rails)
|
|
3
|
+
|
|
1
4
|
# IP2Location Ruby on Rails Library
|
|
2
5
|
This is IP2Location Ruby on Rails 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.
|
|
3
6
|
|
|
@@ -62,6 +65,9 @@ class TestController < ApplicationController
|
|
|
62
65
|
@district = location_service.district
|
|
63
66
|
@asn = location_service.asn
|
|
64
67
|
@as = location_service.as
|
|
68
|
+
@as_domain = location_service.as_domain
|
|
69
|
+
@as_usagetype = location_service.as_usagetype
|
|
70
|
+
@as_cidr = location_service.as_cidr
|
|
65
71
|
end
|
|
66
72
|
end
|
|
67
73
|
```
|
|
@@ -92,6 +98,9 @@ end
|
|
|
92
98
|
<p>District: <%= @district %></p>
|
|
93
99
|
<p>ASN: <%= @asn %></p>
|
|
94
100
|
<p>AS: <%= @as %></p>
|
|
101
|
+
<p>AS Domain: <%= @as_domain %></p>
|
|
102
|
+
<p>AS Usage Type: <%= @as_usagetype %></p>
|
|
103
|
+
<p>AS CIDR: <%= @as_cidr %></p>
|
|
95
104
|
```
|
|
96
105
|
9. Add the following line into the *config/routes.rb* file after the `Rails.application.routes.draw do` line.
|
|
97
106
|
```ruby
|
data/ip2location_rails.gemspec
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
Gem::Specification.new do |s|
|
|
2
|
-
s.name = 'ip2location_rails'
|
|
3
|
-
s.version = '1.
|
|
4
|
-
s.required_ruby_version = '>= 2.5.0'
|
|
5
|
-
s.require_paths = ["lib"]
|
|
6
|
-
s.authors = ["ip2location"]
|
|
7
|
-
s.email = ["support@ip2location.com"]
|
|
8
|
-
s.description = "The official IP2Location Ruby on Rails 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."
|
|
9
|
-
s.summary = "IP2Location Ruby on Rails library"
|
|
10
|
-
s.homepage = 'https://www.ip2location.com'
|
|
11
|
-
s.licenses = ["MIT"]
|
|
12
|
-
s.files = [
|
|
13
|
-
"LICENSE.txt",
|
|
14
|
-
"Gemfile",
|
|
15
|
-
"README.md",
|
|
16
|
-
"ip2location_rails.gemspec",
|
|
17
|
-
"lib/ip2location_rails.rb",
|
|
18
|
-
]
|
|
19
|
-
s.
|
|
20
|
-
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = 'ip2location_rails'
|
|
3
|
+
s.version = '1.1.0'
|
|
4
|
+
s.required_ruby_version = '>= 2.5.0'
|
|
5
|
+
s.require_paths = ["lib"]
|
|
6
|
+
s.authors = ["ip2location"]
|
|
7
|
+
s.email = ["support@ip2location.com"]
|
|
8
|
+
s.description = "The official IP2Location Ruby on Rails 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."
|
|
9
|
+
s.summary = "IP2Location Ruby on Rails library"
|
|
10
|
+
s.homepage = 'https://www.ip2location.com'
|
|
11
|
+
s.licenses = ["MIT"]
|
|
12
|
+
s.files = [
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"Gemfile",
|
|
15
|
+
"README.md",
|
|
16
|
+
"ip2location_rails.gemspec",
|
|
17
|
+
"lib/ip2location_rails.rb",
|
|
18
|
+
]
|
|
19
|
+
if s.respond_to?(:metadata=)
|
|
20
|
+
s.metadata = {
|
|
21
|
+
"bug_tracker_uri" => "https://github.com/ip2location/ip2location-rails/issues",
|
|
22
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/ip2location_rails",
|
|
23
|
+
"homepage_uri" => "https://www.ip2location.com",
|
|
24
|
+
"source_code_uri" => "https://github.com/ip2location/ip2location-rails",
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
s.add_runtime_dependency 'ip2location_ruby', '>= 8.7.3'
|
|
28
|
+
end
|
data/lib/ip2location_rails.rb
CHANGED
|
@@ -1,112 +1,124 @@
|
|
|
1
|
-
require 'ip2location_ruby'
|
|
2
|
-
|
|
3
|
-
class Ip2locationRails
|
|
4
|
-
def initialize(ip_address)
|
|
5
|
-
@ip_address = ip_address
|
|
6
|
-
@i2l = Ip2location.new.open(Rails.configuration.ip2location_db_path)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def location
|
|
10
|
-
@i2l.get_all(@ip_address)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def country_code
|
|
14
|
-
location['country_short']
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def country_name
|
|
18
|
-
location['country_long']
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def region
|
|
22
|
-
location['region']
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def city
|
|
26
|
-
location['city']
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def latitude
|
|
30
|
-
location['latitude']
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def longitude
|
|
34
|
-
location['longitude']
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def isp
|
|
38
|
-
location['isp']
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def domain
|
|
42
|
-
location['domain']
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def netspeed
|
|
46
|
-
location['netspeed']
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def areacode
|
|
50
|
-
location['areacode']
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def iddcode
|
|
54
|
-
location['iddcode']
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def timezone
|
|
58
|
-
location['timezone']
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def zipcode
|
|
62
|
-
location['zipcode']
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def weatherstationname
|
|
66
|
-
location['weatherstationname']
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def weatherstationcode
|
|
70
|
-
location['weatherstationcode']
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def mcc
|
|
74
|
-
location['mcc']
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def mnc
|
|
78
|
-
location['mnc']
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def mobilebrand
|
|
82
|
-
location['mobilebrand']
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def elevation
|
|
86
|
-
location['elevation']
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def usagetype
|
|
90
|
-
location['usagetype']
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def addresstype
|
|
94
|
-
location['addresstype']
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def category
|
|
98
|
-
location['category']
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def district
|
|
102
|
-
location['district']
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def asn
|
|
106
|
-
location['asn']
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def as
|
|
110
|
-
location['as']
|
|
111
|
-
end
|
|
112
|
-
|
|
1
|
+
require 'ip2location_ruby'
|
|
2
|
+
|
|
3
|
+
class Ip2locationRails
|
|
4
|
+
def initialize(ip_address)
|
|
5
|
+
@ip_address = ip_address
|
|
6
|
+
@i2l = Ip2location.new.open(Rails.configuration.ip2location_db_path)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def location
|
|
10
|
+
@i2l.get_all(@ip_address)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def country_code
|
|
14
|
+
location['country_short']
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def country_name
|
|
18
|
+
location['country_long']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def region
|
|
22
|
+
location['region']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def city
|
|
26
|
+
location['city']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def latitude
|
|
30
|
+
location['latitude']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def longitude
|
|
34
|
+
location['longitude']
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def isp
|
|
38
|
+
location['isp']
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def domain
|
|
42
|
+
location['domain']
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def netspeed
|
|
46
|
+
location['netspeed']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def areacode
|
|
50
|
+
location['areacode']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def iddcode
|
|
54
|
+
location['iddcode']
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def timezone
|
|
58
|
+
location['timezone']
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def zipcode
|
|
62
|
+
location['zipcode']
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def weatherstationname
|
|
66
|
+
location['weatherstationname']
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def weatherstationcode
|
|
70
|
+
location['weatherstationcode']
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def mcc
|
|
74
|
+
location['mcc']
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def mnc
|
|
78
|
+
location['mnc']
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def mobilebrand
|
|
82
|
+
location['mobilebrand']
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def elevation
|
|
86
|
+
location['elevation']
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def usagetype
|
|
90
|
+
location['usagetype']
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def addresstype
|
|
94
|
+
location['addresstype']
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def category
|
|
98
|
+
location['category']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def district
|
|
102
|
+
location['district']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def asn
|
|
106
|
+
location['asn']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def as
|
|
110
|
+
location['as']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def as_domain
|
|
114
|
+
location['as_domain']
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def as_usagetype
|
|
118
|
+
location['as_usagetype']
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def as_cidr
|
|
122
|
+
location['as_cidr']
|
|
123
|
+
end
|
|
124
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ip2location_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ip2location
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ip2location_ruby
|
|
@@ -44,8 +43,11 @@ files:
|
|
|
44
43
|
homepage: https://www.ip2location.com
|
|
45
44
|
licenses:
|
|
46
45
|
- MIT
|
|
47
|
-
metadata:
|
|
48
|
-
|
|
46
|
+
metadata:
|
|
47
|
+
bug_tracker_uri: https://github.com/ip2location/ip2location-rails/issues
|
|
48
|
+
documentation_uri: https://www.rubydoc.info/gems/ip2location_rails
|
|
49
|
+
homepage_uri: https://www.ip2location.com
|
|
50
|
+
source_code_uri: https://github.com/ip2location/ip2location-rails
|
|
49
51
|
rdoc_options: []
|
|
50
52
|
require_paths:
|
|
51
53
|
- lib
|
|
@@ -60,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
60
62
|
- !ruby/object:Gem::Version
|
|
61
63
|
version: '0'
|
|
62
64
|
requirements: []
|
|
63
|
-
rubygems_version:
|
|
64
|
-
signing_key:
|
|
65
|
+
rubygems_version: 4.0.10
|
|
65
66
|
specification_version: 4
|
|
66
67
|
summary: IP2Location Ruby on Rails library
|
|
67
68
|
test_files: []
|