From 9702a8142b8a4e97cde983300849590bfe73b8b1 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 21 Apr 2023 13:13:10 +0900 Subject: [ruby/fcntl] Expose Fcntl::VERSION https://github.com/ruby/fcntl/commit/cb8e414e9f --- ext/fcntl/fcntl.c | 6 ++++++ ext/fcntl/fcntl.gemspec | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c index 3bccc41e4c..4ea7b29bf5 100644 --- a/ext/fcntl/fcntl.c +++ b/ext/fcntl/fcntl.c @@ -61,10 +61,16 @@ pack up your own arguments to pass as args for locking functions, etc. * f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m) * */ + +#define FCNTL_VERSION "1.0.2" + void Init_fcntl(void) { VALUE mFcntl = rb_define_module("Fcntl"); + + rb_define_const(mFcntl, "VERSION", rb_str_new_cstr(FCNTL_VERSION)); + #ifdef F_DUPFD /* Document-const: F_DUPFD * diff --git a/ext/fcntl/fcntl.gemspec b/ext/fcntl/fcntl.gemspec index 09d3fc2568..54aadb4b81 100644 --- a/ext/fcntl/fcntl.gemspec +++ b/ext/fcntl/fcntl.gemspec @@ -1,9 +1,19 @@ # coding: utf-8 # frozen_string_literal: true +source_version = ["", "ext/fcntl/"].find do |dir| + begin + break File.open(File.join(__dir__, "#{dir}fcntl.c")) {|f| + f.gets("\n#define FCNTL_VERSION ") + f.gets[/\s*"(.+)"/, 1] + } + rescue Errno::ENOENT + end +end + Gem::Specification.new do |spec| spec.name = "fcntl" - spec.version = "1.0.2" + spec.version = source_version spec.authors = ["Yukihiro Matsumoto"] spec.email = ["matz@ruby-lang.org"] -- cgit v1.2.1