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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b66dc71166a72385fc57f8ca295de970863a611525758a2915f7af8d125134ba
4
- data.tar.gz: 9eaccf234fbedb822ca65444a3ca8adb8baa7fc50bfa9be3e32ff38bf11860cf
3
+ metadata.gz: 2516ca9a9f09d6bd9050f27e88b64b1b00dfbfb8e071cc7d3212f8d5f25cc19e
4
+ data.tar.gz: d41821675b3fc25604cb7ed57f5ad68971eec7199392c164bf16a6134fdcbf5c
5
5
  SHA512:
6
- metadata.gz: '08e16b7c3551beaa21fb9a9072489916092c28c61c8499d389f92ce06ccc699f68ca1ed9e52db153f359cb881b7e33d57f8d0f173e1c992fbdf7be755bfdbe3a'
7
- data.tar.gz: 2bcaf01f1c7b13f7aa154fbea68c5b559902441d68308721049176402bea7e6fd208eb83ae2134aa0c34ac762160f7a3fd1529e4aadf8b324e97481f9a861494
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
@@ -1,3 +1,3 @@
1
1
  module ImmosquareConstants
2
- VERSION = "0.1.4".freeze
2
+ VERSION = "0.1.5".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
- require "immosquare-constants/locale"
2
1
  require "immosquare-constants/color"
2
+ require "immosquare-constants/ip"
3
+ require "immosquare-constants/locale"
3
4
  require "immosquare-constants/regex"
4
5
 
5
6
  module ImmosquareConstants
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
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: 2023-11-27 00:00:00.000000000 Z
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.4.13
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