Skip to content

Commit fe25c6e

Browse files
committed
Merge json and json-java gemspecs
1 parent c4a6e77 commit fe25c6e

File tree

7 files changed

+59
-111
lines changed

7 files changed

+59
-111
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ Gemfile.lock
2020
*/**/*.jar
2121
.byebug_history
2222
*.log
23+
/tmp
24+

Gemfile

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
# vim: set ft=ruby:
2-
31
source 'https://rubygems.org'
42

5-
case ENV['JSON']
6-
when 'ext', nil
7-
if ENV['RUBY_ENGINE'] == 'jruby'
8-
gemspec :name => 'json-java'
9-
else
10-
gemspec :name => 'json'
11-
end
12-
when 'pure'
13-
gemspec :name => 'json_pure'
3+
if ENV['JSON'] == 'pure'
4+
gemspec name: 'json_pure'
5+
else
6+
gemspec name: 'json'
147
end
158

16-
gem "rake"
17-
gem "test-unit"
18-
gem "test-unit-ruby-core"
19-
gem "all_images", "~> 0" unless RUBY_PLATFORM =~ /java/
9+
group :development do
10+
gem "rake"
11+
gem "rake-compiler"
12+
gem "test-unit"
13+
gem "test-unit-ruby-core"
14+
gem "all_images", "~> 0" unless RUBY_PLATFORM =~ /java/
2015

21-
if ENV['BENCHMARK']
22-
gem "benchmark-ips"
23-
unless RUBY_PLATFORM =~ /java/
24-
gem "oj"
25-
gem "rapidjson"
16+
if ENV['BENCHMARK']
17+
gem "benchmark-ips"
18+
unless RUBY_PLATFORM =~ /java/
19+
gem "oj"
20+
gem "rapidjson"
21+
end
2622
end
2723
end

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ the `pp` library's `pp` methods.
231231

232232
### Release
233233

234-
Update the json.gemspec and json-java.gemspec.
234+
Update the `lib/json/version.rb` file.
235235

236236
```
237237
rbenv shell 2.6.5

Rakefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
191191

192192
desc "Package the jruby gem"
193193
task :jruby_gem => :create_jar do
194-
sh 'gem build json-java.gemspec'
195194
mkdir_p 'pkg'
196-
mv "json-#{PKG_VERSION}-java.gem", 'pkg'
195+
sh "gem build -o pkg/json-#{PKG_VERSION}-java.gem json.gemspec"
197196
end
198197

199198
desc "Testing library (jruby)"

ext/json/extconf.rb

-3
This file was deleted.

json-java.gemspec

-36
This file was deleted.

json.gemspec

+39-49
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,60 @@ version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line|
22
/^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1
33
end rescue nil
44

5-
Gem::Specification.new do |s|
5+
spec = Gem::Specification.new do |s|
6+
java_ext = Gem::Platform === s.platform && s.platform =~ 'java' || RUBY_ENGINE == 'jruby'
7+
68
s.name = "json"
79
s.version = version
810

911
s.summary = "JSON Implementation for Ruby"
10-
s.description = "This is a JSON implementation as a Ruby extension in C."
12+
s.homepage = "https://ruby.github.io/json"
13+
s.metadata = {
14+
'bug_tracker_uri' => 'https://github.com/ruby/json/issues',
15+
'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md',
16+
'documentation_uri' => 'https://ruby.github.io/json/doc/index.html',
17+
'homepage_uri' => s.homepage,
18+
'source_code_uri' => 'https://github.com/ruby/json',
19+
'wiki_uri' => 'https://github.com/ruby/json/wiki'
20+
}
21+
22+
s.required_ruby_version = Gem::Requirement.new(">= 2.3")
23+
24+
if java_ext
25+
s.description = "A JSON implementation as a JRuby extension."
26+
s.author = "Daniel Luz"
27+
s.email = "[email protected]"
28+
else
29+
s.description = "This is a JSON implementation as a Ruby extension in C."
30+
s.authors = ["Florian Frank"]
31+
s.email = "[email protected]"
32+
end
33+
1134
s.licenses = ["Ruby"]
12-
s.authors = ["Florian Frank"]
13-
s.email = "[email protected]"
1435

15-
s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"]
1636
s.extra_rdoc_files = ["README.md"]
1737
s.rdoc_options = ["--title", "JSON implementation for Ruby", "--main", "README.md"]
38+
1839
s.files = [
1940
"CHANGES.md",
2041
"COPYING",
2142
"BSDL",
2243
"LEGAL",
2344
"README.md",
24-
"ext/json/ext/fbuffer/fbuffer.h",
25-
"ext/json/ext/generator/depend",
26-
"ext/json/ext/generator/extconf.rb",
27-
"ext/json/ext/generator/generator.c",
28-
"ext/json/ext/generator/generator.h",
29-
"ext/json/ext/parser/depend",
30-
"ext/json/ext/parser/extconf.rb",
31-
"ext/json/ext/parser/parser.c",
32-
"ext/json/ext/parser/parser.h",
33-
"ext/json/ext/parser/parser.rl",
34-
"ext/json/extconf.rb",
3545
"json.gemspec",
36-
"lib/json.rb",
37-
"lib/json/add/bigdecimal.rb",
38-
"lib/json/add/complex.rb",
39-
"lib/json/add/core.rb",
40-
"lib/json/add/date.rb",
41-
"lib/json/add/date_time.rb",
42-
"lib/json/add/exception.rb",
43-
"lib/json/add/ostruct.rb",
44-
"lib/json/add/range.rb",
45-
"lib/json/add/rational.rb",
46-
"lib/json/add/regexp.rb",
47-
"lib/json/add/set.rb",
48-
"lib/json/add/struct.rb",
49-
"lib/json/add/symbol.rb",
50-
"lib/json/add/time.rb",
51-
"lib/json/common.rb",
52-
"lib/json/ext.rb",
53-
"lib/json/ext/generator/state.rb",
54-
"lib/json/generic_object.rb",
55-
"lib/json/pure.rb",
56-
"lib/json/pure/generator.rb",
57-
"lib/json/pure/parser.rb",
58-
"lib/json/version.rb",
46+
*Dir["lib/**/*.rb"],
5947
]
60-
s.homepage = "https://ruby.github.io/json"
61-
s.metadata = {
62-
'bug_tracker_uri' => 'https://github.com/ruby/json/issues',
63-
'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md',
64-
'documentation_uri' => 'https://ruby.github.io/json/doc/index.html',
65-
'homepage_uri' => s.homepage,
66-
'source_code_uri' => 'https://github.com/ruby/json',
67-
'wiki_uri' => 'https://github.com/ruby/json/wiki'
68-
}
6948

70-
s.required_ruby_version = Gem::Requirement.new(">= 2.3")
49+
if java_ext
50+
s.platform = 'java'
51+
else
52+
s.extensions = Dir["ext/json/**/extconf.rb"]
53+
s.files += Dir["ext/json/**/*.{c,h,rl}"]
54+
end
55+
end
56+
57+
if RUBY_ENGINE == 'jruby' && $0 == __FILE__
58+
Gem::Builder.new(spec).build
59+
else
60+
spec
7161
end

0 commit comments

Comments
 (0)