mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Import ipaddr 1.2.2
- Enable frozen_string_literal and do a bit of code cleanup git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
78dc3da299
commit
ab364fb5a8
3 changed files with 8 additions and 6 deletions
|
@ -1,10 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
lib = File.expand_path("../lib", __FILE__)
|
lib = File.expand_path("../lib", __FILE__)
|
||||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
|
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = "ipaddr"
|
spec.name = "ipaddr"
|
||||||
spec.version = "1.2.0"
|
spec.version = "1.2.2"
|
||||||
spec.authors = ["Akinori MUSHA", "Hajimu UMEMOTO"]
|
spec.authors = ["Akinori MUSHA", "Hajimu UMEMOTO"]
|
||||||
spec.email = ["knu@idaemons.org", "ume@mahoroba.org"]
|
spec.email = ["knu@idaemons.org", "ume@mahoroba.org"]
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ IPAddr provides a set of methods to manipulate an IP address.
|
||||||
Both IPv4 and IPv6 are supported.
|
Both IPv4 and IPv6 are supported.
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
spec.homepage = "https://github.com/ruby/ipaddr"
|
spec.homepage = "https://github.com/ruby/ipaddr"
|
||||||
|
spec.license = "BSD-2-Clause"
|
||||||
|
|
||||||
spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "ipaddr.gemspec", "lib/ipaddr.rb"]
|
spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "ipaddr.gemspec", "lib/ipaddr.rb"]
|
||||||
spec.bindir = "exe"
|
spec.bindir = "exe"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# ipaddr.rb - A class to manipulate an IP address
|
# ipaddr.rb - A class to manipulate an IP address
|
||||||
#
|
#
|
||||||
|
@ -103,13 +103,13 @@ class IPAddr
|
||||||
|
|
||||||
# Creates a new ipaddr containing the given network byte ordered
|
# Creates a new ipaddr containing the given network byte ordered
|
||||||
# string form of an IP address.
|
# string form of an IP address.
|
||||||
def IPAddr::new_ntoh(addr)
|
def self.new_ntoh(addr)
|
||||||
return IPAddr.new(IPAddr::ntop(addr))
|
return new(ntop(addr))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a network byte ordered string form of an IP address into
|
# Convert a network byte ordered string form of an IP address into
|
||||||
# human readable form.
|
# human readable form.
|
||||||
def IPAddr::ntop(addr)
|
def self.ntop(addr)
|
||||||
case addr.size
|
case addr.size
|
||||||
when 4
|
when 4
|
||||||
s = addr.unpack('C4').join('.')
|
s = addr.unpack('C4').join('.')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'ipaddr'
|
require 'ipaddr'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue