Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge json and json-java gemspecs #636

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ Gemfile.lock
*/**/*.jar
.byebug_history
*.log
/tmp

2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changes

### 2024-10-23 (2.7.3.rc1)

* Numerous performance optimizations in `JSON.generate` and `JSON.dump`.
* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source.
* Fix json-pure's `Object#to_json` to accept non state arguments
Expand Down
36 changes: 16 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 4 additions & 23 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ else
end

desc "Installing library (pure)"
task :install_pure => :version do
task :install_pure do
ruby 'install.rb'
end

Expand All @@ -79,24 +79,6 @@ task :install_ext => [ :compile, :install_pure, :install_ext_really ]
desc "Installing library (extension)"
task :install => :install_ext

desc m = "Writing version information for #{PKG_VERSION}"
task :version do
puts m
File.open(File.join('lib', 'json', 'version.rb'), 'w') do |v|
v.puts <<EOT
# frozen_string_literal: true
module JSON
# JSON version
VERSION = '#{PKG_VERSION}'
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
end
EOT
end
end

task :check_env do
ENV.key?('JSON') or fail "JSON env var is required"
end
Expand Down Expand Up @@ -191,9 +173,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)"
Expand Down Expand Up @@ -247,7 +228,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
task :create_jar => [ :create_parser_jar, :create_generator_jar ]

desc "Build all gems and archives for a new release of the jruby extension."
task :build => [ :clean, :version, :jruby_gem ]
task :build => [ :clean, :jruby_gem ]

task :release => :build
else
Expand Down Expand Up @@ -331,7 +312,7 @@ else
end

desc "Build all gems and archives for a new release of json and json_pure."
task :build => [ :clean, :version, :package ]
task :build => [ :clean, :package ]

task :release => :build
end
Expand Down
3 changes: 0 additions & 3 deletions ext/json/extconf.rb

This file was deleted.

36 changes: 0 additions & 36 deletions json-java.gemspec

This file was deleted.

88 changes: 39 additions & 49 deletions json.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
else
s.description = "This is a JSON implementation as a Ruby extension in C."
s.authors = ["Florian Frank"]
s.email = "[email protected]"
end

s.licenses = ["Ruby"]
s.authors = ["Florian Frank"]
s.email = "[email protected]"

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
8 changes: 2 additions & 6 deletions lib/json/version.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

module JSON
# JSON version
VERSION = '2.7.2'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
VERSION = '2.7.3.rc1'
end
Loading