Skip to content

Commit

Permalink
[ruby/fcntl] Expose Fcntl::VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt authored and matzbot committed Apr 21, 2023
1 parent 072ef7a commit 9702a81
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ext/fcntl/fcntl.c
Expand Up @@ -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
*
Expand Down
12 changes: 11 additions & 1 deletion 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"]

Expand Down

0 comments on commit 9702a81

Please sign in to comment.