ipaddr-ext 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.
- checksums.yaml +4 -4
- data/lib/ipaddr-ext/json.rb +15 -3
- data/lib/ipaddr-ext/version.rb +1 -1
- data/lib/ipaddr-ext.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf80589f0fb436a83b743951bda416d1797bcfed488cad15b26f40378f95df7b
|
4
|
+
data.tar.gz: 6159ab041b42951c635bafc9b7feab379071d5044f9a03133ccd533a2b166e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e8bcd61f275230ae3ec8937e11d4ef511e188b3487956c3058d50a30552c26afd5a84a4b6f08265b05c1a43d98aebeb8dcc0f70b54dc4cf8f5b6ad843c058db
|
7
|
+
data.tar.gz: ee6b3b25223c78ac7823c13f7fa56c34a443f5d83170a6c0b5a2d52a1f872a72e9277681f80a6f6fcc3f5be7d873ebc5b986fcde427a22443c981ab713ba1ba9
|
data/lib/ipaddr-ext/json.rb
CHANGED
@@ -2,13 +2,25 @@
|
|
2
2
|
|
3
3
|
module IPAddrExt
|
4
4
|
module JSON
|
5
|
+
# Fix ActiveSupport::JSON.encode which remove the prefix address when encode with IPAddr/CIDR
|
6
|
+
# https://github.com/rails/rails/issues/46006
|
7
|
+
def self.remove_as_json
|
8
|
+
if IPAddr.method_defined? :as_json
|
9
|
+
IPAddr.remove_method :as_json
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
def to_json
|
14
|
+
format("\"%s\"", as_json)
|
15
|
+
end
|
16
|
+
|
17
|
+
def as_json(options = nil)
|
6
18
|
if ipv4? && prefix == 32
|
7
|
-
|
19
|
+
to_s
|
8
20
|
elsif ipv6? && prefix == 128
|
9
|
-
|
21
|
+
to_s
|
10
22
|
else
|
11
|
-
format("
|
23
|
+
format("%s/%s", to_s, prefix)
|
12
24
|
end
|
13
25
|
end
|
14
26
|
end
|
data/lib/ipaddr-ext/version.rb
CHANGED
data/lib/ipaddr-ext.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipaddr-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taketo Takashima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|