[ANN] GEM-based rails application installer

I just uploaded the first version of my .gem-based Rails application
to Rubyforge (http://rubyforge.org/projects/rails-installer/; gem
rails-app-installer). This is extracted from Typo 4.0, and it’s intended
make it easy to build user-friendly installers for Rails applications.

This isn’t intended to compete with Capistrano; it’s much
lighter-weight, and
aimed towards normal users installing applications, not production
of internally-developed software.

Here’s what users need to do to install an app via this installer:

$ sudo gem install my-app
$ my-app install /some/path

or, without root:

$ gem install -i ~/gems my-app
$ ~/gems/bin/my-app install /some/path

This will build a working Typo install in /some/path, using Mongrel and
SQLite3 by default. These can both be changed via configuration
settings; see
recent articles on http://scottstuff.net for details.

Here’s what you’ll need to do to add the installer to your existing
Rails app:

  1. Create a .gem that depends on rails-app-installer, rails, and
    other .gems that you need to have installed.
  2. Add an executable entry to your gemspec. If your app is called
    my-app, then add executable = ['my-app'].
  3. Copy the ‘rails_app_installer.yml’ file from the rails-app-installer
    into a directory called ‘installer’ in your application.
  4. Finally, create bin/my-app, using one of the examples in the
    rails-app-installer SVN tree as an example.

Here’s a short example bin/my-app:

  #!/usr/bin/env ruby

  require 'rubygems'
  require 'rails-installer'

  class AppInstaller < RailsInstaller
    application_name 'my_app'
    support_location 'my website'
    rails_version '1.1.4'

  # Installer program
  directory = ARGV[1]

  app = AppInstaller.new(directory)
  app.message_proc = Proc.new do |msg|
    STDERR.puts " #{msg}"

That’s all that’s needed–as long as the installer gem is installed,
this will
give you a full installer that supports installs, upgrades, db backups
restores, and all of the other things that the Typo installer currently
provides. Adding application-specific installer subcommands is easy.
the sweep_cache implementation from Typo’s installer:

  class SweepCache < RailsInstaller::Command
    help "Sweep Typo's cache"

    def self.command(installer, *args)

That’s all that’s needed to implement the typo sweep_cache /some/path
installer command. Er, except for adding a ‘sweep_cache’ method to
AppInstaller, but that’s up to you :-).