README.md.template
[github]: https://github.com/neopoly/rohbau
[doc]: http://rubydoc.info/github/neopoly/rohbau/master/file/README.md
[gem]: https://rubygems.org/gems/rohbau
[gem-badge]: https://img.shields.io/gem/v/rohbau.svg
[travis]: https://travis-ci.org/neopoly/rohbau
[travis-badge]: https://img.shields.io/travis/neopoly/rohbau.svg?branch=master
[codeclimate]: https://codeclimate.com/github/neopoly/rohbau
[codeclimate-climate-badge]: https://img.shields.io/codeclimate/github/neopoly/rohbau.svg
[codeclimate-coverage-badge]: https://codeclimate.com/github/neopoly/rohbau/badges/coverage.svg
[inchpages]: https://inch-ci.org/github/neopoly/rohbau
[inchpages-badge]: https://inch-ci.org/github/neopoly/rohbau.svg?branch=master&style=flat
# Rohbau
[![Travis][travis-badge]][travis]
[![Gem Version][gem-badge]][gem]
[![Code Climate][codeclimate-climate-badge]][codeclimate]
[![Test Coverage][codeclimate-coverage-badge]][codeclimate]
[![Inline docs][inchpages-badge]][inchpages]
[Gem][gem] |
[Source][github] |
[Documentation][doc]
## Description
_Rohbau_ provides a set of patterns used in Domain Driven Design.
## Installation
Add this line to your application's Gemfile:
gem 'rohbau'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rohbau
## Usage
### Runtime
By instantiation of the `RuntimeLoader`, an instance of the `Runtime`is created and stored as a singleton.
Internal units of the respective component can access this instance by referring to the `RuntimeLoader`.
By this a place is made where for example memories for in-memory gateway backend implementations can be stored.
#### Examples
Inject a user service to your application
`examples/my_application.rb`
```ruby
include_example 'my_application'
```
`examples/user_service/runtime.rb`
```ruby
include_example 'user_service/runtime'
```
`examples/runtime.rb`
```ruby
include_example 'runtime'
```
### ServiceFactory
The `ServiceFactory` is considered the authority for retrieval of service instances.
It follows partly the service locator / registry pattern.
#### Examples
Register and unregister default service and override with specific service.
`examples/user_service/service_factory.rb`
```ruby
include_example 'service_factory'
```
Validate registered dependencies
`examples/user_service/service_factory_validation.rb`
```ruby
include_example 'service_factory_validation'
```
### Request
It ensures an initialized runtime and builds up a new the service factory instance.
`examples/user_service/request.rb`
```ruby
include_example 'user_service/request'
```
### Entity
Entities are low level, logic-less, data structures.
`examples/user_entity.rb`
```ruby
include_example 'user_entity'
```
### Gateway
Provides an interface to persist entities.
`examples/user_service/user_gateway.rb`
```ruby
include_example 'user_service/user_gateway'
```
### UseCase
`UseCases` define the interface for the end user who interacts with the system.
#### Examples
`examples/user_service/create_user_use_case.rb`
```ruby
include_example 'user_service/create_user_use_case'
```
`examples/use_case.rb`
```ruby
include_example 'use_case'
```
### EventTube
The `EventTube` implements the `Publish-subscribe` pattern. You can subscribe to events and publish them.
#### Examples
`examples/email_service/email_service.rb`
```ruby
include_example 'email_service/email_service'
```
`examples/user_service/event_tube.rb`
```ruby
include_example 'user_service/event_tube'
```
## Build README
Make changes to `README.md.template`, not to `README.md`
Include examples with
```bash
include_example 'example_file_name'
```
Build README.md with
```bash
rake build_readme
```
Always commit `README.md.template` and `README.md` together.
## Examples
Run all examples via
```bash
rake examples
```
To verify all examples run:
```bash
rake examples:verify
```
Note: Examples will be verified during CI run.
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request