From 3d0e65e79f51a4d3619469dce6432dd083a064ce Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 30 Mar 2023 13:23:44 +0900 Subject: [PATCH] Expose PP::VERSION --- lib/pp.rb | 3 +++ pp.gemspec | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/pp.rb b/lib/pp.rb index 81551aa..b81f84c 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -61,6 +61,9 @@ # Tanaka Akira class PP < PrettyPrint + + VERSION = "0.4.0" + # Returns the usable width for +out+. # As the width of +out+: # 1. If +out+ is assigned to a tty device, its width is used. diff --git a/pp.gemspec b/pp.gemspec index 3f08f40..27a92a8 100644 --- a/pp.gemspec +++ b/pp.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 = "pp" - spec.version = "0.4.0" + spec.name = name + spec.version = version spec.authors = ["Tanaka Akira"] spec.email = ["akr@fsij.org"]