branch14.org

INSTALL

      $ script/plugin install git://github.com/branch14/modeldrivenrails.git
      

README

      ModelDriven Rails Plugin
      ========================
      
      ModelDriven is a Ruby On Rails Plugin that generates models (and
      their migrations, unit tests and fixtures) as well as their
      associations' statements (belongs_to, has_many, ...) from UML Class
      Diagrams.
      
      
      Supported Features
      ==================
      
      Supported is the DIA internal format. XMI support is in progress.
      
      UMLwise it's currently pretty basic. Nothing fancy so far.
      
        classes
        properties
        associations:
          1 - n
          n - n (does implicitly generate join tables)
      
      Railswise it also resolves 'has_many :through'-associations, if
      'n-n'-associations are named. An intermediate join model is generated
      automatically if needed.
      
      Multiplicitywise '1', '0..1', 'n', and '*' are recognized.
      
      
      An Example
      ==========
      
      Lets suppose you have an UML Class Diagram that looks similar to the
      following and is stored in a file named 'diagram.dia'.
      
        -----------------  1             n  -------------------
        | Customer      |  ---------------  | Order           |
        |---------------|                   |-----------------|
        | +name: string |                   | +number: string |
        |---------------|                   |-----------------|
        -----------------                   -------------------
      
      By calling the rake task 'model_driven:generate' like this:
      
        $ rake model_driven:generate filename=diagram.dia
      
      the two models Customer and Order (and their migrations, unit tests
      and fixtures) will be generated.
      
        $ cat app/models/order.rb
        class Order < ActiveRecord::Base
          belongs_to :customer
        end
       
        $ cat app/models/customer.rb
        class Customer < ActiveRecord::Base
          has_many :orders
        end
       
        $ cat db/migrate/20090601100956_create_orders.rb
        class CreateCustomers < ActiveRecord::Migration
          def self.up
            create_table :orders do |t|
              t.string :number
              t.integer :customer_id
              t.timestamps
            end
          end
          def self.down
            drop_table :orders
          end
        end
      
      I guess, you got it. Have fun.
      
      
      FOR THE UNPATIENT WHO READ THE BOTTOM FIRST
      ===========================================
      
        $ rake model_driven:generate filename=diagram.dia
      
      --
      Copyright (c) 2008,2009 Phil Hofmann, released under the MIT license
      

Example Data

Links

Browse Code