| 1 |
require 'rake' |
|---|
| 2 |
require 'rake/packagetask' |
|---|
| 3 |
|
|---|
| 4 |
PROTOTYPE_ROOT = File.expand_path(File.dirname(__FILE__)) |
|---|
| 5 |
PROTOTYPE_SRC_DIR = File.join(PROTOTYPE_ROOT, 'src') |
|---|
| 6 |
PROTOTYPE_DIST_DIR = File.join(PROTOTYPE_ROOT, 'dist') |
|---|
| 7 |
PROTOTYPE_PKG_DIR = File.join(PROTOTYPE_ROOT, 'pkg') |
|---|
| 8 |
PROTOTYPE_VERSION = '1.5.2_pre0' |
|---|
| 9 |
|
|---|
| 10 |
task :default => [:dist, :package, :clean_package_source] |
|---|
| 11 |
|
|---|
| 12 |
task :dist do |
|---|
| 13 |
$:.unshift File.join(PROTOTYPE_ROOT, 'lib') |
|---|
| 14 |
require 'protodoc' |
|---|
| 15 |
|
|---|
| 16 |
Dir.chdir(PROTOTYPE_SRC_DIR) do |
|---|
| 17 |
File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype.js'), 'w+') do |dist| |
|---|
| 18 |
dist << Protodoc::Preprocessor.new('prototype.js') |
|---|
| 19 |
end |
|---|
| 20 |
end |
|---|
| 21 |
end |
|---|
| 22 |
|
|---|
| 23 |
Rake::PackageTask.new('prototype', PROTOTYPE_VERSION) do |package| |
|---|
| 24 |
package.need_tar_gz = true |
|---|
| 25 |
package.package_dir = PROTOTYPE_PKG_DIR |
|---|
| 26 |
package.package_files.include( |
|---|
| 27 |
'[A-Z]*', |
|---|
| 28 |
'dist/prototype.js', |
|---|
| 29 |
'lib/**', |
|---|
| 30 |
'src/**', |
|---|
| 31 |
'test/**' |
|---|
| 32 |
) |
|---|
| 33 |
end |
|---|
| 34 |
|
|---|
| 35 |
task :test => [:dist, :test_units] |
|---|
| 36 |
|
|---|
| 37 |
require 'test/lib/jstest' |
|---|
| 38 |
desc "Runs all the JavaScript unit tests and collects the results" |
|---|
| 39 |
JavaScriptTestTask.new(:test_units) do |t| |
|---|
| 40 |
tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',') |
|---|
| 41 |
browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',') |
|---|
| 42 |
|
|---|
| 43 |
t.mount("/dist") |
|---|
| 44 |
t.mount("/test") |
|---|
| 45 |
|
|---|
| 46 |
Dir["test/unit/*.html"].sort.each do |test_file| |
|---|
| 47 |
test_file = "/#{test_file}" |
|---|
| 48 |
test_name = test_file[/.*\/(.+?)\.html/, 1] |
|---|
| 49 |
t.run(test_file) unless tests_to_run && !tests_to_run.include?(test_name) |
|---|
| 50 |
end |
|---|
| 51 |
|
|---|
| 52 |
%w( safari firefox ie konqueror ).each do |browser| |
|---|
| 53 |
t.browser(browser.to_sym) unless browsers_to_test && !browsers_to_test.include?(browser) |
|---|
| 54 |
end |
|---|
| 55 |
end |
|---|
| 56 |
|
|---|
| 57 |
task :clean_package_source do |
|---|
| 58 |
rm_rf File.join(PROTOTYPE_PKG_DIR, "prototype-#{PROTOTYPE_VERSION}") |
|---|
| 59 |
end |
|---|