diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-02-19 18:45:06 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-02-21 09:50:02 +0000 |
commit | d13879f862a98e718ba7ec40e8d43137efb97a8b (patch) | |
tree | 02945baaa60afc3a5fb8fb90fcb8d9c2065bb0c4 /ext/bigdecimal/bigdecimal.gemspec | |
parent | cb40432c74b9c5f785e8be53cbda981a64d47c72 (diff) |
[ruby/bigdecimal] Read version from bigdecimal.c
The dependency of extconf.h on bigdecimal.gemspec does not make sense
as far as no rule is defined for it. Also, the relationship between
extension library and gemspec file is various in default gems, and
does not work well.
https://github.com/ruby/bigdecimal/commit/7f99b28552
Diffstat (limited to 'ext/bigdecimal/bigdecimal.gemspec')
-rw-r--r-- | ext/bigdecimal/bigdecimal.gemspec | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec index a72205f517..f9f3b45616 100644 --- a/ext/bigdecimal/bigdecimal.gemspec +++ b/ext/bigdecimal/bigdecimal.gemspec @@ -1,8 +1,18 @@ # coding: utf-8 +name = File.basename(__FILE__, '.*') +source_version = ["", "ext/#{name}/"].find do |dir| + begin + break File.foreach(File.join(__dir__, "#{dir}#{name}.c")) {|line| + break $1.sub("-", ".") if /^#define\s+#{name.upcase}_VERSION\s+"(.+)"/o =~ line + } + rescue Errno::ENOENT + end +end or raise "can't find #{name.upcase}_VERSION" + Gem::Specification.new do |s| - s.name = "bigdecimal" - s.version = "3.1.3" + s.name = name + s.version = source_version s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"] s.email = ["[email protected]"] |