Sha256: 523e058b78374b1c3ada0f62c7872580c4ffe23315d5038368ade2254c6e35d6

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 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, $mail = ActiveWrapper.setup(
  :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
$mail.deliver(:from => 'me@me.com', :to => 'you@you.com', :subject => 'subject', :body => 'body')
</pre>

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

* <b>config/database.yml</b>
* <b>config/mail.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.

Mailer
------

Your <b>mail.yml</b> should look something like this:

<pre>
development:
  smtp:
    address: smtp.gmail.com
    authentication: :plain
    domain: gmail.com
    password: password
    port: 587
    enable_starttls_auto: true
    user_name: user@gmail.com
</pre>

This file is optional.

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

4 entries across 4 versions & 1 rubygems

Version Path
winton-active_wrapper-0.1.2 README.markdown
winton-active_wrapper-0.1.3 README.markdown
winton-active_wrapper-0.1.4 README.markdown
winton-active_wrapper-0.1.5 README.markdown