Skip to content

Commit

Permalink
pulled in the rake build from jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
heygrady committed Oct 7, 2010
1 parent 9763970 commit 013b56a
Show file tree
Hide file tree
Showing 15 changed files with 7,454 additions and 50 deletions.
81 changes: 81 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
prefix = File.dirname( __FILE__ )

# Directory variables
src_dir = File.join( prefix, 'src' )
build_dir = File.join( prefix, 'build' )
test_dir = File.join( prefix, 'test' )

# A different destination directory can be set by
# setting DIST_DIR before calling rake
dist_dir = ENV['DIST_DIR'] || File.join( prefix, 'dist' )

base_files = %w{transform transform.attributes transform.animate angle matrix matrix.calculations matrix.functions}.map { |js| File.join( src_dir, "jquery.#{js}.js" ) }

# General Variables
date = `git log -1`[/^Date:\s+(.+)$/, 1]
version = File.read( File.join( prefix, 'version.txt' ) ).strip

# jQuery files/dirs
jq = File.join( dist_dir, "jquery.transform-#{version}.js" )
jq_min = File.join( dist_dir, "jquery.transform-#{version}.min.js" )


# Build tools
rhino = "java -jar \"#{build_dir}/js.jar\""
minfier = "java -jar \"#{build_dir}/yuicompressor-2.4.2.jar\""

# Turn off output other than needed from `sh` and file commands
verbose(false)

# Tasks
task :default => "all"

desc "Builds jQuery; Tests with JSLint; Minifies jQuery"
task :all => [:jquery, :lint, :min] do
puts "jQuery build complete."
end

desc "Builds jQuery Transform: jquery.transform.js (Default task)"
task :jquery => [jq]

desc "Builds a minified version of jQuery Transform: jquery.transform.min.js"
task :min => jq_min


task :init => [] do
end

desc "Removes dist folder"
task :clean do
puts "Removing Distribution directory: #{dist_dir}..."
rm_rf dist_dir
end

desc "Tests built jquery.transform.js against JSLint"
task :lint => jq do
puts "Checking jQuery against JSLint..."
sh "#{rhino} \"" + File.join(build_dir, 'jslint-check.js') + "\""
end


# File and Directory Dependencies
directory dist_dir

file jq => [dist_dir, base_files].flatten do
puts "Building jquery.transform.js..."

File.open(jq, 'w') do |f|
f.write cat(base_files).gsub(/(Date:.)/, "\\1#{date}" ).gsub(/@VERSION/, version)
end
end

file jq_min => jq do
puts "Building jquery.transform.min.js..."
sh "#{minfier} -o \"#{jq_min}\" \"#{jq}\""
end

def cat( files )
files.map do |file|
File.read(file)
end.join('')
end
Binary file added build/js.jar
Binary file not shown.
36 changes: 36 additions & 0 deletions build/jslint-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("build/jslint.js");

var src = readFile("dist/jquery.js");

JSLINT(src, { evil: true, forin: true, maxerr: 100 });

// All of the following are known issues that we think are 'ok'
// (in contradiction with JSLint) more information here:
// http://docs.jquery.com/JQuery_Core_Style_Guidelines
var ok = {
"Expected an identifier and instead saw 'undefined' (a reserved word).": true,
"Use '===' to compare with 'null'.": true,
"Use '!==' to compare with 'null'.": true,
"Expected an assignment or function call and instead saw an expression.": true,
"Expected a 'break' statement before 'case'.": true

};

var e = JSLINT.errors, found = 0, w;

for ( var i = 0; i < e.length; i++ ) {
w = e[i];

if ( !ok[ w.reason ] ) {
found++;
print( "\n" + w.evidence + "\n" );
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
}
}

if ( found > 0 ) {
print( "\n" + found + " Error(s) found." );

} else {
print( "JSLint check passed." );
}
Loading

0 comments on commit 013b56a

Please sign in to comment.