+
+desc "Rebuilds selector.js from SizzleJS"
+task :selector => [:init, selector]
+
+desc "Tests built jquery.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.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.min.js..."
+
+ sh "#{minfier} --js #{jq} --warning_level QUIET --js_output_file #{jq_min}"
+
+ min = File.read( jq_min )
+
+ # Equivilent of "head"
+ File.open(jq_min, 'w') do |f|
+ f.write File.readlines(jq)[0..14].join()
+ f.write min
+ end
+end
+
+file selector => [sizzle, :init] do
+ puts "Building selector code from Sizzle..."
+
+ File.open(selector, 'w') do |f|
+ f.write File.read(sizzle).gsub(
+ /^.+EXPOSE$\n/,
+ '\0' + File.read( File.join( src_dir, 'sizzle-jquery.js' ))
+ ).gsub(
+ /^window.Sizzle.+$\n/, ''
+ )
+ end
+end
+
+file sizzle do
+ puts "Retrieving SizzleJS from Github..."
+ sh "git clone git://github.com/jeresig/sizzle.git #{sizzle_dir}"
+end
+
+file qunit do
+ puts "Retrieving QUnit from Github..."
+ sh "git clone git://github.com/jquery/qunit.git #{qunit_dir}"
+end
+
+
+def cat( files )
+ files.map do |file|
+ File.read(file)
+ end.join('')
+end
\ No newline at end of file