Skip to content

Commit 333018e

Browse files
authored
Merge pull request #28 from headius/jruby
Add JRuby's syslog
2 parents 26cc486 + a6f55b8 commit 333018e

6 files changed

Lines changed: 390 additions & 16 deletions

File tree

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ jobs:
66
ruby-versions:
77
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
88
with:
9-
engine: cruby-truffleruby
109
min_version: 2.5
1110

1211
build:

Rakefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ Rake::TestTask.new(:test) do |t|
77
t.test_files = FileList["test/**/test_*.rb"]
88
end
99

10-
require 'rake/extensiontask'
11-
Rake::ExtensionTask.new("syslog_ext") do |ext|
12-
ext.ext_dir = 'ext/syslog'
10+
if RUBY_ENGINE == 'jruby'
11+
# nothing to compile for JRuby
12+
task :compile do end
13+
else
14+
require 'rake/extensiontask'
15+
Rake::ExtensionTask.new("syslog_ext") do |ext|
16+
ext.ext_dir = 'ext/syslog'
1317

14-
# In contrast to "gem install" a "rake compile" is expecting the C-ext file even on Windows.
15-
# Work around by creating a dummy so file.
16-
task "#{ext.tmp_dir}/#{ext.platform}/stage/lib" do |t|
17-
touch "#{ext.tmp_dir}/#{ext.platform}/#{ext.name}/#{RUBY_VERSION}/#{ext.name}.so"
18+
# In contrast to "gem install" a "rake compile" is expecting the C-ext file even on Windows.
19+
# Work around by creating a dummy so file.
20+
task "#{ext.tmp_dir}/#{ext.platform}/stage/lib" do |t|
21+
touch "#{ext.tmp_dir}/#{ext.platform}/#{ext.name}/#{RUBY_VERSION}/#{ext.name}.so"
22+
end
1823
end
1924
end
25+
2026
task :default => :test

ext/syslog/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def windows?
1414
RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
1515
end
1616

17-
if windows?
17+
if windows? || RUBY_ENGINE == 'jruby'
1818
generate_dummy_makefile
1919
else
2020
have_library("log") # for Android

lib/syslog.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
begin
2-
require 'syslog_ext'
2+
if RUBY_ENGINE == 'jruby'
3+
require 'syslog/jruby'
4+
else
5+
require 'syslog_ext'
6+
end
37
rescue LoadError
48
raise LoadError.new(<<-EOS)
5-
Can't load Syslog!
6-
7-
Syslog is not supported on your system. For Windows
8-
we recommend using the win32-eventlog gem.
9-
EOS
9+
Can't load Syslog!
10+
11+
Syslog is not supported on your system. For Windows
12+
we recommend using the win32-eventlog gem.
13+
EOS
1014
end

0 commit comments

Comments
 (0)