Skip to content

Commit

Permalink
Turn json_pure into an empty gem
Browse files Browse the repository at this point in the history
Fix: #650
Closes: #682
  • Loading branch information
byroot committed Nov 5, 2024
1 parent f373b8c commit cbd79f7
Show file tree
Hide file tree
Showing 9 changed files with 638 additions and 1,081 deletions.
51 changes: 10 additions & 41 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ else
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find(&which)
end

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

task :install_ext_really do
desc "Installing library (extension)"
task :install => [ :compile ] do
sitearchdir = CONFIG["sitearchdir"]
cd 'ext' do
for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
Expand All @@ -73,30 +69,6 @@ task :install_ext_really do
end
end

desc "Installing library (extension)"
task :install_ext => [ :compile, :install_pure, :install_ext_really ]

desc "Installing library (extension)"
task :install => :install_ext

task :check_env do
ENV.key?('JSON') or fail "JSON env var is required"
end

desc "Testing library (pure ruby)"
task :test_pure => [ :set_env_pure, :check_env, :do_test_pure ]
task(:set_env_pure) { ENV['JSON'] = 'pure' }

UndocumentedTestTask.new do |t|
t.name = 'do_test_pure'
t.test_files = FileList['test/json/*_test.rb']
t.verbose = true
t.options = '-v'
end

desc "Testing library (pure ruby and extension)"
task :test => [ :test_pure, :test_ext ]

namespace :gems do
desc 'Install all development gems'
task :install do
Expand Down Expand Up @@ -177,16 +149,14 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
sh "gem build -o pkg/json-#{PKG_VERSION}-java.gem json.gemspec"
end

desc "Testing library (jruby)"
task :test_ext => [ :set_env_ext, :create_jar, :check_env, :do_test_ext ]
task(:set_env_ext) { ENV['JSON'] = 'ext' }

UndocumentedTestTask.new do |t|
t.name = 'do_test_ext'
t.name = :test
t.test_files = FileList['test/json/*_test.rb']
t.verbose = true
t.options = '-v'
end
desc "Testing library (jruby)"
task :test => [:create_jar ]

file JRUBY_PARSER_JAR => :compile do
cd 'java/src' do
Expand Down Expand Up @@ -239,20 +209,19 @@ else
task :compile => [ :ragel, EXT_PARSER_DL, EXT_GENERATOR_DL ]
end

desc "Testing library (extension)"
task :test_ext => [ :set_env_ext, :check_env, :compile, :do_test_ext ]
task(:set_env_ext) { ENV['JSON'] = 'ext' }

UndocumentedTestTask.new do |t|
t.name = 'do_test_ext'
t.name = :test
t.test_files = FileList['test/json/*_test.rb']
t.verbose = true
t.options = '-v'
end

desc "Testing library (extension)"
task :test => [ :compile ]

begin
require "ruby_memcheck"
RubyMemcheck::TestTask.new(valgrind: [ :set_env_ext, :check_env, :compile, :do_test_ext ]) do |t|
RubyMemcheck::TestTask.new(valgrind: [ :compile, :test ]) do |t|
t.test_files = FileList['test/json/*_test.rb']
t.verbose = true
t.options = '-v'
Expand Down
23 changes: 2 additions & 21 deletions json_pure.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,7 @@ Gem::Specification.new do |s|
"LEGAL",
"README.md",
"json_pure.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/generic_object.rb",
"lib/json/pure.rb",
"lib/json/pure/generator.rb",
"lib/json/pure/parser.rb",
"lib/json/version.rb",
]
s.homepage = "https://ruby.github.io/json"
s.metadata = {
Expand All @@ -56,5 +35,7 @@ Gem::Specification.new do |s|
'wiki_uri' => 'https://github.com/ruby/json/wiki'
}

s.add_dependency "json"

s.required_ruby_version = Gem::Requirement.new(">= 2.7")
end
7 changes: 1 addition & 6 deletions lib/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,5 @@
#
module JSON
require 'json/version'

begin
require 'json/ext'
rescue LoadError
require 'json/pure'
end
require 'json/ext'
end
6 changes: 2 additions & 4 deletions lib/json/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ module JSON
module Ext
if RUBY_ENGINE == 'truffleruby'
require 'json/ext/parser'
require 'json/pure'
$DEBUG and warn "Using Ext extension for JSON parser and Pure library for JSON generator."
require 'json/ext/truffle_ruby_generator'
JSON.parser = Parser
JSON.generator = JSON::Pure::Generator
JSON.generator = TruffleRubyGenerator
else
require 'json/ext/parser'
require 'json/ext/generator'
$DEBUG and warn "Using Ext extension for JSON."
JSON.parser = Parser
JSON.generator = Generator
end
Expand Down
Loading

0 comments on commit cbd79f7

Please sign in to comment.