Rakefile in json_pure-1.1.1 vs Rakefile in json_pure-1.1.2

- old
+ new

@@ -1,8 +1,11 @@ # vim: set et sw=2 ts=2: -require 'rake/gempackagetask' +begin + require 'rake/gempackagetask' +rescue LoadError +end require 'rake/clean' require 'rbconfig' include Config @@ -162,100 +165,63 @@ system 'RUBYOPT="" rcov -x tests -Ilib tests/runner.rb' end desc "Create RDOC documentation" task :doc => [ :version, EXT_PARSER_SRC ] do - sh "rdoc -m JSON -S -o doc #{FileList['lib/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}" + sh "rdoc -m JSON -S -o doc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}" end -spec_pure = Gem::Specification.new do |s| - s.name = 'json_pure' - s.version = PKG_VERSION - s.summary = "A JSON implementation in Ruby" - s.description = "" +if defined? Gem + spec_pure = Gem::Specification.new do |s| + s.name = 'json_pure' + s.version = PKG_VERSION + s.summary = "A JSON implementation in Ruby" + s.description = "" - s.files = PKG_FILES + s.files = PKG_FILES - s.require_path = 'lib' + s.require_path = 'lib' - s.bindir = "bin" - s.executables = ["edit_json.rb"] - s.default_executable = "edit_json.rb" + s.bindir = "bin" + s.executables = ["edit_json.rb"] + s.default_executable = "edit_json.rb" - s.has_rdoc = true - s.rdoc_options << - '--title' << 'JSON -- A JSON implemention' << - '--main' << 'JSON' << '--line-numbers' - s.test_files << 'tests/runner.rb' + s.has_rdoc = true + s.rdoc_options << + '--title' << 'JSON -- A JSON implemention' << + '--main' << 'JSON' << '--line-numbers' + s.test_files << 'tests/runner.rb' - s.author = "Florian Frank" - s.email = "flori@ping.de" - s.homepage = "http://json.rubyforge.org" - s.rubyforge_project = "json" -end + s.author = "Florian Frank" + s.email = "flori@ping.de" + s.homepage = "http://json.rubyforge.org" + s.rubyforge_project = "json" + end -Rake::GemPackageTask.new(spec_pure) do |pkg| - pkg.need_tar = true - pkg.package_files += PKG_FILES -end + Rake::GemPackageTask.new(spec_pure) do |pkg| + pkg.need_tar = true + pkg.package_files += PKG_FILES + end -spec_ext = Gem::Specification.new do |s| - s.name = 'json' - s.version = PKG_VERSION - s.summary = "A JSON implementation as a Ruby extension" - s.description = "" - - s.files = PKG_FILES - - s.extensions << - "#{EXT_PARSER_DIR}/extconf.rb" << - "#{EXT_GENERATOR_DIR}/extconf.rb" - - s.require_path = EXT_ROOT_DIR - s.require_paths << 'ext' - s.require_paths << 'lib' - - s.bindir = "bin" - s.executables = ["edit_json.rb"] - s.default_executable = "edit_json.rb" - - s.has_rdoc = true - s.rdoc_options << - '--title' << 'JSON -- A JSON implemention' << - '--main' << 'JSON' << '--line-numbers' - s.test_files << 'tests/runner.rb' - - s.author = "Florian Frank" - s.email = "flori@ping.de" - s.homepage = "http://json.rubyforge.org" - s.rubyforge_project = "json" -end - -Rake::GemPackageTask.new(spec_ext) do |pkg| - pkg.need_tar = true - pkg.package_files += PKG_FILES -end - -task :package_win => :compile do - mkdir_p 'pkg' - spec_win_ext = Gem::Specification.new do |s| + spec_ext = Gem::Specification.new do |s| s.name = 'json' - s.platform = Gem::Platform::WIN32 s.version = PKG_VERSION s.summary = "A JSON implementation as a Ruby extension" s.description = "" - s.files = PKG_FILES.to_a << - "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}" << - "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}" + s.files = PKG_FILES + s.extensions << + "#{EXT_PARSER_DIR}/extconf.rb" << + "#{EXT_GENERATOR_DIR}/extconf.rb" + s.require_path = EXT_ROOT_DIR s.require_paths << 'ext' s.require_paths << 'lib' s.bindir = "bin" - s.executables = ["edit_json.rb", "prettify_json.rb"] + s.executables = ["edit_json.rb"] s.default_executable = "edit_json.rb" s.has_rdoc = true s.rdoc_options << '--title' << 'JSON -- A JSON implemention' << @@ -266,13 +232,52 @@ s.email = "flori@ping.de" s.homepage = "http://json.rubyforge.org" s.rubyforge_project = "json" end - gem_file = "json-#{spec_win_ext.version}-#{spec_win_ext.platform}.gem" - Gem::Builder.new(spec_win_ext).build - mv gem_file, 'pkg' + Rake::GemPackageTask.new(spec_ext) do |pkg| + pkg.need_tar = true + pkg.package_files += PKG_FILES + end + + task :package_win => :compile do + mkdir_p 'pkg' + spec_win_ext = Gem::Specification.new do |s| + s.name = 'json' + s.platform = Gem::Platform::WIN32 + s.version = PKG_VERSION + s.summary = "A JSON implementation as a Ruby extension" + s.description = "" + + s.files = PKG_FILES.to_a << + "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}" << + "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}" + + s.require_path = EXT_ROOT_DIR + s.require_paths << 'ext' + s.require_paths << 'lib' + + s.bindir = "bin" + s.executables = ["edit_json.rb", "prettify_json.rb"] + s.default_executable = "edit_json.rb" + + s.has_rdoc = true + s.rdoc_options << + '--title' << 'JSON -- A JSON implemention' << + '--main' << 'JSON' << '--line-numbers' + s.test_files << 'tests/runner.rb' + + s.author = "Florian Frank" + s.email = "flori@ping.de" + s.homepage = "http://json.rubyforge.org" + s.rubyforge_project = "json" + end + + gem_file = "json-#{spec_win_ext.version}-#{spec_win_ext.platform}.gem" + Gem::Builder.new(spec_win_ext).build + mv gem_file, 'pkg' + end end task :mrproper => [ :ragel_clean, :clean ] do for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ] cd(dir) { rm_f 'Makefile' } @@ -296,10 +301,10 @@ EOT end end if ON_WINDOWS - task :release => [ :version, :clean, :compile, :package_win ] + task :release => [ :version, :clean, :package_win ] else task :release => [ :version, :mrproper, :package ] end task :default => [ :version, :compile ]