network_address_calculator 0.0.1 → 0.0.2
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/network_address_calculator.rb +5 -0
- data/lib/network_address_calculator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a8aa43401061850ca1124c62e138be823599ca
|
4
|
+
data.tar.gz: f628f363f2a0d30c6dd0fc59380e4e6dd1c1aafc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e6301477c79a05eb31542abf8177c027c56ec144047bb0661e77d51d792b6e71fa0a0f8bc3cef18e927a20d003885df6c512a659128c38ad1be71d39d5303f
|
7
|
+
data.tar.gz: 7c6b9f85813066a2d8e62c614cd95caa25188a352a0f9aa63ae3ffad35b1cf070906f878737d88335765c77105fbf63477180c9cf24b542b7ba36a3ab31fb3e9
|
@@ -6,6 +6,10 @@ module NetworkAddressCalculator
|
|
6
6
|
|
7
7
|
def self.next_free_subnets(supernet, subnets, no_of_subnets=1, slash=24)
|
8
8
|
|
9
|
+
if subnets.empty?
|
10
|
+
subnets = [NetAddr::CIDR.create(supernet).ip+"/32"]
|
11
|
+
end
|
12
|
+
|
9
13
|
if IP.new(supernet).size < get_host_count_from_slash(slash)
|
10
14
|
raise ArgumentError, "Requested range is bigger than supernet"
|
11
15
|
end
|
@@ -30,6 +34,7 @@ module NetworkAddressCalculator
|
|
30
34
|
used_subnets = []
|
31
35
|
supernet = NetAddr::CIDR.create(supernet.to_s)
|
32
36
|
|
37
|
+
|
33
38
|
subnets.each do |x|
|
34
39
|
used_subnets << NetAddr::CIDR.create(x)
|
35
40
|
end
|