diff options
-rw-r--r-- | lib/prettyprint.gemspec | 11 | ||||
-rw-r--r-- | 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 = ["[email protected]"] 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 |