yasarg (Yet Another Standalone Active Record Gem)

The goal of this gem is to facilitates the use of Active Record on non Rails projects. The tasks in the db namespace that we use when developing Rails applications are a nice part of our lifes, so this gem tries to glue this in your application too.

Ah! almost forgot, the generators (migration and model) are available to you too.

...............................................
Hi, thank you for use yasarg
   This gem is built on top of giant's shoulder
   Thank you Rails team, you're awswome!
...............................................

Use rubygems to install yasarg:

gem install yasarg

Create a configuration file in your application: config/database.yml, like you would do within a Rails app:

# database.yml - an example
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

If you want the rake db tasks in your project, you can make a Rakefile with the following code (besides your own tasks, of course).

# Rakefile
require 'yasarg'
Yasarg::Tasks.load\_tasks

Now you can execute the rake db:create, for example.

To use a generator you can use the yasarg executable:

$ yasarg g model Contact name nascimento:date

The conventions are the same used on Rails applications. The previous command will generate: app/models/contact.rb and db/migrate/[timestamp]\_create\_table\_contats.rb

You can run rake db:migrate now and you are ready to go.