From f09638fe25d86c4d619a1f45b1595c8a30c54cc4 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 13 Apr 2023 18:34:43 +0900 Subject: [PATCH] [ruby/time] Expose Time::VERSION https://github.com/ruby/time/commit/32793b56b7 --- lib/time.gemspec | 11 +++++++++-- lib/time.rb | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/time.gemspec b/lib/time.gemspec index ce5f76f8e9..a9349a253f 100644 --- a/lib/time.gemspec +++ b/lib/time.gemspec @@ -1,6 +1,13 @@ +name = File.basename(__FILE__, ".gemspec") +version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir| + break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line| + /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1 + end rescue nil +end + Gem::Specification.new do |spec| - spec.name = "time" - spec.version = "0.2.2" + spec.name = name + spec.version = version spec.authors = ["Tanaka Akira"] spec.email = ["akr@fsij.org"] diff --git a/lib/time.rb b/lib/time.rb index 6a13212a49..c572e76d7d 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -25,6 +25,9 @@ require 'date' # :startdoc: class Time + + VERSION = "0.2.2" + class << Time #