public_ip 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/bin/public_ip +1 -1
- data/lib/public_ip.rb +2 -0
- data/lib/public_ip/service/ip_api.rb +13 -0
- data/lib/public_ip/service/ip_chicken.rb +16 -0
- data/lib/public_ip/service/ipify.rb +13 -0
- data/lib/public_ip/service/json_type.rb +19 -0
- data/lib/public_ip/service/mx_toolbox.rb +15 -0
- data/lib/public_ip/service/parsed_html.rb +13 -0
- data/lib/public_ip/service/private_internet_access.rb +15 -0
- data/lib/public_ip/service/simple.rb +3 -1
- data/lib/public_ip/service/what_is_my_ip.rb +19 -0
- data/lib/public_ip/service/wtf_is_my_ip.rb +13 -0
- data/lib/public_ip/version.rb +1 -1
- data/public_ip.gemspec +1 -0
- metadata +26 -3
- data/lib/public_ip/service/untitled +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6014ac220e8ffedcb14958f6a2d32463d756a42
|
4
|
+
data.tar.gz: 1e0ddf384845fc0e4993986e015413ad4e2a644c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 494aacfe714bdbe90586a2d995c387748d1bb949df19009d9f3ed8b2c13ad215aa26caf5e0d9eae21beac1e1840fbcc76bc4b33433657dded8ba69071cac121c
|
7
|
+
data.tar.gz: 6e827fcee2fe45fe5e808815bc59ba8bf1e124ec883c7a9de8a49ebd74e3581a41643d5b75c1a0a03b403c3c4d6beba04d0452f0c63710793ea91507ee3ad21c
|
data/.codeclimate.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# PublicIp
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/pedrocarrico/public_ip.png)](http://travis-ci.org/pedrocarrico/public_ip) [![Dependency Status](https://gemnasium.com/pedrocarrico/public_ip.png?travis)](https://gemnasium.com/pedrocarrico/public_ip) [![Gem Version](https://badge.fury.io/rb/public_ip.png)](http://badge.fury.io/rb/public_ip) [![Code Climate](https://codeclimate.com/github/pedrocarrico/public_ip/badges/gpa.svg)](https://codeclimate.com/github/pedrocarrico/public_ip)
|
3
|
+
[![Build Status](https://secure.travis-ci.org/pedrocarrico/public_ip.png)](http://travis-ci.org/pedrocarrico/public_ip) [![Dependency Status](https://gemnasium.com/pedrocarrico/public_ip.png?travis)](https://gemnasium.com/pedrocarrico/public_ip) [![Gem Version](https://badge.fury.io/rb/public_ip.png)](http://badge.fury.io/rb/public_ip) [![Code Climate](https://codeclimate.com/github/pedrocarrico/public_ip/badges/gpa.svg)](https://codeclimate.com/github/pedrocarrico/public_ip) [![Test Coverage](https://codeclimate.com/github/pedrocarrico/public_ip/badges/coverage.svg)](https://codeclimate.com/github/pedrocarrico/public_ip/coverage)
|
4
4
|
|
5
5
|
Ever questioned what is your public internet IP and you've forgotten how to do it.
|
6
6
|
Instead of remembering every service that you can query to get your public internet IP you can use this gem.
|
data/bin/public_ip
CHANGED
@@ -10,7 +10,7 @@ class App
|
|
10
10
|
|
11
11
|
main do |service|
|
12
12
|
if options['list-services']
|
13
|
-
list_of_services = PublicIp.list_services.map do |service_symbol, service_class|
|
13
|
+
list_of_services = PublicIp.list_services.sort.map do |service_symbol, service_class|
|
14
14
|
"#{service_symbol} (#{service_class.uri})"
|
15
15
|
end.join("\n")
|
16
16
|
|
data/lib/public_ip.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'public_ip/service/registry'
|
2
2
|
require 'public_ip/service/registrable'
|
3
3
|
require 'public_ip/service/simple'
|
4
|
+
require 'public_ip/service/parsed_html'
|
4
5
|
require 'public_ip/service/plain'
|
5
6
|
require 'public_ip/service/matched_expression'
|
7
|
+
require 'public_ip/service/json_type'
|
6
8
|
|
7
9
|
require 'public_ip/version'
|
8
10
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module PublicIp
|
4
|
+
module Service
|
5
|
+
class IpChicken < ParsedHTML
|
6
|
+
def self.uri
|
7
|
+
URI('http://www.ipchicken.com/')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse_ip_address(response_body)
|
11
|
+
parsed_html = Nokogiri::HTML(response_body).css('table:nth-of-type(2) p:nth-of-type(2) b')
|
12
|
+
parsed_html.text.match(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/)[0]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module PublicIp
|
4
|
+
module Service
|
5
|
+
class JsonType < Simple
|
6
|
+
extend PublicIp::Service::Registrable
|
7
|
+
|
8
|
+
def self.parse_json(_json_data)
|
9
|
+
fail 'Not implemented'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.ip
|
13
|
+
response = perform_request
|
14
|
+
|
15
|
+
parse_json(JSON.parse(response.body.strip))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module PublicIp
|
4
|
+
module Service
|
5
|
+
class MxToolbox < ParsedHTML
|
6
|
+
def self.uri
|
7
|
+
URI('http://mxtoolbox.com/WhatIsMyIP/')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse_ip_address(response_body)
|
11
|
+
Nokogiri::HTML(response_body).css('#ctl00_ContentPlaceHolder1_hlIP').text
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module PublicIp
|
4
|
+
module Service
|
5
|
+
class PrivateInternetAccess < ParsedHTML
|
6
|
+
def self.uri
|
7
|
+
URI('https://www.privateinternetaccess.com/pages/whats-my-ip/')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse_ip_address(response_body)
|
11
|
+
Nokogiri::HTML(response_body).css('.ipbox-footer ul li:first-of-type span').text.strip
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -29,7 +29,9 @@ module PublicIp
|
|
29
29
|
def self.perform_request
|
30
30
|
Timeout.timeout(PublicIp::TIMEOUT_IN_SECS) do
|
31
31
|
request = Net::HTTP::Get.new(uri, headers)
|
32
|
-
Net::HTTP.
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = (uri.scheme == 'https')
|
34
|
+
http.request(request)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module PublicIp
|
4
|
+
module Service
|
5
|
+
class WhatIsMyIp < ParsedHTML
|
6
|
+
def self.uri
|
7
|
+
URI('https://www.whatismyip.com/')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.headers
|
11
|
+
{ 'User-Agent' => 'Chrome' }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parse_ip_address(response_body)
|
15
|
+
Nokogiri::HTML(response_body).css('.ip div').text
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/public_ip/version.rb
CHANGED
data/public_ip.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public_ip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Carriço
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: methadone
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.9.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.7
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +147,7 @@ executables:
|
|
133
147
|
extensions: []
|
134
148
|
extra_rdoc_files: []
|
135
149
|
files:
|
150
|
+
- ".codeclimate.yml"
|
136
151
|
- ".gitignore"
|
137
152
|
- ".rspec"
|
138
153
|
- ".rubocop.yml"
|
@@ -153,17 +168,25 @@ files:
|
|
153
168
|
- lib/public_ip/service/i_can_haz_ip.rb
|
154
169
|
- lib/public_ip/service/ident_me.rb
|
155
170
|
- lib/public_ip/service/ifconfig_me.rb
|
171
|
+
- lib/public_ip/service/ip_api.rb
|
172
|
+
- lib/public_ip/service/ip_chicken.rb
|
156
173
|
- lib/public_ip/service/ip_echo.rb
|
157
174
|
- lib/public_ip/service/ip_info.rb
|
158
175
|
- lib/public_ip/service/ip_ogre.rb
|
176
|
+
- lib/public_ip/service/ipify.rb
|
177
|
+
- lib/public_ip/service/json_type.rb
|
159
178
|
- lib/public_ip/service/matched_expression.rb
|
179
|
+
- lib/public_ip/service/mx_toolbox.rb
|
180
|
+
- lib/public_ip/service/parsed_html.rb
|
160
181
|
- lib/public_ip/service/plain.rb
|
182
|
+
- lib/public_ip/service/private_internet_access.rb
|
161
183
|
- lib/public_ip/service/registrable.rb
|
162
184
|
- lib/public_ip/service/registry.rb
|
163
185
|
- lib/public_ip/service/simple.rb
|
164
186
|
- lib/public_ip/service/smart_ip.rb
|
165
|
-
- lib/public_ip/service/
|
187
|
+
- lib/public_ip/service/what_is_my_ip.rb
|
166
188
|
- lib/public_ip/service/what_is_my_ip_address.rb
|
189
|
+
- lib/public_ip/service/wtf_is_my_ip.rb
|
167
190
|
- lib/public_ip/version.rb
|
168
191
|
- public_ip.gemspec
|
169
192
|
homepage: https://github.com/pedrocarrico/public_ip
|
File without changes
|