Skip to content
Newer
Older
100644 70 lines (55 sloc) 1.87 KB
73c0bc8 @beastaugh Add build task.
authored
1 require 'pathname'
2
3ee0efe @beastaugh Rake task to minify Tarski's JavaScript.
authored
3 require 'packr'
df864cc @beastaugh Add a task to compress Tarski's CSS files using the YUI Compressor.
authored
4 require 'yui/compressor'
3ee0efe @beastaugh Rake task to minify Tarski's JavaScript.
authored
5
73c0bc8 @beastaugh Add build task.
authored
6 desc "Create a zip file of the lastest release"
7 task :build do
8 src_dir = Pathname.new(File.dirname(__FILE__)).expand_path
9 build_dir = src_dir + "tarski"
10 build_files = [".git", ".gitignore", ".DS_Store", "Rakefile", "tarski"]
11 zip_name = "tarski_#{theme_version(src_dir + "style.dev.css")}.zip"
12
13 # Create build directory
14 FileUtils.rm_rf build_dir if Dir.exist? build_dir
15 FileUtils.mkdir build_dir
16
17 # Copy files
18 (Dir.entries(src_dir) - build_files - [".", ".."]).
19 reject {|path| path =~ /\.zip$/ }.each do |path|
20 FileUtils.cp_r path, build_dir + path
21 end
22
23 # Zip build directory
24 `cd #{src_dir}; zip -rmq #{zip_name} tarski`
25 end
26
df864cc @beastaugh Add a task to compress Tarski's CSS files using the YUI Compressor.
authored
27 desc "Compress JavaScript and CSS files"
28 task :minify => [:"minify:js", :"minify:css"]
29
30 namespace :minify do
31
32 desc "Compress JavaScript files"
33 task :js do
34 Dir.glob("app/js/*.dev.js").each do |file|
35 options = {:shrink_vars => true, :private => true}
36 code = File.read(file)
37 compressed = Packr.pack(code, options)
e180cbe @beastaugh Updated CSS compression task to minify CSS files in /library/css as w…
authored
38 File.open(file.sub(/\.dev.js$/, ".js"), "w") { |f| f.write(compressed) }
df864cc @beastaugh Add a task to compress Tarski's CSS files using the YUI Compressor.
authored
39 end
40 end
41
42 desc "Compress CSS files"
43 task :css do
e180cbe @beastaugh Updated CSS compression task to minify CSS files in /library/css as w…
authored
44 main = "style.dev.css"
f347c1e @beastaugh Revert "Add custom stylesheets to the list of files to be compressed."
authored
45 files = Dir.glob("library/css/*.dev.css") << main
df864cc @beastaugh Add a task to compress Tarski's CSS files using the YUI Compressor.
authored
46 compressor = YUI::CssCompressor.new
47
e180cbe @beastaugh Updated CSS compression task to minify CSS files in /library/css as w…
authored
48 files.each do |file|
49 code = File.read(file)
50 compressed = compressor.compress(code)
51
52 if file == main
53 header = code.match(/\/\*.+?\*\//m)[0]
54 output = header + "\n" + compressed
55 else
56 output = compressed
57 end
58
59 File.open(file.sub(/\.dev\.css/, ".css"), "w") { |f| f.write(output) }
df864cc @beastaugh Add a task to compress Tarski's CSS files using the YUI Compressor.
authored
60 end
3ee0efe @beastaugh Rake task to minify Tarski's JavaScript.
authored
61 end
df864cc @beastaugh Add a task to compress Tarski's CSS files using the YUI Compressor.
authored
62
3ee0efe @beastaugh Rake task to minify Tarski's JavaScript.
authored
63 end
73c0bc8 @beastaugh Add build task.
authored
64
65 def theme_version(stylesheet)
66 lines = File.read(stylesheet).split("\n")
67 prefix = "Version: "
68 lines.select {|line| line =~ /^#{prefix}/ }.first.sub(prefix, "").strip
69 end
Something went wrong with that request. Please try again.