summaryrefslogtreecommitdiff
path: root/ext/zlib/zlib.gemspec
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-29 18:21:17 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-29 18:47:59 +0900
commitf10c9cb1f2dfca024937bc48137168124d8511aa (patch)
tree4315dd4c2b10d94cf5d4e505ec4a6ffbc09cfb62 /ext/zlib/zlib.gemspec
parentce477089f690d3bedcaef088158b429db8a97d64 (diff)
[ruby/zlib] Search zlib.c as a gem
https://github.com/ruby/zlib/commit/8f43b264cd
Diffstat (limited to 'ext/zlib/zlib.gemspec')
-rw-r--r--ext/zlib/zlib.gemspec15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/zlib/zlib.gemspec b/ext/zlib/zlib.gemspec
index f5b6443..4a77ae3 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