Skip to content

Instantly share code, notes, and snippets.

@eivindingebrigtsen
Created November 4, 2010 09:31
Show Gist options
  • Save eivindingebrigtsen/662277 to your computer and use it in GitHub Desktop.
Save eivindingebrigtsen/662277 to your computer and use it in GitHub Desktop.
PATH = 'js/mustaches';
desc 'update git repo from upstream repository'
task :up do
sh('git stash')
sh('git svn rebase')
sh('git stash apply')
end
desc 'send up code changes to upstream repository'
task :c => [:up] do
sh('git add -u')
sh("git commit -m'#{ENV['m']}'" )
sh('git svn rebase')
sh('git svn dcommit')
end
desc "make mustache templates"
task :default do
src = 'SB.extend({templates: {';
length = Dir[PATH+'/*.mustache'].length;
Dir[PATH+'/*.mustache'].each do |f|
file = File.open(f, 'rb').read();
file.gsub!(/\n|\r|\t/, '')
src += File.basename(f).gsub(/\.mustache/, '') + " : '" + file + "',";
end
src += 'done:true}});';
File.open('js/src/templates.js', 'wb'){|io| io.write(src) }
puts "Saved " + length.to_s + ' templates'
end
desc "Pack all javascript files"
task :pack do
puts '###### PACKING JS #######'
js = [
[true, 'js/ext/jquery.js'],
[true, 'js/ext/date-nb-NO.js'],
[false, 'js/ext/underscore-min.js'],
[true, 'js/ext/jquery-ui-1.8.5.js'],
[true, 'js/ext/jquery.tiptip.js'],
[true, 'js/ext/excanvas.js'],
[true, 'js/ext/thejit.js'],
[true, 'js/ext/mustache.js'],
[true, 'js/src/extensions.js'],
[true, 'js/src/core.js'],
[true, 'js/src/utils.js'],
[true, 'js/src/templates.js'],
[true, 'js/src/handlers.js'],
[true, 'js/src/callbacks.js'],
[true, 'js/src/api.js'],
[true, 'js/src/table.js'],
[true, 'js/src/list.js'],
[true, 'js/src/datepicker.js'],
[true, 'js/src/accounts.js'],
[true, 'js/src/search.js'],
[true, 'js/src/autocomplete.js'],
[true, 'js/src/browser.js'],
[true, 'js/src/options.js'],
[true, 'js/src/treemap.js'],
[true, 'js/src/events.js']
].map do |pack, file|
if(pack)
puts "compressing #{file}"
`java -jar js/bin/yuicompressor-2.4.2.jar #{file}`
else
puts "reading #{file}"
IO.read(file)
end
end
File.open('js/min/SB.js', 'w'){|io| io.write(js.join("\n"))}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment