Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Syslog::VERSION #5

Merged
merged 1 commit into from Apr 25, 2023
Merged

Expose Syslog::VERSION #5

merged 1 commit into from Apr 25, 2023

Conversation

hsbt
Copy link
Member

@hsbt hsbt commented Apr 21, 2023

There is no way to refer gem version in Ruby now. I hope to expose gem version by VERSION constant.

@hsbt hsbt requested a review from knu as a code owner April 21, 2023 04:22
Comment on lines +2 to +9
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather do it this way:

Suggested change
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
source_version = %w[. ext/syslog].find do |dir|
break $1 if File.foreach(File.join(__dir__, dir, "syslog.c")).any?(/^#define\s+SYSLOG_VERSION\s+"(.+)"/)
rescue Errno::ENOENT

@knu knu merged commit ff5d72f into master Apr 25, 2023
16 checks passed
@knu knu deleted the expose-gem-version branch April 25, 2023 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants