end
end
File.open('js/min/SB.js', 'w'){|io| io.write(js.join("\n"))}
end
desc 'Replace Tabs with spaces'
task :tabs do
puts '###### TABS #######'
Dir['*/'].each do |f|
puts File.basename(f)
next if File.directory?(f)
source = File.open(f, 'rb').read
case File.extname(f)
when '.js', '.css', '.html', '.sass', '.mustache'
next if File.dirname(f).match(/ext/)
source.gsub!(/\t/, ' ')
end
File.open("#{File.dirname(f)}/#{File.basename(f)}", 'wb') {|io| io.write(source)}
end
end
desc 'strip console logs'
task :strip => [:tabs] do
puts '###### STRIPPING CONSOLE CALLS #######'
rm_rf(TMP)
mkdirp(TMP)
Dir[PATH+'/*/_.js'].each do |f|
next if File.directory?(f) || File.basename(f) =~ /(min.|tests.|pack.|compiled.)/
source = File.open(f, 'rb').read
file = File.basename(f)
stripped = source
stripped = source.gsub(/SB.(time|log)(.*?)[)\;\n]/, '')
File.open(TMP+'/'+file, 'w'){|io| io.write(stripped)}
end
end
task :r => [:mustache, :pack] do
puts('Aaayay')
end
desc 'Compile less files (windows OS)'
task :lessCompile do
puts '###### COMPILE css/.less => css/.css#######'
count = 0
Dir['css/*.less'].each do |f|
next if File.directory?(f)
sh('cscript bin/lessc.wsf ' +f + ' ' +File.dirname(f) +'/' + File.basename(f,'.less') + '.css -compress')
count =+ 1
puts(File.basename(f) + ' => ' + File.basename(f,'.less') + '.css')
end
puts('Total files compiled: ' +count.to_s)
end
desc 'Compile less files (windows OS) and run rake'
task :lessCompileRake => [:lessCompile, :css, :pack]
PATH = 'javascript/mustaches'; TMP = 'tmp'; COMPRESS_FILES = false; #Should be true when releasing a version
desc 'update git repo from upstream repository' task :up do sh('git stash') sh('git svn rebase') sh('git stash apply') end
desc 'fix issue commit' task :f => [:pack]do sh("git commit -am'resolves issue NBP-#{ENV['m']}'" ) 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
task :default =>[:mustache]
desc "make mustache templates" task :mustache do src = 'SB.extend({templates: {'; length = Dir[PATH+'/*.mustache'].length;
end
desc "Pack all css" task :css do css = [ [COMPRESS_FILES, "css/jquery-ui.css"], [COMPRESS_FILES, "css/edb/master.css"], [COMPRESS_FILES, "css/stb/main.css"], [COMPRESS_FILES, "css/stb/defaults.css"], [COMPRESS_FILES, "css/stb/tables.css"], [COMPRESS_FILES, "css/stb/navigation.css"], [COMPRESS_FILES, "css/master.css"],
[COMPRESS_FILES, "css/budget.css"]
].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('css/all.css', 'w'){|io| io.write(css.join("\n"))}end
desc "Pack all external javascript files" task :ext do packMe = true js = [ [COMPRESS_FILES, 'js/ext/jquery-1.7.min.js' ], [COMPRESS_FILES, 'js/ext/json2.js' ], [COMPRESS_FILES, 'js/ext/excanvas.js' ], [COMPRESS_FILES, 'js/ext/highcharts.src.js' ], [COMPRESS_FILES, 'js/ext/thejit.js' ], [COMPRESS_FILES, 'js/ext/date-nb-NO.js' ], [COMPRESS_FILES, 'js/ext/jquery.bbq.js' ], [COMPRESS_FILES, 'js/ext/waypoints.js' ], [COMPRESS_FILES, 'js/ext/jquery.cookie.js' ],
[COMPRESS_FILES, 'js/ext/modernizr.js' ],
end File.open('js/min/ext.js', 'w'){|io| io.write(js.join("\n"))} end
desc "Pack all javascript files" task :pack => [:mustache] do puts '###### PACKING JS #######' js = [
External scripts
end end File.open('js/min/SB.js', 'w'){|io| io.write(js.join("\n"))} end
desc 'Replace Tabs with spaces' task :tabs do puts '###### TABS #######' Dir['*/'].each do |f| puts File.basename(f) next if File.directory?(f) source = File.open(f, 'rb').read case File.extname(f) when '.js', '.css', '.html', '.sass', '.mustache' next if File.dirname(f).match(/ext/) source.gsub!(/\t/, ' ') end File.open("#{File.dirname(f)}/#{File.basename(f)}", 'wb') {|io| io.write(source)} end end
desc 'strip console logs' task :strip => [:tabs] do puts '###### STRIPPING CONSOLE CALLS #######' rm_rf(TMP) mkdirp(TMP) Dir[PATH+'/*/_.js'].each do |f| next if File.directory?(f) || File.basename(f) =~ /(min.|tests.|pack.|compiled.)/ source = File.open(f, 'rb').read file = File.basename(f) stripped = source stripped = source.gsub(/SB.(time|log)(.*?)[)\;\n]/, '') File.open(TMP+'/'+file, 'w'){|io| io.write(stripped)} end end task :r => [:mustache, :pack] do puts('Aaayay') end
desc 'Compile less files (windows OS)' task :lessCompile do puts '###### COMPILE css/.less => css/.css#######' count = 0 Dir['css/*.less'].each do |f| next if File.directory?(f) sh('cscript bin/lessc.wsf ' +f + ' ' +File.dirname(f) +'/' + File.basename(f,'.less') + '.css -compress') count =+ 1 puts(File.basename(f) + ' => ' + File.basename(f,'.less') + '.css') end puts('Total files compiled: ' +count.to_s) end
desc 'Compile less files (windows OS) and run rake' task :lessCompileRake => [:lessCompile, :css, :pack]