ipaddr 1.2.3 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ipaddr.gemspec +15 -3
- data/lib/ipaddr.rb +8 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06fb862bc853927b4eb39fd9026c6c8ad873faa1a68f9c39273dc138f7eb0d37
|
4
|
+
data.tar.gz: 67115eb06827bcde6f1639535494f5b190529b127577af48f76ae3bf4886110c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e75fe29c69c244547d966127f1fd98b38352ad562ac2c5b2cdbb301374d390b99ab81f8bdc976f23668df2cfe9b03872a8fef559769f474668936bea5f219c2
|
7
|
+
data.tar.gz: 62a69ec4cdbe84424750ec9b1947a4d6184bf835db3cc3a1053da8e646c7df5557ae9ba36c9943e827f6c3d4e238127d5d1ce6fab89b4bdf482dcd58753e0134
|
data/README.md
CHANGED
@@ -55,7 +55,7 @@ than `ipaddr` has, try this library instead.
|
|
55
55
|
|
56
56
|
## Development
|
57
57
|
|
58
|
-
After checking out the repo, run `
|
58
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
|
59
59
|
|
60
60
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
61
61
|
|
data/ipaddr.gemspec
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# coding: utf-8
|
3
|
-
|
4
|
-
|
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
|
5
17
|
|
6
18
|
Gem::Specification.new do |spec|
|
7
19
|
spec.name = "ipaddr"
|
8
|
-
spec.version =
|
20
|
+
spec.version = version
|
9
21
|
spec.authors = ["Akinori MUSHA", "Hajimu UMEMOTO"]
|
10
22
|
spec.email = ["knu@idaemons.org", "ume@mahoroba.org"]
|
11
23
|
|
data/lib/ipaddr.rb
CHANGED
@@ -40,13 +40,14 @@ require 'socket'
|
|
40
40
|
# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
|
41
41
|
|
42
42
|
class IPAddr
|
43
|
+
VERSION = "1.2.5"
|
43
44
|
|
44
45
|
# 32 bit mask for IPv4
|
45
46
|
IN4MASK = 0xffffffff
|
46
47
|
# 128 bit mask for IPv6
|
47
48
|
IN6MASK = 0xffffffffffffffffffffffffffffffff
|
48
49
|
# Format string for IPv6
|
49
|
-
IN6FORMAT = (["%.4x"] * 8).join(':')
|
50
|
+
IN6FORMAT = (["%.4x"] * 8).join(':').freeze
|
50
51
|
|
51
52
|
# Regexp _internally_ used for parsing IPv4 address.
|
52
53
|
RE_IPV4ADDRLIKE = %r{
|
@@ -410,7 +411,7 @@ class IPAddr
|
|
410
411
|
raise AddressFamilyError, "unsupported address family"
|
411
412
|
end
|
412
413
|
|
413
|
-
|
414
|
+
self.class.new(begin_addr, @family)..self.class.new(end_addr, @family)
|
414
415
|
end
|
415
416
|
|
416
417
|
# Returns the prefix length in bits for the ipaddr.
|
@@ -509,6 +510,9 @@ class IPAddr
|
|
509
510
|
@addr = addr
|
510
511
|
if family[0]
|
511
512
|
@family = family[0]
|
513
|
+
if @family == Socket::AF_INET
|
514
|
+
@mask_addr &= IN4MASK
|
515
|
+
end
|
512
516
|
end
|
513
517
|
return self
|
514
518
|
end
|
@@ -579,6 +583,7 @@ class IPAddr
|
|
579
583
|
# those, such as &, |, include? and ==, accept a string, or a packed
|
580
584
|
# in_addr value instead of an IPAddr object.
|
581
585
|
def initialize(addr = '::', family = Socket::AF_UNSPEC)
|
586
|
+
@mask_addr = nil
|
582
587
|
if !addr.kind_of?(String)
|
583
588
|
case family
|
584
589
|
when Socket::AF_INET, Socket::AF_INET6
|
@@ -731,7 +736,7 @@ end
|
|
731
736
|
unless Socket.const_defined? :AF_INET6
|
732
737
|
class Socket < BasicSocket
|
733
738
|
# IPv6 protocol family
|
734
|
-
AF_INET6 = Object.new
|
739
|
+
AF_INET6 = Object.new.freeze
|
735
740
|
end
|
736
741
|
|
737
742
|
class << IPSocket
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: |
|
15
15
|
IPAddr provides a set of methods to manipulate an IP address.
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
|
-
rubygems_version: 3.
|
48
|
+
rubygems_version: 3.4.0.dev
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: A class to manipulate an IP address in ruby
|