-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
45 lines (32 loc) · 1018 Bytes
/
Rakefile
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
37
38
39
40
41
42
43
44
45
require 'fileutils'
require 'pathname'
require 'yui/compressor'
require 'closure-compiler'
namespace :js do
desc "Compress jquery.ql_zoom.js with YUI"
task :yui do
compress_yui('src/jquery.ql_zoom.js')
end
desc "Compress jquert.ql_zoom.js with Closure"
task :closure do
compress_closure('src/jquery.ql_zoom.js')
end
def compress_closure(path)
puts "Compressing #{path}"
file_handle = File.open(path)
compressed_output = Closure::Compiler.new.compile(file_handle)
file_handle.close
#overwrite the file
File.open('src/jquery.ql_zoom.min.js', "w+") { |file| file.puts compressed_output }
end
def compress_yui(path)
puts "Compressing #{path}"
file_handle = File.open(path)
compressor = YUI::JavaScriptCompressor.new
compressed_output = compressor.compress(file_handle)
file_handle.close
#overwrite the file
File.open('src/jquery.ql_zoom.min.js', "w+") { |file| file.puts compressed_output }
end
end
task :default => 'js:closure'