Domain Engine
This gem provides a rails generator for scaffolding new domain engines in a Rails project.
Installation
Add it to your Gemfile under the development dependencies:
group :development do
gem "domain_engine"
end
Usage
You can invoke it like any other generator. It requires an argument for the name of your domain.
The name can be provided as a class name (MyDomain
) or a file name (my_domain
)
rails g domain_engine:new MyDomain
The following folders are created under a domains
folder in the root of the Rails app (domains
is also created if it does not exist):
domains/my_domain/
├── app
│ ├── blueprints
│ │ └── my_domain
│ ├── commands
│ │ └── my_domain
│ ├── controllers
│ │ └── my_domain
│ │ ├── application_controller.rb
│ │ └── hellos_controller.rb
│ ├── domain
│ │ └── my_domain
│ ├── infrastructure
│ │ └── my_domain
│ ├── jobs
│ │ └── my_domain
│ ├── models
│ │ └── my_domain
│ └── queries
│ └── my_domain
├── config
│ └── routes.rb
├── doc
├── lib
│ ├── engine.rb
│ └── tasks
├── package.yml
└── spec
├── commands
│ └── my_domain
├── controllers
│ └── my_domain
│ └── hellos_controller_spec.rb
├── domain
│ └── my_domain
├── factories
├── fixtures
├── infrastructure
│ └── my_domain
├── jobs
│ └── my_domain
├── models
│ └── my_domain
├── package_helper.rb
├── queries
│ └── my_domain
├── requests
│ └── my_domain
└── support
└── controller_extension.rb
Verify
Once completed you can verify that your domain works by running rspec domains/my_domain
and see the example spec pass.