From 283c19037423aa9ac86b1094950aec04210f9129 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 14 Apr 2023 12:01:01 +0900 Subject: [PATCH] [ruby/nkf] Expose NKF::GEM_VERSION https://github.com/ruby/nkf/commit/0d0fb3a162 --- ext/nkf/nkf.c | 3 +++ ext/nkf/nkf.gemspec | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c index c6ddee1976..f89ad68845 100644 --- a/ext/nkf/nkf.c +++ b/ext/nkf/nkf.c @@ -9,6 +9,7 @@ #define RUBY_NKF_REVISION "$Revision$" #define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")" +#define NKF_GEM_VERSION "0.1.2" #include "ruby/ruby.h" #include "ruby/encoding.h" @@ -500,4 +501,6 @@ Init_nkf(void) rb_define_const(mNKF, "NKF_VERSION", rb_str_new2(NKF_VERSION)); /* Release date of nkf */ rb_define_const(mNKF, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE)); + /* Version of nkf library */ + rb_define_const(mNKF, "GEM_VERSION", rb_str_new_cstr(NKF_GEM_VERSION)); } diff --git a/ext/nkf/nkf.gemspec b/ext/nkf/nkf.gemspec index 7f3bd4a4b1..92ab0f22fe 100644 --- a/ext/nkf/nkf.gemspec +++ b/ext/nkf/nkf.gemspec @@ -1,6 +1,16 @@ +source_version = ["", "ext/nkf/"].find do |dir| + begin + break File.open(File.join(__dir__, "#{dir}nkf.c")) {|f| + f.gets("\n#define NKF_GEM_VERSION ") + f.gets[/\s*"(.+)"/, 1] + } + rescue Errno::ENOENT + end +end + Gem::Specification.new do |spec| spec.name = "nkf" - spec.version = "0.1.2" + spec.version = source_version spec.authors = ["NARUSE Yui"] spec.email = ["naruse@airemix.jp"]