immosquare-constants 0.1.4 → 0.1.5
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/lib/immosquare-constants/ip.rb +34 -0
- data/lib/immosquare-constants/version.rb +1 -1
- data/lib/immosquare-constants.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2516ca9a9f09d6bd9050f27e88b64b1b00dfbfb8e071cc7d3212f8d5f25cc19e
|
4
|
+
data.tar.gz: d41821675b3fc25604cb7ed57f5ad68971eec7199392c164bf16a6134fdcbf5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d112eaf32e54fa1d6bb9e3a422d77416ff7452488961529579da39ce74447e4d1c7a0a10932aa8543a1d4197e660b0ef47ee71fb7a34b905ed3d313e0e13ce
|
7
|
+
data.tar.gz: c429c7f583c21fd6ec16ebac768b2b8db5baa2c6b80e60ececce79ea5485fb774fefb8b79fc22bdcce59fbd238d1c82dc90f8164b3a8cbd7a9b55f6527267a34
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "socket"
|
2
|
+
require "net/http"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module ImmosquareConstants
|
6
|
+
module Ip
|
7
|
+
class << self
|
8
|
+
|
9
|
+
##============================================================##
|
10
|
+
## On récupère l'IP réelle
|
11
|
+
##============================================================##
|
12
|
+
def get_real_ip
|
13
|
+
begin
|
14
|
+
begin
|
15
|
+
uri = URI.parse("https://checkip.amazonaws.com/")
|
16
|
+
response = Net::HTTP.get_response(uri)
|
17
|
+
raise("No IP found") unless response.is_a?(Net::HTTPSuccess)
|
18
|
+
|
19
|
+
response.body.strip
|
20
|
+
rescue StandardError => e
|
21
|
+
s = Socket.ip_address_list.find(&:ipv4_private?)
|
22
|
+
s = Socket.ip_address_list.first if s.blank?
|
23
|
+
raise("No IP found") if s.blank?
|
24
|
+
|
25
|
+
s.ip_address
|
26
|
+
end
|
27
|
+
rescue StandardError => e
|
28
|
+
"0.0.0.0"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/immosquare-constants.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-constants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ImmosquareConstants gem provides a robust set of constants to facilitate
|
14
14
|
application development across various domains
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- lib/immosquare-constants.rb
|
22
22
|
- lib/immosquare-constants/color.rb
|
23
|
+
- lib/immosquare-constants/ip.rb
|
23
24
|
- lib/immosquare-constants/locale.rb
|
24
25
|
- lib/immosquare-constants/regex.rb
|
25
26
|
- lib/immosquare-constants/version.rb
|
@@ -42,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
43
|
- !ruby/object:Gem::Version
|
43
44
|
version: '0'
|
44
45
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
46
|
+
rubygems_version: 3.5.11
|
46
47
|
signing_key:
|
47
48
|
specification_version: 4
|
48
49
|
summary: ImmosquareConstants is a comprehensive collection of constants useful for
|