Build script in Ruby using Rio
Rio is one of my favorite gems. I find it a pleasure to use. Today I wanted to create a build script for my SyntaxHighlighter.
require 'rio'
packer = 'Packer.exe'
build = rio('dp.SyntaxHighlighter').rmtree.mkpath
scripts = rio(build, 'Scripts').mkpath
styles = rio(build, 'Styles').mkpath
uncompressed = rio(build, 'Uncompressed').mkpath
rio('../Scripts').each do |file|
next if file =~ /\.svn/
puts "Copied %s" % file.filename
file > scripts
next if not file.ext? =~ /\.js/
file > uncompressed
file = rio(scripts, file.filename.to_s)
name = file.to_s
file.rename!("#{file}.tmp")
`"#{packer}" -o "#{name}" -m jsmin "#{file}"`
file.delete
end
rio('../Styles/SyntaxHighlighter.css') > styles
puts `rar.exe a dp.SyntaxHighlighter.rar #{build}`build.rmtree
The script rebuilds the following tree structure:
.
dp.SyntaxHighlighter
Scripts
Styles
Uncompressed
It then makes two copies of JavaScript files into Scripts and Uncompressed, packs one copy using a command line JavaScript packer and finally makes a RAR package out of the whole folder.
At the end, it deletes the temporary build folder and I end up with a single RAR file.
No comments yet, be the first one!
Leave a Reply