jfs-generators
==============

My collection of Ruby on Rails generators.


Install
-------

If you have never grabbed a gem from github or you aren't sure if you have, run
the following command: (you should only have to do this once):

    gem sources -a http://gems.github.com

Once you have setup GitHub as a gem source, run this command to install the gem:

    sudo gem install jfs-generators
    
    
Usage
-----

Once you install the gem, the generators should be available to all Ruby on
Rails applications on your system. Run `script/generate` without any arguments
to see a list of the available generators in your environment.

To run the generator, go to your rails project directory and call it using the
`script/generate` or `script/destroy` command. For example:

    script/generate jfs_model Article title:string content:text


jfs\_960
--------

Injects the project with the CSS files for the 960 Grid System (v1.1).
    
Example:

    ./script/generate jfs_960
    
Injects the project with `public/stylesheets/reset.css`,
`public/stylesheets/text.css` and `public/stylesheets/960.css`.


jfs\_config
-----------

Creates YAML file in your config directory and an initializer to load this
config. The config has a separate section for each environment.

The config is loaded into a constant called `APP_CONFIG` by default, this changes
depending on the name you choose to pass the generator. Use this constant to
access the config settings like this.
  
    APP_CONFIG[:some_setting]
  
Examples:

    script/generate jfs_config
    
Creates a YAML file at `config/app_config.yml` and an initializer at
`config/initializers/load_app_config.rb`.


    script/generate jfs_config passwords

Creates a YAML file at `config/passwords_config.yml` and an initializer at
`config/initializers/load_passwords_config.rb`.


jfs\_jquery
-----------

Injects the project with the javascript files for jQuery (v.1.3.2) and
jQuery UI (v.1.7.1).
    
Example:

    ./script/generate jfs_jquery
    
Injects the project with `public/javascripts/jqery.min.js.css` and
`public/javascripts/jquery-ui.min.js`.


jfs\_layout
-----------

Creates a basic layout using including a stylesheet and layout helper.

The generator optionally takes a single arugument. This is the name of the
layout and stylesheet files. If no argument is passed then it defaults to
"application".

The layout is i18n ready and the english translation is creates as
config/en.layout.yml.

The helper module includes a `title` method to allow views to set the title
in the document head.

Examples:
    
    script/generate jfs_layout
    
Creates a layout file at `app/views/layouts/application.html.erb`, a helper at
`app/helpers/layout_helper.rb`, a translation file at
`config/locales/en.layout.yml` and a stylesheet at
`public/stylesheets/application.css`.
    
    script/generate jfs_layout admin

Creates a layout file at `app/views/layouts/admin.html.erb`, a helper at
`app/helpers/layout_helper.rb`, a translation file at
`config/locales/en.layout.yml` and a stylesheet at
`public/stylesheets/admin.css`.
    

jfs\_model
----------

Stubs out a new model, including `attr_accessible` statement for attributes.
Pass the model name, either CamelCased or under\_scored, and an optional list of
attribute pairs as arguments.

Attribute pairs are column_name:sql\_type arguments specifying the model's
attributes. Timestamps are added by default, so you don't have to specify them
by hand as `created_at:datetime updated_at:datetime`.

This generates a model class in `app/models` and a migration in `db/migrate`.

Examples:

    ./script/generate jfs_model Account

Creates an Account model at `app/models/account.rb` and a migration at
`db/migrate/XXX_create_accounts.rb`.

    ./script/generate model Article title:string content:text

Creates an Article model with a string title and text body.


jfs\_scaffold
-------------

Scaffolds an entire resource, from model and migration to translation ready
controller and views. The resource is ready to use as a starting point for your
RESTful, resource-oriented application.

Pass the model name, either CamelCased or under\_scored, as the first argument,
and an optional list of attribute pairs.

Attribute pairs are column_name:sql\_type arguments specifying the model's
attributes. Timestamps are added by default, so you don't have to specify them
by hand as 'created_at:datetime updated_at:datetime'.

For example, `jfs_scaffold article title:string content:text` gives you a model
with those two attributes, a controller that handles the
create/show/update/destroy, forms to create and edit your posts, and an index
that lists them all, as well as a `map.resources :articles` declaration in
`config/routes.rb`.

Examples:

    ./script/generate scaffold article title:string content:text

Creates a model at `app/models/article.rb`, a migration at
`db/migrate/XXX_create_articles.rb`, a helper at
`app/helpers/articles_helper.rb`, a controller at
`app/controllers/articles_controller.rb`, views at
`app/views/article/index.html.erb`, `app/views/article/new.html.erb`,
`app/views/article/show.html.erb`, `app/views/article/edit.html.erb`
and `app/views/article/_fields.html.erb` and a translation file at
`config/locales/en.article.yml`.


Copyright
---------

Copyright (c) 2009 Jason Stahl. See LICENSE for details.