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

ruby-changes:69803

From: Jean <ko1@a...>
Date: Thu, 18 Nov 2021 20:22:26 +0900 (JST)
Subject: [ruby-changes:69803] 3ce27552df (master): [ruby/date] Expose Date::VERSION

https://git.ruby-lang.org/ruby.git/commit/?id=3ce27552df

From 3ce27552df3411ea75ac8f24023194ec373e0f0c Mon Sep 17 00:00:00 2001
From: Jean Boussier <jean.boussier@g...>
Date: Tue, 16 Nov 2021 14:14:28 +0100
Subject: [ruby/date] Expose Date::VERSION

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

Many gems extracted from ruby don't do this, even though it would be even more
useful because they ship with ruby, so it's less clear which version it is.

https://github.com/ruby/date/commit/fef7ec18d8
---
 ext/date/date.gemspec | 7 ++++++-
 ext/date/lib/date.rb  | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ext/date/date.gemspec b/ext/date/date.gemspec
index 1a3ae812dce..cf076969766 100644
--- a/ext/date/date.gemspec
+++ b/ext/date/date.gemspec
@@ -1,7 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/date.gemspec#L1
 # frozen_string_literal: true
+
+version = File.foreach(File.expand_path("../lib/date.rb", __FILE__)).find do |line|
+  /^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1
+end
+
 Gem::Specification.new do |s|
   s.name = "date"
-  s.version = '3.2.1'
+  s.version = version
   s.summary = "A subclass of Object includes Comparable module for handling dates."
   s.description = "A subclass of Object includes Comparable module for handling dates."
 
diff --git a/ext/date/lib/date.rb b/ext/date/lib/date.rb
index 49012195031..c8fad9ac87e 100644
--- a/ext/date/lib/date.rb
+++ b/ext/date/lib/date.rb
@@ -4,6 +4,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/lib/date.rb#L4
 require 'date_core'
 
 class Date
+  VERSION = '3.2.1' # :nodoc:
 
   def infinite?
     false
-- 
cgit v1.2.1


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

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