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-01-25 22:57:06 +00:00
|
|
|
PROTOTYPE_VERSION = '1.6.0.2'
|
2007-01-18 22:24:27 +00:00
|
|
|
|
|
|
|
task :default => [:dist, :package, :clean_package_source]
|
|
|
|
|
2008-01-07 19:24:18 +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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2008-01-07 19:24:18 +00:00
|
|
|
desc "Builds the distribution, runs the JavaScript unit tests and collects their results."
|
2007-01-18 22:24:27 +00:00
|
|
|
task :test => [:dist, :test_units]
|
|
|
|
|
|
|
|
require 'test/lib/jstest'
|
|
|
|
desc "Runs all the JavaScript unit tests and collects the results"
|
|
|
|
JavaScriptTestTask.new(:test_units) do |t|
|
2008-01-06 00:34:39 +00:00
|
|
|
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(',')
|
2008-01-06 00:34:39 +00:00
|
|
|
|
2007-01-18 22:24:27 +00:00
|
|
|
t.mount("/dist")
|
|
|
|
t.mount("/test")
|
|
|
|
|
2007-03-27 18:50:43 +00:00
|
|
|
Dir["test/unit/*.html"].sort.each do |test_file|
|
2008-01-06 00:34:39 +00:00
|
|
|
tests = testcases ? { :url => "/#{test_file}", :testcases => testcases } : "/#{test_file}"
|
|
|
|
test_filename = test_file[/.*\/(.+?)\.html/, 1]
|
|
|
|
t.run(tests) unless tests_to_run && !tests_to_run.include?(test_filename)
|
2007-01-18 22:24:27 +00:00
|
|
|
end
|
|
|
|
|
2007-08-04 04:40:22 +00:00
|
|
|
%w( safari firefox ie konqueror opera ).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
|
|
|
|
|
|
|
|
task :clean_package_source do
|
|
|
|
rm_rf File.join(PROTOTYPE_PKG_DIR, "prototype-#{PROTOTYPE_VERSION}")
|
|
|
|
end
|