lookupip 0.1.2 → 0.1.3
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/README.md +9 -12
- data/lib/lookupip/v4.rb +11 -3
- data/lib/lookupip/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07eb1a9f3efa25cd53ebb955b92e6112dcf1e560
|
4
|
+
data.tar.gz: 4f12d27a140f64fbd4e38cff08572b9cbccae596
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '087ca7088feb7578715db26455bec190924a6bb851b2849ef4045763691f909d95d7bf640557d0ed86bf78fc952773719ce2a523955d48a6ef867a839629a3ff'
|
7
|
+
data.tar.gz: 6845dd6d763c0c3c343dc2e42112fe15dd70823c7c07c4a51834d1c6c11df4c9a649298b67040fff880b807adaac0c7b1e6c2191303994b68fb112baf701577f
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Lookupip
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Easy way to find ip address informations.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -26,21 +24,20 @@ Or install it yourself as:
|
|
26
24
|
require 'lookupip'
|
27
25
|
|
28
26
|
# IPv4
|
29
|
-
ip_info = LookupIP::V4.address '30.104.194.91'
|
30
|
-
puts ip_info.country #=> "United States"
|
31
|
-
puts ip_info.city #=> "Columbus"
|
32
|
-
puts ip_info.isp #=> "DoD Network Information Center"
|
33
|
-
```
|
34
27
|
|
35
|
-
|
28
|
+
ip_info = LookupIP::V4.address '30.104.194.91'
|
36
29
|
|
37
|
-
|
30
|
+
puts ip_info.country #=> "United States"
|
31
|
+
puts ip.state #=> "Ohio"
|
32
|
+
puts ip_info.city #=> "Columbus"
|
33
|
+
puts ip_info.isp #=> "DoD Network Information Center"
|
34
|
+
puts ip_info.code #=> "US"
|
35
|
+
```
|
38
36
|
|
39
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
37
|
|
41
38
|
## Contributing
|
42
39
|
|
43
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/0x2C6/LookupIP.
|
44
41
|
|
45
42
|
## License
|
46
43
|
|
data/lib/lookupip/v4.rb
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'uri'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
module LookupIP
|
6
7
|
class V4
|
7
|
-
attr_reader :ip, :country, :state, :city, :isp
|
8
|
+
attr_reader :ip, :country, :state, :city, :isp, :code
|
8
9
|
def initialize(ip, country, state, city, isp)
|
9
10
|
@ip = ip
|
10
11
|
@country = country
|
11
12
|
@state = state
|
12
13
|
@city = city
|
13
14
|
@isp = isp
|
15
|
+
@code = get_country_codes(@country)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_country_codes(country)
|
19
|
+
@@country_code = JSON.parse(Net::HTTP.get(URI(
|
20
|
+
'https://pkgstore.datahub.io/core/country-list/data_json/data/8c458f2d15d9f2119654b29ede6e45b8/data_json.json'
|
21
|
+
))).find{ |c| c['Name'] == country }['Code']
|
14
22
|
end
|
15
23
|
|
16
24
|
def self.address(ip)
|
@@ -18,12 +26,12 @@ module LookupIP
|
|
18
26
|
uri = URI("https://www.iplocation.net/?query=#{@ip}&submit=IP+Lookup")
|
19
27
|
page = Net::HTTP.get(uri)
|
20
28
|
page = Nokogiri::HTML(page)
|
21
|
-
|
29
|
+
@@results = LookupIP::V4.new(
|
22
30
|
@ip,
|
23
31
|
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[2]').text.strip,
|
24
32
|
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[3]').text.strip,
|
25
33
|
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[4]').text.strip,
|
26
|
-
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[2]/tr/td[1]').text.strip
|
34
|
+
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[2]/tr/td[1]').text.strip,
|
27
35
|
)
|
28
36
|
end
|
29
37
|
end
|
data/lib/lookupip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookupip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Farhad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|