Skip to content

Commit

Permalink
Search zlib.c as a gem
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 29, 2019
1 parent 42e5e15 commit 8f43b26
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions 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
Expand Down

0 comments on commit 8f43b26

Please sign in to comment.