Generates models, unit tests & migrations for Rails from SQL Editor files.
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
templates
test
.gitignore
README.rdoc
USAGE
domain_generator.rb
rakefile

README.rdoc

Rails Domain Generator

Features

  • Generates models, unit tests and migrations based on a given XML file

  • Handles indexes, some validations

  • Handles has_many and belongs_to relationships

Description

Generates models, unit tests and migrations for a domain by parsing an XML file. Designed to be used at the beginning of a new project where you have a piece of your domain defined (maybe derived from a set of mockups), it saves you the trouble of re-defining tables. The XML file is generated using visual database modeling software or ERP software. Right now only SQL Editor is supported.

By default it will generate models, unit tests and migrations for all tables, but you can pass in specific table name(s) to override this.

When generating models, it will also create the method calls to generate the model joins. Currently, only 'has_many' and 'belongs_to' are supported. It will also create presence validators for any fields that are marked as required and uniqueness validators for any fields that are marked as unique. If comments are given for the table, they will be inserted as RDOC comments before the model class definition.

The generated unit tests rely on Shoulda and assume that it has been installed. They will also create tests for any presence or uniqueness validations.

The generated migrations are the same as the standard migration generator, but also support default values and string limits defined for the fields. Indexes are also generated.

Installation

Clone the git repo to a folder where Rails looks for custom generators.

For example:

mkdir ~/.rails/generators

cd ~/.rails/generators

git clone git://github.com/thethirdswitch/domain.git

License

(The MIT License)

Copyright © 2010 Bob Nadler, Jr.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.