diff options
author | Hiroshi SHIBATA <[email protected]> | 2023-04-14 11:34:47 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-04-14 03:43:46 +0000 |
commit | 3733ee835b16052d1e1b8e309eb8cb7266209472 (patch) | |
tree | 3d0e16f54d92b765bea65e05cdaa9d7a507af6e2 | |
parent | 283c19037423aa9ac86b1094950aec04210f9129 (diff) |
[ruby/readline-ext] Expose Readline::GEM_VERSION
https://github.com/ruby/readline-ext/commit/70aa84b80e
-rw-r--r-- | ext/readline/readline-ext.gemspec | 12 | ||||
-rw-r--r-- | ext/readline/readline.c | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/ext/readline/readline-ext.gemspec b/ext/readline/readline-ext.gemspec index 1e16edbfe6..e2700a0a56 100644 --- a/ext/readline/readline-ext.gemspec +++ b/ext/readline/readline-ext.gemspec @@ -1,6 +1,16 @@ +source_version = ["", "ext/readline/"].find do |dir| + begin + break File.open(File.join(__dir__, "#{dir}readline.c")) {|f| + f.gets("\n#define READLINE_VERSION ") + f.gets[/\s*"(.+)"/, 1] + } + rescue Errno::ENOENT + end +end + Gem::Specification.new do |spec| spec.name = "readline-ext" - spec.version = "0.1.5" + spec.version = source_version spec.authors = ["Yukihiro Matsumoto"] spec.email = ["[email protected]"] diff --git a/ext/readline/readline.c b/ext/readline/readline.c index fc254ce315..a27521e14a 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -15,6 +15,8 @@ ************************************************/ +#define READLINE_VERSION "0.1.5" + #ifdef RUBY_EXTCONF_H #include RUBY_EXTCONF_H #endif @@ -2119,6 +2121,8 @@ Init_readline(void) /* Version string of GNU Readline or libedit. */ rb_define_const(mReadline, "VERSION", version); + rb_define_const(mReadline, "GEM_VERSION", rb_str_new_cstr(READLINE_VERSION)); + rl_attempted_completion_function = readline_attempted_completion_function; #if defined(HAVE_RL_PRE_INPUT_HOOK) rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook; |