diff options
author | Nobuyoshi Nakada <[email protected]> | 2019-09-29 18:21:17 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-09-29 18:47:59 +0900 |
commit | f10c9cb1f2dfca024937bc48137168124d8511aa (patch) | |
tree | 4315dd4c2b10d94cf5d4e505ec4a6ffbc09cfb62 | |
parent | ce477089f690d3bedcaef088158b429db8a97d64 (diff) |
[ruby/zlib] Search zlib.c as a gem
https://github.com/ruby/zlib/commit/8f43b264cd
-rw-r--r-- | ext/zlib/zlib.gemspec | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/zlib/zlib.gemspec b/ext/zlib/zlib.gemspec index f5b6443258..4a77ae325e 100644 --- a/ext/zlib/zlib.gemspec +++ b/ext/zlib/zlib.gemspec @@ -1,9 +1,16 @@ # coding: utf-8 # frozen_string_literal: true -source_version = File.open(File.join(__dir__, "zlib.c")) {|f| - f.gets("\n#define RUBY_ZLIB_VERSION ") - f.gets[/\s*(".+")/, 1].undump -} + +source_version = ["", "ext/zlib/"].find do |dir| + begin + break File.open(File.join(__dir__, "#{dir}zlib.c")) {|f| + f.gets("\n#define RUBY_ZLIB_VERSION ") + f.gets[/\s*"(.+)"/, 1] + } + rescue Errno::ENOENT + end +end + Gem::Specification.new do |spec| spec.name = "zlib" spec.version = source_version |