Rakefile in json_pure-1.6.5 vs Rakefile in json_pure-1.6.6
- old
+ new
@@ -2,25 +2,31 @@
require 'rubygems/package_task'
rescue LoadError
end
require 'rbconfig'
-begin
- include RbConfig
-rescue NameError
- include Config
-end
+include\
+ begin
+ RbConfig
+ rescue NameError
+ Config
+ end
-
require 'rake/clean'
-CLOBBER.include Dir['benchmarks/data/*.{dat,log}'], 'doc', 'Gemfile.lock'
+CLOBBER.include 'doc', 'Gemfile.lock'
CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'],
FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class,dSYM}"],
FileList['java/src/**/*.class']
-MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
+require 'rake/testtask'
+class UndocumentedTestTask < Rake::TestTask
+ def desc(*) end
+end
+
+MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
+BUNDLE = ENV['BUNDLE'] || %w[bundle].find { |c| system(c, '-v') }
PKG_NAME = 'json'
PKG_TITLE = 'JSON Implementation for Ruby'
PKG_VERSION = File.read('VERSION').chomp
PKG_FILES = FileList[`git ls-files`.split(/\n/)]
@@ -42,23 +48,13 @@
JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
-def myruby(*args, &block)
- @myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
- options = (Hash === args.last) ? args.pop : {}
- if args.length > 1 then
- sh(*([@myruby] + args + [options]), &block)
- else
- sh("#{@myruby} #{args.first}", options, &block)
- end
-end
-
desc "Installing library (pure)"
task :install_pure => :version do
- myruby 'install.rb'
+ ruby 'install.rb'
end
task :install_ext_really do
sitearchdir = CONFIG["sitearchdir"]
cd 'ext' do
@@ -73,15 +69,11 @@
desc "Installing library (extension)"
task :install_ext => [ :compile, :install_pure, :install_ext_really ]
desc "Installing library (extension)"
-if RUBY_PLATFORM =~ /java/
- task :install => :install_pure
-else
- task :install => :install_ext
-end
+task :install => :install_ext
if defined?(Gem) and defined?(Gem::PackageTask)
spec_pure = Gem::Specification.new do |s|
s.name = 'json_pure'
s.version = PKG_VERSION
@@ -90,11 +82,10 @@
s.files = PKG_FILES
s.require_path = 'lib'
s.add_development_dependency 'permutation'
- s.add_development_dependency 'bullshit'
s.add_development_dependency 'sdoc'
s.add_development_dependency 'rake', '~>0.9.2'
s.extra_rdoc_files << 'README.rdoc'
s.rdoc_options <<
@@ -131,11 +122,10 @@
s.require_path = EXT_ROOT_DIR
s.require_paths << 'ext'
s.require_paths << 'lib'
s.add_development_dependency 'permutation'
- s.add_development_dependency 'bullshit'
s.add_development_dependency 'sdoc'
s.extra_rdoc_files << 'README.rdoc'
s.rdoc_options <<
'--title' << 'JSON implemention for Ruby' << '--main' << 'README.rdoc'
@@ -180,22 +170,30 @@
EOT
end
end
desc "Testing library (pure ruby)"
-task :test_pure => :clean do
- ENV['JSON'] = 'pure'
- ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
- myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
+task :test_pure => [ :clean, :do_test_pure ]
+
+UndocumentedTestTask.new do |t|
+ t.name = 'do_test_pure'
+ t.libs << 'lib'
+ t.test_files = FileList['tests/test_*.rb']
+ t.verbose = true
+ t.options = '-v'
end
desc "Testing library (pure ruby and extension)"
-task :test => [ :test_pure, :test_ext ]
+task :test do
+ sh "env JSON=pure #{BUNDLE} exec rake test_pure" or exit 1
+ sh "env JSON=ext #{BUNDLE} exec rake test_ext" or exit 1
+end
namespace :gems do
+ desc 'Install all development gems'
task :install do
- sh 'bundle'
+ sh "#{BUNDLE}"
end
end
if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
if ENV.key?('JAVA_HOME')
@@ -248,13 +246,18 @@
mkdir_p 'pkg'
mv "json-#{PKG_VERSION}-java.gem", 'pkg'
end
desc "Testing library (jruby)"
- task :test_ext => :create_jar do
- ENV['JSON'] = 'ext'
- myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
+ task :test_ext => [ :create_jar, :do_test_ext ]
+
+ UndocumentedTestTask.new do |t|
+ t.name = 'do_test_ext'
+ t.libs << 'lib'
+ t.test_files = FileList['tests/test_*.rb']
+ t.verbose = true
+ t.options = '-v'
end
file JRUBY_PARSER_JAR => :compile do
cd 'java/src' do
parser_classes = FileList[
@@ -302,46 +305,33 @@
desc "Compiling extension"
task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
file EXT_PARSER_DL => EXT_PARSER_SRC do
cd EXT_PARSER_DIR do
- myruby 'extconf.rb'
+ ruby 'extconf.rb'
sh MAKE
end
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
end
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
cd EXT_GENERATOR_DIR do
- myruby 'extconf.rb'
+ ruby 'extconf.rb'
sh MAKE
end
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
end
desc "Testing library (extension)"
- task :test_ext => :compile do
- ENV['JSON'] = 'ext'
- ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
- myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
- end
+ task :test_ext => [ :compile, :do_test_ext ]
- desc "Benchmarking parser"
- task :benchmark_parser do
- ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
- myruby 'benchmarks/parser_benchmark.rb'
- myruby 'benchmarks/parser2_benchmark.rb'
+ UndocumentedTestTask.new do |t|
+ t.name = 'do_test_ext'
+ t.libs << 'ext' << 'lib'
+ t.test_files = FileList['tests/test_*.rb']
+ t.verbose = true
+ t.options = '-v'
end
-
- desc "Benchmarking generator"
- task :benchmark_generator do
- ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
- myruby 'benchmarks/generator_benchmark.rb'
- myruby 'benchmarks/generator2_benchmark.rb'
- end
-
- desc "Benchmarking library"
- task :benchmark => [ :benchmark_parser, :benchmark_generator ]
desc "Create RDOC documentation"
task :doc => [ :version, EXT_PARSER_SRC ] do
sh "sdoc -o doc -t '#{PKG_TITLE}' -m README.rdoc README.rdoc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
end