ipify 0.1.0 → 0.2.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ipify.rb +13 -0
  3. data/lib/ipify/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21fd9dfcc11cfb8e5beb37d22ccc1ecaf664884e
4
- data.tar.gz: 81e01fca75bd48172c671786a386183f84341742
3
+ metadata.gz: 46049822ec6b7e96bfa5cba35ea23deb488121b0
4
+ data.tar.gz: f0bfbe5590f2b0db342d2d1de3d8d78d1db14c35
5
5
  SHA512:
6
- metadata.gz: 063da2714a5e4de12a6afc6da1222b0fd57665f4f13ecdcaf317f6ceb9de6275fe754b69a2e3c740adaa4f60f183dc125d1aca364fc928f7c11115296e05d28b
7
- data.tar.gz: 3480d9ec93f888f2d6c62ae3ad8c3d17b14dca5b4dc0fbb8c2bacb4dd9e0f0b2571be1707ede263e49e46f817fe2c853286e2314b0a3284ccef4d03205e7708d
6
+ metadata.gz: 243b954291d381cccd564d5145e2990fa497171ef43c8acfe8c013055eb60afb04298791cbfc7ee635dab985c1dba7968b383bc3e3127549a0387ecbb22e38b1
7
+ data.tar.gz: 2292821c3a48c65b9b7904ab499b8d50fdc4c4eca89fdeae515661f6ff8f2257cd82d372385e02a8169576284dbe678ef9b55bccb6408e2a54eff9aea9b89a43
data/lib/ipify.rb CHANGED
@@ -4,7 +4,19 @@ require 'retriable'
4
4
 
5
5
  module Ipify
6
6
 
7
+ # Requests this machine's IP address from the ipify.org service. Will retry up to 3 times
8
+ # until ultimately returning +nil+.
9
+ #
10
+ # @return [String] external ip address, or +nil+ if unsuccessful
7
11
  def self.ip
12
+ ip! rescue nil
13
+ end
14
+
15
+ # Requests this machine's IP address from the ipify.org service. Will retry up to 3 times
16
+ # until ultimately raising the last exception encountered.
17
+ #
18
+ # @return [String] external ip address
19
+ def self.ip!
8
20
  http = build_http
9
21
  Retriable.retriable tries: 3 do
10
22
  http.get('/').body
@@ -13,6 +25,7 @@ module Ipify
13
25
 
14
26
  private
15
27
 
28
+ # @return [Net::HTTP] http client
16
29
  def self.build_http
17
30
  uri = URI('https://api.ipify.org')
18
31
  http = Net::HTTP.new(uri.host, uri.port)
data/lib/ipify/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ipify
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys