From 8b924ebdf25fd77250d6ab69f162a2ab7fc888fc Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 30 Mar 2023 14:14:15 +0900 Subject: [ruby/tempfile] Expose Tempfile::VERSION https://github.com/ruby/tempfile/commit/6aa1f37dc4 --- lib/tempfile.gemspec | 11 +++++++++-- lib/tempfile.rb | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/tempfile.gemspec b/lib/tempfile.gemspec index acb26b68db..6b433dd9a6 100644 --- a/lib/tempfile.gemspec +++ b/lib/tempfile.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 = "tempfile" - spec.version = "0.1.3" + spec.name = name + spec.version = version spec.authors = ["Yukihiro Matsumoto"] spec.email = ["matz@ruby-lang.org"] diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 1bb13e9501..d53d8c7196 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -88,6 +88,8 @@ require 'tmpdir' # mutex. class Tempfile < DelegateClass(File) + VERSION = "0.1.3" + # Creates a file in the underlying file system; # returns a new \Tempfile object based on that file. # -- cgit v1.2.3