diff --git a/base64.gemspec b/base64.gemspec index daa0b7f..d793dce 100644 --- a/base64.gemspec +++ b/base64.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 = "base64" - spec.version = "0.1.1" + spec.name = name + spec.version = version spec.authors = ["Yusuke Endoh"] spec.email = ["mame@ruby-lang.org"] diff --git a/lib/base64.rb b/lib/base64.rb index 693aa1f..15c0b29 100644 --- a/lib/base64.rb +++ b/lib/base64.rb @@ -22,6 +22,9 @@ # binary data into purely printable characters. module Base64 + + VERSION = "0.1.1" + module_function # Returns the Base64-encoded version of +bin+.