SAFARI = '/Applications/Safari.app/Contents/MacOS/Safari' def exit_msg(msg, code=1) puts msg exit(code) end def run command res = `#{command}` stat = $?.exitstatus if stat != 0 if block_given? (return (yield res, stat)) else exit_msg res, stat end end res end def out command (puts (run command)) end desc "mirror to jquery svn repository" task :mirror do name = File.basename(Dir.pwd).gsub(/[^-]+-/,'').gsub(/(^uitable)(.)/) do "uiTable#{$2.upcase}" end svn_dir = "/home/greg/src/jqueryjs/plugins/#{name}/" puts "copying to directory: #{svn_dir}" out "cp -R * #{svn_dir}" commit_msg = `git log | head -5 | tail -1`.chomp Dir.chdir(svn_dir) do out "svn commit -m '#{commit_msg}'" end end desc "run test" task :test do test_files = Dir[ 'test/*_spec.html' ].join(' ') run( "#{ENV['BROWSER'] || 'konqueror'} #{test_files}" ) do |r,s| run( "#{SAFARI} #{test_files}" ) end end