-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrakefile.rb
36 lines (28 loc) · 1.25 KB
/
rakefile.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'find'
namespace :solitaire do
desc "Concatenates JS files into one called solitaire-all.js"
task :concatenate do
files = ["Game.js", "MainWindow.js", "Deck.js", "Dealer.js", "Card.js", "Pack.js", "Stack.js", "SuitStack.js"]
concatenated_filename = "javascripts/solitaire/solitaire-all.js"
#remove old files, create blank ones again
File.delete(concatenated_filename) and puts "Deleted old file" if File.exists?(concatenated_filename)
FileUtils.touch(concatenated_filename)
file = File.open(concatenated_filename, 'w') do |f|
files.each do |i|
f.puts(IO.read("javascripts/solitaire/#{i}"))
f.puts("\n")
end
end
end
desc "Minifies a JS file using YUI Compressor"
task :minify do
minified_filename = "javascripts/solitaire/solitaire-min.js"
FileUtils.rm(minified_filename) if File.exists?(minified_filename)
system("java -jar ../yui-compressor/build/yuicompressor-2.4.jar javascripts/solitaire/solitaire-all.js -o #{minified_filename}")
end
desc "Prepares site for deployment (concatenates and minifies js code)"
task :deploy do
Rake::Task["solitaire:concatenate"].execute
Rake::Task["solitaire:minify"].execute
end
end