Skip to content

Commit

Permalink
[ruby/syslog] Expose Syslog::VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt authored and matzbot committed Apr 25, 2023
1 parent 0cc5c59 commit 117fc8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ext/syslog/syslog.c
Expand Up @@ -12,6 +12,8 @@
#include "ruby/util.h"
#include <syslog.h>

#define SYSLOG_VERSION "0.1.1"

/* Syslog class */
static VALUE mSyslog;
/*
Expand Down Expand Up @@ -574,6 +576,8 @@ void Init_syslog(void)

/* Syslog macros */

rb_define_const(mSyslog, "VERSION", rb_str_new_cstr(SYSLOG_VERSION));

rb_define_method(mSyslogMacros, "LOG_MASK", mSyslogMacros_LOG_MASK, 1);
rb_define_method(mSyslogMacros, "LOG_UPTO", mSyslogMacros_LOG_UPTO, 1);
rb_define_singleton_method(mSyslogMacros, "included", mSyslogMacros_included, 1);
Expand Down
13 changes: 12 additions & 1 deletion ext/syslog/syslog.gemspec
@@ -1,6 +1,17 @@

source_version = ["", "ext/syslog/"].find do |dir|
begin
break File.open(File.join(__dir__, "#{dir}syslog.c")) {|f|
f.gets("\n#define SYSLOG_VERSION ")
f.gets[/\s*"(.+)"/, 1]
}
rescue Errno::ENOENT
end
end

Gem::Specification.new do |spec|
spec.name = "syslog"
spec.version = "0.1.1"
spec.version = source_version
spec.authors = ["Akinori MUSHA"]
spec.email = ["knu@idaemons.org"]

Expand Down

0 comments on commit 117fc8e

Please sign in to comment.