[前][次][番号順一覧][スレッド一覧]

ruby-changes:71139

From: Jean <ko1@a...>
Date: Thu, 10 Feb 2022 17:18:21 +0900 (JST)
Subject: [ruby-changes:71139] 5221cb4468 (master): [ruby/ipaddr] Expose IPAddr::VERSION

https://git.ruby-lang.org/ruby.git/commit/?id=5221cb4468

From 5221cb4468526a18875c21cff5dee5ac96d9873b Mon Sep 17 00:00:00 2001
From: Jean Boussier <jean.boussier@g...>
Date: Thu, 2 Dec 2021 10:07:26 +0100
Subject: [ruby/ipaddr] Expose IPAddr::VERSION

An almost universal convention for gems is to expose Namespace::VERSION
which makes it much easier when debugging etc.

https://github.com/ruby/ipaddr/commit/587ae6996e
---
 lib/ipaddr.gemspec | 6 +++++-
 lib/ipaddr.rb      | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/ipaddr.gemspec b/lib/ipaddr.gemspec
index 36e2300002..352570a213 100644
--- a/lib/ipaddr.gemspec
+++ b/lib/ipaddr.gemspec
@@ -3,9 +3,13 @@ https://github.com/ruby/ruby/blob/trunk/lib/ipaddr.gemspec#L3
 lib = File.expand_path("../lib", __FILE__)
 $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
 
+version = File.foreach(File.expand_path("ipaddr.rb", lib)).find do |line|
+  /^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1
+end
+
 Gem::Specification.new do |spec|
   spec.name          = "ipaddr"
-  spec.version       = "1.2.3"
+  spec.version       = version
   spec.authors       = ["Akinori MUSHA", "Hajimu UMEMOTO"]
   spec.email         = ["knu@i...", "ume@m..."]
 
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 5df798f5d7..9cc210c307 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -40,6 +40,7 @@ require 'socket' https://github.com/ruby/ruby/blob/trunk/lib/ipaddr.rb#L40
 #   p ipaddr3                   #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
 
 class IPAddr
+  VERSION = "1.2.3"
 
   # 32 bit mask for IPv4
   IN4MASK = 0xffffffff
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]