Skip to content

Commit fc56707

Browse files
authored
Merge pull request #9 from ahorek/jruby_support
jruby support
2 parents fbfa918 + 93326fb commit fc56707

File tree

9 files changed

+602
-9
lines changed

9 files changed

+602
-9
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ jobs:
77
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
88
strategy:
99
matrix:
10-
ruby: [ '3.0', 2.7, 2.6, 2.5, head ]
10+
ruby: [ '3.0', 2.7, 2.6, 2.5, head, jruby ]
1111
os: [ ubuntu-latest, macos-latest, windows-latest ]
1212
exclude:
1313
- { os: windows-latest, ruby: head }
14+
- { os: macos-latest, ruby: jruby }
15+
- { os: windows-latest, ruby: jruby }
1416
include:
1517
- { os: windows-latest, ruby: mingw }
1618
- { os: windows-latest, ruby: mswin }

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/tmp/
1010
/ChangeLog
1111
/Gemfile.lock
12+
*.jar
1213
*.bundle
1314
*.so
1415
*.dll

Rakefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
require "bundler/gem_tasks"
22
require "rake/testtask"
33

4-
require 'rake/extensiontask'
5-
extask = Rake::ExtensionTask.new("cgi/escape") do |x|
6-
x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}")
4+
require 'rake/javaextensiontask'
5+
Rake::JavaExtensionTask.new("escape") do |ext|
6+
ext.source_version = '1.8'
7+
ext.target_version = '1.8'
8+
ext.ext_dir = 'ext/java'
9+
ext.lib_dir = 'lib/cgi'
10+
11+
task :build => :compile
12+
end
13+
14+
unless RUBY_ENGINE == 'jruby'
15+
require 'rake/extensiontask'
16+
extask = Rake::ExtensionTask.new("cgi/escape") do |x|
17+
x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}")
18+
end
719
end
820

921
Rake::TestTask.new(:test) do |t|
10-
t.libs << "lib/#{RUBY_VERSION}/#{extask.platform}"
1122
t.libs << "test/lib"
23+
if RUBY_ENGINE == 'jruby'
24+
t.libs << "ext/java/org/jruby/ext/cgi/escape/lib"
25+
else
26+
t.libs << "lib/#{RUBY_VERSION}/#{extask.platform}"
27+
end
1228
t.ruby_opts << "-rhelper"
1329
t.test_files = FileList['test/**/test_*.rb']
1430
end

cgi.gemspec

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@ Gem::Specification.new do |spec|
2222
spec.metadata["homepage_uri"] = spec.homepage
2323
spec.metadata["source_code_uri"] = spec.homepage
2424

25-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26-
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) }
27-
end
28-
spec.extensions = ["ext/cgi/escape/extconf.rb"]
2925
spec.executables = []
26+
27+
spec.files = [
28+
"LICENSE.txt",
29+
"README.md",
30+
*Dir["lib{.rb,/**/*.rb}", "bin/*"] ]
31+
3032
spec.require_paths = ["lib"]
33+
34+
if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
35+
spec.platform = 'java'
36+
spec.require_paths << "ext/java/org/jruby/ext/cgi/escape/lib"
37+
spec.files += Dir["ext/java/**/*.{rb}", "lib/cgi/escape.jar"]
38+
else
39+
spec.files += Dir["ext/cgi/**/*.{rb,c,h,sh}", "ext/cgi/escape/depend", "lib/cgi/escape.so"]
40+
spec.extensions = ["ext/cgi/escape/extconf.rb"]
41+
end
3142
end

0 commit comments

Comments
 (0)