better_ipaddr 0.4.0 → 0.5.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/better_ipaddr/classes.rb +4 -0
- data/lib/better_ipaddr/methods.rb +23 -5
- data/lib/better_ipaddr/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 871dfdaf9d8e064ae09988a53d3e991544d414a9
|
4
|
+
data.tar.gz: 3d3229104847532b1713497982473e6f08520ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d24bedd14d52e7f729af783387d2fe956b9ad4da55bbbfc624ec041046da05854dfcb573b855d131bc727aaa5f74cf879ff3dee01b592b635403c7ce60c5c4a3
|
7
|
+
data.tar.gz: 90bcb07ddb3ee7899fa8d8c53d193806004c016e4bf9cc21a1ed3160155edc944f420be46284e4a441cfbc361477a3fe9c447fa751b1ecd24dbcc5aab293b7f9
|
@@ -45,6 +45,13 @@ module BetterIpaddr
|
|
45
45
|
module InstanceMethods
|
46
46
|
include Constants
|
47
47
|
|
48
|
+
def self.included(base)
|
49
|
+
return unless base <= IPAddr
|
50
|
+
base.class_eval do
|
51
|
+
define_method :stdlib_to_s, IPAddr.instance_method(:to_s)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
48
55
|
# Return the magic number representing the address family.
|
49
56
|
# @return [Integer]
|
50
57
|
attr_reader :family
|
@@ -149,17 +156,28 @@ module BetterIpaddr
|
|
149
156
|
#
|
150
157
|
# @return [String]
|
151
158
|
|
152
|
-
def base
|
153
|
-
|
159
|
+
def base(full: false)
|
160
|
+
if full
|
161
|
+
to_string
|
162
|
+
else
|
163
|
+
stdlib_to_s
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def better_to_s(cidr: false, full: false)
|
168
|
+
if cidr
|
169
|
+
"#{base(full: full)}/#{prefix_length}"
|
170
|
+
else
|
171
|
+
base(full: full)
|
172
|
+
end
|
154
173
|
end
|
155
174
|
|
156
175
|
# Return a string containing the CIDR representation of the address.
|
157
176
|
#
|
158
177
|
# @return [String]
|
159
178
|
|
160
|
-
def cidr
|
161
|
-
|
162
|
-
"#{_to_string(@addr)}/#{prefixlen}"
|
179
|
+
def cidr(cidr: nil, full: false)
|
180
|
+
better_to_s(cidr: true, full: full)
|
163
181
|
end
|
164
182
|
|
165
183
|
# Test whether or not this address completely encloses the other address.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_ipaddr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,4 +103,3 @@ signing_key:
|
|
103
103
|
specification_version: 4
|
104
104
|
summary: IPAddr enhancements for network management.
|
105
105
|
test_files: []
|
106
|
-
has_rdoc:
|