ipaddr 1.2.3 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ipaddr.gemspec +15 -3
  4. data/lib/ipaddr.rb +8 -3
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2856d459b11572a7c59a6ad57ec0462b5e851a5c2a012cb6d106a8be15e3739
4
- data.tar.gz: e8bf2d309cd922ad6c10af07f359034264be462b926718b4d8524e068084fa5f
3
+ metadata.gz: 06fb862bc853927b4eb39fd9026c6c8ad873faa1a68f9c39273dc138f7eb0d37
4
+ data.tar.gz: 67115eb06827bcde6f1639535494f5b190529b127577af48f76ae3bf4886110c
5
5
  SHA512:
6
- metadata.gz: 372737acde9b6852b407d6b38df6392ea2240589eda19798e14fd01184594f0a9ef7d3a30d7f3ce5d178d314ff535a92fb1400f9895863c49047229175e1e350
7
- data.tar.gz: 46aaa06ed661f88c99b63f844855ec91e9b17639799d5d3d980a77f7db236306511671d6f38b562d08fcdd35150b5bea1adccef2b182c7c8e5563a6439b374d7
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 `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
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 = "1.2.3"
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
- return clone.set(begin_addr, @family)..clone.set(end_addr, @family)
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.3
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: 2021-10-25 00:00:00.000000000 Z
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.2.22
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