From 6beb755d810082ea3f557f54c687bc752a11cc7b Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 30 Mar 2023 13:24:34 +0900 Subject: [PATCH] [ruby/prettyprint] Expose PrettyPrint::VERSION https://github.com/ruby/prettyprint/commit/c6f3947e96 --- lib/prettyprint.gemspec | 11 +++++++++-- lib/prettyprint.rb | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/prettyprint.gemspec b/lib/prettyprint.gemspec index eae2227d60..a18adb174b 100644 --- a/lib/prettyprint.gemspec +++ b/lib/prettyprint.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 = "prettyprint" - spec.version = "0.1.1" + spec.name = name + spec.version = version spec.authors = ["Tanaka Akira"] spec.email = ["akr@fsij.org"] diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb index 188c2e6db0..540b12fb70 100644 --- a/lib/prettyprint.rb +++ b/lib/prettyprint.rb @@ -33,6 +33,8 @@ # class PrettyPrint + VERSION = "0.1.1" + # This is a convenience method which is same as follows: # # begin