SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.

Build script in Ruby using Rio

Posted on May 14th, 2007 by Alex Gorbatchev. In Ruby. No comments yet...

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.

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet, be the first one!

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> , rel="nofollow" in use - no link dropping, no keywords or domains as names; do not spam, and do not advertise!

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr