ipaddr 1.2.7 → 1.2.8
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.rb +22 -6
- metadata +4 -8
- data/ipaddr.gemspec +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27c05756ec16e7913ff99aab584bbcddab9e5ef419e5f5fb17850a846c8e562d
|
|
4
|
+
data.tar.gz: 6845f685c7cfcee252d97e6e74f597991ba7586fc7104242e64ccad5abe9acfc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71535cdb0def5ae3bdc48c762f586c569dd3104e131da598620c43ac679b705e85dc48a45fa0142a69f98097d15dabdf3b427153cb39c283459a3d5d17471da6
|
|
7
|
+
data.tar.gz: 74c73fbf129bfdf9526e3e76269b7c82e75dbef4b63dda82868b465c83bcd29495e470fc1743664a5a065958e455fa53ca678ac8161427a0ab10b55c92b5dd05
|
data/lib/ipaddr.rb
CHANGED
|
@@ -40,7 +40,8 @@ require 'socket'
|
|
|
40
40
|
# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
|
|
41
41
|
|
|
42
42
|
class IPAddr
|
|
43
|
-
|
|
43
|
+
# The version string
|
|
44
|
+
VERSION = "1.2.8"
|
|
44
45
|
|
|
45
46
|
# 32 bit mask for IPv4
|
|
46
47
|
IN4MASK = 0xffffffff
|
|
@@ -151,6 +152,16 @@ class IPAddr
|
|
|
151
152
|
return self.clone.set(addr_mask(~@addr))
|
|
152
153
|
end
|
|
153
154
|
|
|
155
|
+
# Returns a new ipaddr greater than the original address by offset
|
|
156
|
+
def +(offset)
|
|
157
|
+
self.clone.set(@addr + offset, @family)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Returns a new ipaddr less than the original address by offset
|
|
161
|
+
def -(offset)
|
|
162
|
+
self.clone.set(@addr - offset, @family)
|
|
163
|
+
end
|
|
164
|
+
|
|
154
165
|
# Returns true if two ipaddrs are equal.
|
|
155
166
|
def ==(other)
|
|
156
167
|
other = coerce_other(other)
|
|
@@ -343,7 +354,7 @@ class IPAddr
|
|
|
343
354
|
_ipv4_compat?
|
|
344
355
|
end
|
|
345
356
|
|
|
346
|
-
def _ipv4_compat?
|
|
357
|
+
def _ipv4_compat? # :nodoc:
|
|
347
358
|
if !ipv6? || (@addr >> 32) != 0
|
|
348
359
|
return false
|
|
349
360
|
end
|
|
@@ -371,7 +382,9 @@ class IPAddr
|
|
|
371
382
|
if !ipv4?
|
|
372
383
|
raise InvalidAddressError, "not an IPv4 address: #{@addr}"
|
|
373
384
|
end
|
|
374
|
-
|
|
385
|
+
clone = self.clone.set(@addr, Socket::AF_INET6)
|
|
386
|
+
clone.instance_variable_set(:@mask_addr, @mask_addr | 0xffffffffffffffffffffffff00000000)
|
|
387
|
+
clone
|
|
375
388
|
end
|
|
376
389
|
|
|
377
390
|
# Returns a new ipaddr built by converting the IPv6 address into a
|
|
@@ -533,6 +546,7 @@ class IPAddr
|
|
|
533
546
|
end
|
|
534
547
|
|
|
535
548
|
protected
|
|
549
|
+
# :stopdoc:
|
|
536
550
|
|
|
537
551
|
def begin_addr
|
|
538
552
|
@addr & @mask_addr
|
|
@@ -548,6 +562,7 @@ class IPAddr
|
|
|
548
562
|
raise AddressFamilyError, "unsupported address family"
|
|
549
563
|
end
|
|
550
564
|
end
|
|
565
|
+
#:startdoc:
|
|
551
566
|
|
|
552
567
|
# Set +@addr+, the internal stored ip address, to given +addr+. The
|
|
553
568
|
# parameter +addr+ is validated using the first +family+ member,
|
|
@@ -689,6 +704,7 @@ class IPAddr
|
|
|
689
704
|
end
|
|
690
705
|
end
|
|
691
706
|
|
|
707
|
+
# :stopdoc:
|
|
692
708
|
def coerce_other(other)
|
|
693
709
|
case other
|
|
694
710
|
when IPAddr
|
|
@@ -709,8 +725,8 @@ class IPAddr
|
|
|
709
725
|
octets = addr.split('.')
|
|
710
726
|
end
|
|
711
727
|
octets.inject(0) { |i, s|
|
|
712
|
-
(n = s.to_i) < 256 or raise InvalidAddressError, "invalid address: #{
|
|
713
|
-
(s != '0') && s.start_with?('0') and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous: #{
|
|
728
|
+
(n = s.to_i) < 256 or raise InvalidAddressError, "invalid address: #{addr}"
|
|
729
|
+
(s != '0') && s.start_with?('0') and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous: #{addr}"
|
|
714
730
|
i << 8 | n
|
|
715
731
|
}
|
|
716
732
|
end
|
|
@@ -800,7 +816,7 @@ unless Socket.const_defined? :AF_INET6
|
|
|
800
816
|
class << IPSocket
|
|
801
817
|
private
|
|
802
818
|
|
|
803
|
-
def valid_v6?(addr)
|
|
819
|
+
def valid_v6?(addr) # :nodoc:
|
|
804
820
|
case addr
|
|
805
821
|
when IPAddr::RE_IPV6ADDRLIKE_FULL
|
|
806
822
|
if $2
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ipaddr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akinori MUSHA
|
|
8
8
|
- Hajimu UMEMOTO
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies: []
|
|
14
13
|
description: |
|
|
15
14
|
IPAddr provides a set of methods to manipulate an IP address.
|
|
@@ -23,14 +22,12 @@ extra_rdoc_files: []
|
|
|
23
22
|
files:
|
|
24
23
|
- LICENSE.txt
|
|
25
24
|
- README.md
|
|
26
|
-
- ipaddr.gemspec
|
|
27
25
|
- lib/ipaddr.rb
|
|
28
26
|
homepage: https://github.com/ruby/ipaddr
|
|
29
27
|
licenses:
|
|
30
28
|
- Ruby
|
|
31
29
|
- BSD-2-Clause
|
|
32
30
|
metadata: {}
|
|
33
|
-
post_install_message:
|
|
34
31
|
rdoc_options: []
|
|
35
32
|
require_paths:
|
|
36
33
|
- lib
|
|
@@ -38,15 +35,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
38
35
|
requirements:
|
|
39
36
|
- - ">="
|
|
40
37
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '2.
|
|
38
|
+
version: '2.4'
|
|
42
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
40
|
requirements:
|
|
44
41
|
- - ">="
|
|
45
42
|
- !ruby/object:Gem::Version
|
|
46
43
|
version: '0'
|
|
47
44
|
requirements: []
|
|
48
|
-
rubygems_version: 3.
|
|
49
|
-
signing_key:
|
|
45
|
+
rubygems_version: 3.6.9
|
|
50
46
|
specification_version: 4
|
|
51
47
|
summary: A class to manipulate an IP address in ruby
|
|
52
48
|
test_files: []
|
data/ipaddr.gemspec
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# coding: utf-8
|
|
3
|
-
|
|
4
|
-
if File.exist?(File.expand_path("ipaddr.gemspec"))
|
|
5
|
-
lib = File.expand_path("../lib", __FILE__)
|
|
6
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
7
|
-
|
|
8
|
-
file = File.expand_path("ipaddr.rb", lib)
|
|
9
|
-
else
|
|
10
|
-
# for ruby-core
|
|
11
|
-
file = File.expand_path("../ipaddr.rb", __FILE__)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
version = File.foreach(file).find do |line|
|
|
15
|
-
/^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
Gem::Specification.new do |spec|
|
|
19
|
-
spec.name = "ipaddr"
|
|
20
|
-
spec.version = version
|
|
21
|
-
spec.authors = ["Akinori MUSHA", "Hajimu UMEMOTO"]
|
|
22
|
-
spec.email = ["knu@idaemons.org", "ume@mahoroba.org"]
|
|
23
|
-
|
|
24
|
-
spec.summary = %q{A class to manipulate an IP address in ruby}
|
|
25
|
-
spec.description = <<-'DESCRIPTION'
|
|
26
|
-
IPAddr provides a set of methods to manipulate an IP address.
|
|
27
|
-
Both IPv4 and IPv6 are supported.
|
|
28
|
-
DESCRIPTION
|
|
29
|
-
spec.homepage = "https://github.com/ruby/ipaddr"
|
|
30
|
-
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
|
31
|
-
|
|
32
|
-
spec.files = ["LICENSE.txt", "README.md", "ipaddr.gemspec", "lib/ipaddr.rb"]
|
|
33
|
-
spec.require_paths = ["lib"]
|
|
34
|
-
|
|
35
|
-
spec.required_ruby_version = ">= 2.3"
|
|
36
|
-
end
|