lookupip 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d37142ba9cdf22d567dc3ce88a1abd95962a4a37
4
- data.tar.gz: 86ff08c2e04b2aa121b32cc882c77446c3065c41
3
+ metadata.gz: df41fbd9ab23aef2864f89e387d68297e4db6e80
4
+ data.tar.gz: c9150cb9ebff076f494a10d8eb6f0141ce580976
5
5
  SHA512:
6
- metadata.gz: f655ac6b90c7ef5cb80d33612cb5c5727ef2fbf18d57a80c7227b7bd103c5984b34095f49c3eef93a56121b8e1849bf633fd8ff4ad9668546ff4e0fa97181f7f
7
- data.tar.gz: 16eff31ee42d509e34aca3b1f0ae4e5974c4ba19f09f5a5ef83ad30842c7bd2882ff5fe4b7e31f13bc4434e96ff7bf3c6d0e7298608761e227dadf68a06d45a8
6
+ metadata.gz: 99178c47c07ac3f749c379175dd5965dafe25f05302cb90c94c0877233a71b6b5805bf0f83a20f4343370e04784b74af2739168d02a70b0c32c1661d9b9f290e
7
+ data.tar.gz: 5bcb2e0b9c887c7f292d117ac282c2effb9156a79d6494accad5b701924f8311474320826126aee91e068a40e3950266ba9812d521fe1576b3017970c758fe51
@@ -1,22 +1,30 @@
1
1
  require 'net/http'
2
2
  require 'nokogiri'
3
3
  require 'uri'
4
- require 'ostruct'
5
4
 
6
5
  module LookupIP
7
6
  class V4
7
+ attr_reader :ip, :country, :state, :city, :isp
8
+ def initialize(ip, country, state, city, isp)
9
+ @ip = ip
10
+ @country = country
11
+ @state = state
12
+ @city = city
13
+ @isp = isp
14
+ end
15
+
8
16
  def self.address(ip)
9
17
  @ip = ip
10
18
  uri = URI("https://www.iplocation.net/?query=#{@ip}&submit=IP+Lookup")
11
19
  page = Net::HTTP.get(uri)
12
20
  page = Nokogiri::HTML(page)
13
- @results = OpenStruct.new({
14
- ip: @ip,
15
- country: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[2]').text.strip,
16
- state: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[3]').text.strip,
17
- city: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[4]').text.strip,
18
- isp: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[2]/tr/td[1]').text.strip
19
- })
21
+ @results = LookupIP::V4.new(
22
+ @ip,
23
+ page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[2]').text.strip,
24
+ page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[3]').text.strip,
25
+ 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
27
+ )
20
28
  end
21
29
  end
22
30
  end
@@ -1,3 +1,3 @@
1
1
  module LookupIP
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookupip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Farhad