diff --git a/.gitignore b/.gitignore index b621a3e9..8ae6ac11 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ Gemfile.lock */**/*.jar .byebug_history *.log +/tmp + diff --git a/Gemfile b/Gemfile index 3d74f7ff..50249b0c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,27 +1,23 @@ -# vim: set ft=ruby: - source 'https://rubygems.org' -case ENV['JSON'] -when 'ext', nil - if ENV['RUBY_ENGINE'] == 'jruby' - gemspec :name => 'json-java' - else - gemspec :name => 'json' - end -when 'pure' - gemspec :name => 'json_pure' +if ENV['JSON'] == 'pure' + gemspec name: 'json_pure' +else + gemspec name: 'json' end -gem "rake" -gem "test-unit" -gem "test-unit-ruby-core" -gem "all_images", "~> 0" unless RUBY_PLATFORM =~ /java/ +group :development do + gem "rake" + gem "rake-compiler" + gem "test-unit" + gem "test-unit-ruby-core" + gem "all_images", "~> 0" unless RUBY_PLATFORM =~ /java/ -if ENV['BENCHMARK'] - gem "benchmark-ips" - unless RUBY_PLATFORM =~ /java/ - gem "oj" - gem "rapidjson" + if ENV['BENCHMARK'] + gem "benchmark-ips" + unless RUBY_PLATFORM =~ /java/ + gem "oj" + gem "rapidjson" + end end end diff --git a/README.md b/README.md index 3b0b6ebf..94a35d7b 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ the `pp` library's `pp` methods. ### Release -Update the json.gemspec and json-java.gemspec. +Update the `lib/json/version.rb` file. ``` rbenv shell 2.6.5 diff --git a/Rakefile b/Rakefile index 81e8bd9b..307b86d3 100644 --- a/Rakefile +++ b/Rakefile @@ -191,9 +191,8 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby' desc "Package the jruby gem" task :jruby_gem => :create_jar do - sh 'gem build json-java.gemspec' mkdir_p 'pkg' - mv "json-#{PKG_VERSION}-java.gem", 'pkg' + sh "gem build -o pkg/json-#{PKG_VERSION}-java.gem json.gemspec" end desc "Testing library (jruby)" diff --git a/ext/json/extconf.rb b/ext/json/extconf.rb deleted file mode 100644 index 8a99b6a5..00000000 --- a/ext/json/extconf.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'mkmf' - -create_makefile('json') diff --git a/json-java.gemspec b/json-java.gemspec deleted file mode 100644 index ad357c88..00000000 --- a/json-java.gemspec +++ /dev/null @@ -1,36 +0,0 @@ -version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line| - /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1 -end rescue nil - -spec = Gem::Specification.new do |s| - s.name = "json" - s.version = version - - s.summary = "JSON Implementation for Ruby" - s.description = "A JSON implementation as a JRuby extension." - s.licenses = ["Ruby"] - s.author = "Daniel Luz" - s.email = "dev+ruby@mernen.com" - - s.platform = 'java' - - s.files = Dir["lib/**/*", "COPYING", "LEGAL", "BSDL"] - - s.homepage = "https://ruby.github.io/json" - s.metadata = { - 'bug_tracker_uri' => 'https://github.com/ruby/json/issues', - 'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md', - 'documentation_uri' => 'https://ruby.github.io/json/doc/index.html', - 'homepage_uri' => s.homepage, - 'source_code_uri' => 'https://github.com/ruby/json', - 'wiki_uri' => 'https://github.com/ruby/json/wiki' - } - - s.required_ruby_version = Gem::Requirement.new(">= 2.3") -end - -if $0 == __FILE__ - Gem::Builder.new(spec).build -else - spec -end diff --git a/json.gemspec b/json.gemspec index 39b0155d..96721f90 100644 --- a/json.gemspec +++ b/json.gemspec @@ -2,70 +2,60 @@ version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line| /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1 end rescue nil -Gem::Specification.new do |s| +spec = Gem::Specification.new do |s| + java_ext = Gem::Platform === s.platform && s.platform =~ 'java' || RUBY_ENGINE == 'jruby' + s.name = "json" s.version = version s.summary = "JSON Implementation for Ruby" - s.description = "This is a JSON implementation as a Ruby extension in C." + s.homepage = "https://ruby.github.io/json" + s.metadata = { + 'bug_tracker_uri' => 'https://github.com/ruby/json/issues', + 'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md', + 'documentation_uri' => 'https://ruby.github.io/json/doc/index.html', + 'homepage_uri' => s.homepage, + 'source_code_uri' => 'https://github.com/ruby/json', + 'wiki_uri' => 'https://github.com/ruby/json/wiki' + } + + s.required_ruby_version = Gem::Requirement.new(">= 2.3") + + if java_ext + s.description = "A JSON implementation as a JRuby extension." + s.author = "Daniel Luz" + s.email = "dev+ruby@mernen.com" + else + s.description = "This is a JSON implementation as a Ruby extension in C." + s.authors = ["Florian Frank"] + s.email = "flori@ping.de" + end + s.licenses = ["Ruby"] - s.authors = ["Florian Frank"] - s.email = "flori@ping.de" - s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"] s.extra_rdoc_files = ["README.md"] s.rdoc_options = ["--title", "JSON implementation for Ruby", "--main", "README.md"] + s.files = [ "CHANGES.md", "COPYING", "BSDL", "LEGAL", "README.md", - "ext/json/ext/fbuffer/fbuffer.h", - "ext/json/ext/generator/depend", - "ext/json/ext/generator/extconf.rb", - "ext/json/ext/generator/generator.c", - "ext/json/ext/generator/generator.h", - "ext/json/ext/parser/depend", - "ext/json/ext/parser/extconf.rb", - "ext/json/ext/parser/parser.c", - "ext/json/ext/parser/parser.h", - "ext/json/ext/parser/parser.rl", - "ext/json/extconf.rb", "json.gemspec", - "lib/json.rb", - "lib/json/add/bigdecimal.rb", - "lib/json/add/complex.rb", - "lib/json/add/core.rb", - "lib/json/add/date.rb", - "lib/json/add/date_time.rb", - "lib/json/add/exception.rb", - "lib/json/add/ostruct.rb", - "lib/json/add/range.rb", - "lib/json/add/rational.rb", - "lib/json/add/regexp.rb", - "lib/json/add/set.rb", - "lib/json/add/struct.rb", - "lib/json/add/symbol.rb", - "lib/json/add/time.rb", - "lib/json/common.rb", - "lib/json/ext.rb", - "lib/json/ext/generator/state.rb", - "lib/json/generic_object.rb", - "lib/json/pure.rb", - "lib/json/pure/generator.rb", - "lib/json/pure/parser.rb", - "lib/json/version.rb", + *Dir["lib/**/*.rb"], ] - s.homepage = "https://ruby.github.io/json" - s.metadata = { - 'bug_tracker_uri' => 'https://github.com/ruby/json/issues', - 'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md', - 'documentation_uri' => 'https://ruby.github.io/json/doc/index.html', - 'homepage_uri' => s.homepage, - 'source_code_uri' => 'https://github.com/ruby/json', - 'wiki_uri' => 'https://github.com/ruby/json/wiki' - } - s.required_ruby_version = Gem::Requirement.new(">= 2.3") + if java_ext + s.platform = 'java' + else + s.extensions = Dir["ext/json/**/extconf.rb"] + s.files += Dir["ext/json/**/*.{c,h,rl}"] + end +end + +if RUBY_ENGINE == 'jruby' && $0 == __FILE__ + Gem::Builder.new(spec).build +else + spec end