[ruby/nkf] Add JRuby extension to the gem

This pulls in the nkf extension implementation from JRuby. The
build and load logic has been updated along the same lines as
ruby/digest and the gem appears to build correctly for the -java
platform.

Fixes https://github.com/ruby/nkf/pull/13

https://github.com/ruby/nkf/commit/18f57f36ed
This commit is contained in:
Charles Oliver Nutter 2024-01-18 19:45:05 -06:00 committed by git
parent e2e15ddd67
commit c6b548accb
2 changed files with 17 additions and 3 deletions

View File

@ -11,8 +11,8 @@ end
Gem::Specification.new do |spec|
spec.name = "nkf"
spec.version = source_version
spec.authors = ["NARUSE Yui"]
spec.email = ["naruse@airemix.jp"]
spec.authors = ["NARUSE Yui", "Charles Oliver Nutter"]
spec.email = ["naruse@airemix.jp", "headius@headius.com"]
spec.summary = %q{Ruby extension for Network Kanji Filter}
spec.description = %q{Ruby extension for Network Kanji Filter}
@ -28,8 +28,16 @@ Gem::Specification.new do |spec|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
spec.platform = 'java'
spec.files += Dir["lib/nkf.jar"]
else
spec.extensions = ["ext/nkf/extconf.rb"]
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.extensions = ["ext/nkf/extconf.rb"]
end

6
lib/nkf.rb Normal file
View File

@ -0,0 +1,6 @@
if RUBY_ENGINE == "jruby"
require 'nkf.jar'
JRuby::Util.load_ext('org.jruby.ext.nkf.NKFLibrary')
else
require 'nkf.so'
end