From 76aaaf6434752b5dc407878a5268892f859b2bf5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 13 Apr 2023 18:09:27 +0900 Subject: [PATCH] [ruby/un] Expose UN::VERSION https://github.com/ruby/un/commit/47bcad1804 --- lib/un.gemspec | 11 +++++++++-- lib/un.rb | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/un.gemspec b/lib/un.gemspec index 1a466fdebe..2ed49511cc 100644 --- a/lib/un.gemspec +++ b/lib/un.gemspec @@ -1,8 +1,15 @@ # frozen_string_literal: true +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 = "un" - spec.version = "0.2.1" + spec.name = name + spec.version = version spec.authors = ["WATANABE Hirofumi"] spec.email = ["eban@ruby-lang.org"] diff --git a/lib/un.rb b/lib/un.rb index 796b36fbab..632960bf53 100644 --- a/lib/un.rb +++ b/lib/un.rb @@ -412,6 +412,9 @@ def help end module UN # :nodoc: + + VERSION = "0.2.1" + module_function def help(argv, output: $stdout) all = argv.empty?