Skip to content

Latest commit

 

History

History
85 lines (81 loc) · 2.45 KB

README.md

File metadata and controls

85 lines (81 loc) · 2.45 KB

Rails generator for Domain-driven design application

Demo

Supporting Rails 3.2.0 or above

How to use

  1. Install:
$ gem install domain-generator
  1. Gemfile:
gem 'domain-generator', '~> 0.1.0'
  1. Build the gem yourself:
$ gem build domain-generator.gemspec
  1. Try it out:
$ rails generate domain [DOMAIN_NAME] [options]

Options

  1. --include-dry | --no-include-dry
  2. --repo | --no-repo
    • Generate repository class for the model
  3. --app-service
    • Generate the application service class
  4. --service
    • Generate the service class
  5. --model
    • Generate the Entity / Model class

To generate everything

All

To generate model without repository

No Repo

You can also just generate a particular class and spec

App Service

It won't generate anything if only domain name is provided

Nothing

Of course all of them can be deleted easily

Delete

Folder structure:

App:

app/domain
└── pet_management
    ├── app_services
    │   └── register_dog.rb
    ├── infrastructures
    │   └── repos
    │       └── dog.rb
    └── services
        ├── models
        │   └── dog.rb
        └── validate_dog.rb

RSpec:

spec/domain
└── pet_management
    ├── app_services
    │   └── register_dog_spec.rb
    ├── infrastructures
    │   └── repos
    │       └── dog_spec.rb
    └── services
        ├── models
        │   └── dog_spec.rb
        └── validate_dog_spec.rb

A model factory to give you a starting point with FactoryBot

test/factories
└── Dog.rb

TODO:

  1. Generate class and spec seperately.
  2. Validate arguements must be in CamelCase.
  3. Generate repository class without dry stuff.
  4. Depends on what's on the issue list I guess.