prototype/Rakefile

93 lines
2.8 KiB
Ruby
Raw Normal View History

2007-01-18 22:24:27 +00:00
require 'rake'
require 'rake/packagetask'
PROTOTYPE_ROOT = File.expand_path(File.dirname(__FILE__))
PROTOTYPE_SRC_DIR = File.join(PROTOTYPE_ROOT, 'src')
PROTOTYPE_DIST_DIR = File.join(PROTOTYPE_ROOT, 'dist')
PROTOTYPE_PKG_DIR = File.join(PROTOTYPE_ROOT, 'pkg')
2008-09-08 08:23:20 +00:00
PROTOTYPE_TEST_DIR = File.join(PROTOTYPE_ROOT, 'test')
PROTOTYPE_TMP_DIR = File.join(PROTOTYPE_TEST_DIR, 'unit', 'tmp')
2008-09-29 01:09:16 +00:00
PROTOTYPE_VERSION = '1.6.0.3'
2007-01-18 22:24:27 +00:00
task :default => [:dist, :dist_helper, :package, :clean_package_source]
2007-01-18 22:24:27 +00:00
desc "Builds the distribution."
2007-01-18 22:24:27 +00:00
task :dist do
$:.unshift File.join(PROTOTYPE_ROOT, 'lib')
require 'protodoc'
Dir.chdir(PROTOTYPE_SRC_DIR) do
File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype.js'), 'w+') do |dist|
dist << Protodoc::Preprocessor.new('prototype.js')
end
end
end
desc "Builds the updating helper."
task :dist_helper do
$:.unshift File.join(PROTOTYPE_ROOT, 'lib')
require 'protodoc'
Dir.chdir(File.join(PROTOTYPE_ROOT, 'ext', 'update_helper')) do
File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype_update_helper.js'), 'w+') do |dist|
dist << Protodoc::Preprocessor.new('prototype_update_helper.js')
end
end
end
2007-01-18 22:24:27 +00:00
Rake::PackageTask.new('prototype', PROTOTYPE_VERSION) do |package|
package.need_tar_gz = true
package.package_dir = PROTOTYPE_PKG_DIR
package.package_files.include(
'[A-Z]*',
'dist/prototype.js',
'lib/**',
'src/**',
'test/**'
)
end
desc "Builds the distribution and the test suite, runs the tests and collects their results."
task :test => [:dist, :test_units]
2007-01-18 22:24:27 +00:00
require 'test/lib/jstest'
desc "Runs all the JavaScript unit tests and collects the results"
2008-09-08 08:23:20 +00:00
JavaScriptTestTask.new(:test_units => [:build_unit_tests]) do |t|
testcases = ENV['TESTCASES']
2007-01-18 22:24:27 +00:00
tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
2007-01-18 22:24:27 +00:00
t.mount("/dist")
t.mount("/test")
2008-09-08 08:23:20 +00:00
Dir.mkdir(PROTOTYPE_TMP_DIR) unless File.exist?(PROTOTYPE_TMP_DIR)
2008-09-08 08:23:20 +00:00
Dir["test/unit/tmp/*_test.html"].each do |file|
test_name = File.basename(file).sub("_test.html", "")
unless tests_to_run && !tests_to_run.include?(test_name)
2008-09-08 08:23:20 +00:00
t.run("/#{file}", testcases)
end
2007-01-18 22:24:27 +00:00
end
%w( safari firefox ie konqueror opera chrome ).each do |browser|
2007-01-18 22:24:27 +00:00
t.browser(browser.to_sym) unless browsers_to_test && !browsers_to_test.include?(browser)
end
end
2008-09-08 08:23:20 +00:00
task :build_unit_tests do
Dir[File.join('test', 'unit', '*_test.js')].each do |file|
PageBuilder.new(file, 'prototype.erb').render
end
end
task :clean_package_source do
rm_rf File.join(PROTOTYPE_PKG_DIR, "prototype-#{PROTOTYPE_VERSION}")
end
desc 'Generates an empty tmp directory for building tests.'
task :clean_tmp do
puts 'Generating an empty tmp directory for building tests.'
FileUtils.rm_rf(PROTOTYPE_TMP_DIR) if File.exist?(PROTOTYPE_TMP_DIR)
Dir.mkdir(PROTOTYPE_TMP_DIR)
end