ipaddr_extensions 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +2 -0
- data/ipaddr_extensions.gemspec +1 -1
- data/lib/ipaddr_extensions.rb +19 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf483a94c8f13822c09bcb94e9323a51aa6aa325
|
4
|
+
data.tar.gz: f0f734f2d9d499ded274d8df132f21bb961b75d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cc83a72b64428e8c3ca311bbb0e82a3872f4440208cba9691a3a42550775a288e5e36afa907eb24579fea8e23076a85d4d1963e58352701241231f08bb97cdf
|
7
|
+
data.tar.gz: 0f8af589f5449c7c070e3ac9a0c99589cd2cb338161842b14106d76bc3ec9506ada74f050b0964586b9d4d79b4a0a9d3059e0138af46b5433934c66a83d4acf1
|
data/README
CHANGED
@@ -50,6 +50,8 @@ Example
|
|
50
50
|
=> #<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:3039/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
|
51
51
|
>> ("2001:db8::/32".to_ip / 16).collect { |prefix| prefix.to_string_including_length }
|
52
52
|
=> ["2001:db8::/36", "2001:db8:1000::/36", "2001:db8:2000::/36", "2001:db8:3000::/36", "2001:db8:4000::/36", "2001:db8:5000::/36", "2001:db8:6000::/36", "2001:db8:7000::/36", "2001:db8:8000::/36", "2001:db8:9000::/36", "2001:db8:a000::/36", "2001:db8:b000::/36", "2001:db8:c000::/36", "2001:db8:d000::/36", "2001:db8:e000::/36", "2001:db8:f000::/36"]
|
53
|
+
=> IPAddr.new("2001:db8::/32").subnets(35)
|
54
|
+
=> [#<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:2000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:4000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:6000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:8000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:a000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:c000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>, #<IPAddr: IPv6:2001:0db8:e000:0000:0000:0000:0000:0000/ffff:ffff:e000:0000:0000:0000:0000:0000>]
|
53
55
|
|
54
56
|
|
55
57
|
Copyright (c) 2010-2013 James Harton, Resistor Limited, released under the MIT License.
|
data/ipaddr_extensions.gemspec
CHANGED
data/lib/ipaddr_extensions.rb
CHANGED
@@ -404,6 +404,8 @@ module IPAddrExtensions
|
|
404
404
|
end
|
405
405
|
end
|
406
406
|
|
407
|
+
alias cidr to_string_including_length
|
408
|
+
|
407
409
|
alias bitmask length
|
408
410
|
|
409
411
|
def /(by)
|
@@ -434,6 +436,23 @@ module IPAddrExtensions
|
|
434
436
|
end
|
435
437
|
end
|
436
438
|
|
439
|
+
def subnets(length)
|
440
|
+
unless length > self.length
|
441
|
+
raise ArgumentError, "Subnets cannot have prefix lengths longer than or equal to their supernets'"
|
442
|
+
end
|
443
|
+
if self.ipv4?
|
444
|
+
base_len = 32
|
445
|
+
elsif self.ipv6?
|
446
|
+
base_len = 128
|
447
|
+
end
|
448
|
+
(0..(2**(length-self.length))-1).collect do |i|
|
449
|
+
offset = ((base_len - self.length) - (length - self.length))
|
450
|
+
new_subnet = IPAddr.new(self.to_i + (i << offset), self.family)
|
451
|
+
new_subnet.length = length
|
452
|
+
new_subnet
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
437
456
|
def is_teredo?
|
438
457
|
IPAddr.new("2001::/32").include? self
|
439
458
|
end
|
@@ -640,7 +659,6 @@ class IPProtocol
|
|
640
659
|
81 => "VMTP",
|
641
660
|
82 => "SECURE-VMTP",
|
642
661
|
83 => "VINES",
|
643
|
-
84 => "TTP",
|
644
662
|
84 => "IPTM",
|
645
663
|
85 => "NSFNET-IGP",
|
646
664
|
86 => "DGP",
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipaddr_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Harton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description:
|
@@ -44,17 +44,17 @@ require_paths:
|
|
44
44
|
- lib
|
45
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.4.6
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: A small gem that adds extra functionality to Rubys IPAddr class
|