Class RailsInstaller
In: lib/rails-installer/commands.rb
lib/rails-installer/databases.rb
lib/rails-installer/web-servers.rb
lib/rails-installer.rb
Parent: Object

An installer for Rails applications.

The Rails Application Installer is designed to make it easy for end-users to install open-source Rails apps with a minimum amount of effort. When built properly, all the user needs to do is run:

   $ gem install my_app
   $ my_app install /some/path

To use this installer, you’ll need to create a small driver program (the ‘my_app’ program from above). Here’s a minimal example:

   #!/usr/bin/env ruby

   require 'rubygems'
   require 'rails-installer'

   class AppInstaller < RailsInstaller
     application_name 'my_shiny_metal_app'
     support_location 'our shiny website'
     rails_version '1.1.4'
   end

   # Installer program
   directory = ARGV[1]

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

Place this in your application’s gem/ directory, and then add it to your .gem using the ‘executables’ gemspec option. See the examples/ directory for more complex examples.

Methods

Included Modules

FileUtils

Classes and Modules

Class RailsInstaller::Command
Class RailsInstaller::Database
Class RailsInstaller::InstallFailed
Class RailsInstaller::WebServer

Attributes

config  [RW] 
install_directory  [RW] 
message_proc  [RW] 
source_directory  [RW] 

Public Class methods

The application name. Set this in your derived class.

Which Rails version this app needs. This version of Rails will be frozen into vendor/rails/

The support location. This is displayed to the user at the end of the install process.

Public Instance methods

The application name, as set by application_name.

The path to the config file that comes with the GEM

Backup the database

The path to the installed config file

Copy files from the source directory to the target directory.

Copy a specific gem’s contents.

Copy one file from source_directory to install_directory, creating directories as needed.

Create all default config files

Create the default database.yml

Create required directories, like tmp

Create the initial SQLite database

Execute a command-line command

Expand configuration template files.

Locate the source directory for a specific Version

Clean up file and directory permissions.

Freeze to a specific version of Rails gems.

Get the current schema version

Compute the different between two hashes. Returns four hashes, one contains the keys that are in ‘b’ but not in ‘a’ (added entries), the next contains keys that are in ‘a’ and ‘b’, but have different values (changed). The third contains keys that are in ‘b’ but not ‘a’ (added). The final hash contains items that are the same in each.

Install Application

Another install hook; install_post_hook runs after the final migration.

The easy way to add steps to the installation process. install_pre_hook runs right after the DB is backed up and right before the first migration attempt.

The default install sequence. Override this if you need to add extra steps to the installer.

Display a status message

Migrate the database

Pre-migrate the database. This checks to see if we’re downgrading to an earlier version of our app, and runs ‘rake migrate VERSION=…’ to downgrade the database.

Load a yaml file

Restore the database

Run Rails tests. This helps verify that we have a clean install with all dependencies. This cuts down on a lot of bug reports.

Save config settings

Pick a default port number

Find all files in a directory tree and return a Hash containing sha1 hashes of all files.

Start application in the background

Stop application

Call system, ignoring all output.

[Validate]