immosquare-constants 0.1.14 → 0.1.16

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: 4b0e58e67146383f7bb046bc321ac80ae421919e732b8ef6e601db0921a952a3
4
- data.tar.gz: 86dcdc2878e7ab49df7f3b51741b2061b7114d8256d3bd362bb03084b20ec940
3
+ metadata.gz: 97b58fa8bdcd04000abd024afae97165b9b11d0e1e38fcb36bf2233af0926895
4
+ data.tar.gz: f4e113d541371b985f6c75f58c9bc7964adc75c28880ee24c13347696c6c34c4
5
5
  SHA512:
6
- metadata.gz: 77cb31bd52a176a82bb5909f42e5d45068f6baefdb1f691cbaf147091d53ddbdb17eedfaa086e1d3d026ea59362a81563a70059599045f93012d0c529b174038
7
- data.tar.gz: 138cf03ab85646ff1c7bea7498c04897f566933bb515e44f731404cd1d69baaded686171e4715b911fa5b4432ae3b406adac1412476bd8cb5b9233f088161020
6
+ metadata.gz: e69deefa3385c84aeb8b666f08cb5a34fe53c114f382cd18c3dfcc2a139a28059489509ec6b3cfc2a94beb66bb34f9ea97065bc022bede2931f203f542c407f5
7
+ data.tar.gz: 72cb4e752a34f992c61ce00defa1967b8b0c3efa2092285d38b237e7e1f54a713d088fb1d4801fbab27f0e5a3e1cf8350622b9c1568e9a0433f00fde81237d67
@@ -50,6 +50,14 @@ module ImmosquareConstants
50
50
  to_hash
51
51
  end
52
52
 
53
+ def each(&)
54
+ to_hash.each(&)
55
+ end
56
+
57
+ def each_with_index(&)
58
+ to_hash.each_with_index(&)
59
+ end
60
+
53
61
  end
54
62
 
55
63
  class << self
@@ -113,30 +121,34 @@ module ImmosquareConstants
113
121
  raise("IP is localhost (127.0.0.1)") if ip == "127.0.0.1"
114
122
 
115
123
  ip
116
- rescue StandardError => e
124
+ rescue StandardError
117
125
  get_public_ip_from_aws
118
126
  end
119
127
  end
120
128
 
121
129
  ##============================================================##
122
- ## Get public IP address with fallback (for production)
130
+ ## Get public IP address with fallback
123
131
  ##============================================================##
124
132
  def get_public_ip_from_aws
125
133
  begin
126
134
  begin
127
- uri = URI.parse("https://checkip.amazonaws.com/")
128
- response = Net::HTTP.get_response(uri)
129
- raise("No IP found") unless response.is_a?(Net::HTTPSuccess)
135
+ uri = URI.parse("https://checkip.amazonaws.com/")
136
+ http = Net::HTTP.new(uri.host, uri.port)
137
+ http.use_ssl = true
138
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
139
+ response = http.get(uri.request_uri)
140
+ raise("No IP found") if !response.is_a?(Net::HTTPSuccess)
130
141
 
131
142
  response.body.strip
132
143
  rescue StandardError => e
144
+ puts("Error getting public IP from AWS: #{e.message}")
133
145
  s = Socket.ip_address_list.find(&:ipv4_private?)
134
146
  s = Socket.ip_address_list.first if s.nil?
135
147
  raise("No IP found") if s.nil?
136
148
 
137
149
  s.ip_address
138
150
  end
139
- rescue StandardError => e
151
+ rescue StandardError
140
152
  "0.0.0.0"
141
153
  end
142
154
  end
@@ -1,3 +1,3 @@
1
1
  module ImmosquareConstants
2
- VERSION = "0.1.14".freeze
2
+ VERSION = "0.1.16".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-constants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  requirements: []
44
- rubygems_version: 3.6.9
44
+ rubygems_version: 3.7.2
45
45
  specification_version: 4
46
46
  summary: ImmosquareConstants is a comprehensive collection of constants useful for
47
47
  a variety of applications.