Sha256: ff6c7b1e1a8a6430e8ec6f192f3680b1ea515c676b442b30ccc655b007ed4c30

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

ActiveWrapper
=============

Wraps ActiveRecord and Logger for use in non-Rails environments.

Setup
-----

<pre>
sudo gem install active_wrapper
</pre>

Usage
-----

<pre>
require 'rubygems'
require 'active_wrapper'

$db, $log = ActiveWrapper.new(
  :base => File.dirname('__FILE__'),
  :env => 'development',
  :log => 'custom',
  :stdout => true
)

$db.establish_connection
$db.generate_migration('my_migration')
$db.migrate('001')
$db.migrate_reset
$log.info('log this')
$log.clear
</pre>

<code>ActiveWrapper</code> looks for the following files within the <code>:base</code> directory:

* <b>config/database.yml</b>
* <b>db/migrate/*.rb</b>

The <code>:env</code> option is <code>"development"</code> by default.

Logger
------

In the previous example, the log is stored in <b>log/custom.log</b>.

If no <code>:log</code> name is specified, the <code>:env</code> option is used for the log name.

You may also set <code>:log</code> to false to disable logging entirely.

Setting <code>:stdout</code> to true causes stdout and stderr to redirect to the logger. It is false by default.

Rakefile
--------

Add this to your project's <b>Rakefile</b> for database migration and log tasks:

<pre>
require 'rubygems'
require 'rake'
require 'active_wrapper/tasks'

ActiveWrapper::Tasks.new(:log => 'custom') do
  # Put stuff you would normally put in the environment task here
end
</pre>

Pass the same options to <code>ActiveWrapper::Tasks.new</code> as you would <code>ActiveWrapper.new</code>.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
winton-active_wrapper-0.1.0 README.markdown