Hello Hanami community! We’re thrilled to announce the release of Hanami 2.0.0.beta1!
With this release, we’ve revolutionized the Hanami app structure: the
app/ directory is the primary home for your code, and slices are now optional.
“What's a slice?,” you may ask! Think of slices as distinct modules of your application. A typical case is to use slices to separate your business domains (e.g. billing, accounting, admin). For our earlier 2.0 alpha releases, slices were the only way to build Hanami apps, which presupposed you wanted a full modular monolith composed of multiple domains.
With this change, you can just as easily build small services with Hanami, with minimal ceremony.
Let’s dissect a newly generated application (this one being named “Bookshelf”):
app/is home for your application code
app/actions/holds your actions and
Bookshelf::Actionas their superclass
config/app.rbdefines your application (
Bookshelf::App) and its configuration
config/settings.rbdefines your app’s settings, such as the database URL
config/routes.rbdefines your app’s HTTP routes
lib/is the home for any general purpose code used by your application code
lib/bookshelf/types.rbdefines your custom Ruby data types (using the dry-types gem)
lib/tasks/is there for any custom Rake tasks
spec/holds your tests (using RSpec)
spec/requests/holds your HTTP integration tests (using the rack-test gem)
⚡ tree . . ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app │ ├── action.rb │ └── actions ├── config │ ├── app.rb │ ├── routes.rb │ └── settings.rb ├── config.ru ├── lib │ ├── bookshelf │ │ └── types.rb │ └── tasks └── spec ├── requests │ └── root_spec.rb ├── spec_helper.rb └── support ├── requests.rb └── rspec.rb 9 directories, 14 files
Simple. In the spirit of Hanami.
This first beta comes with new CLI commands:
hanami newto generate a new application
hanami serverto start the HTTP server (Puma)
hanami routesto print application routes
hanami --help, is also your friend 😉.
Some of you may have noticed in the previous section we didn't mention views. Where have the views gone?
We want to release Hanami 2 stable as soon as possible, so we decided to split the remaining scope across Hanami 2.0 and 2.1 releases.
The roadmap until 2.0 is straightforward: solidify the app structure as presented above. We plan to add more commands to CLI code generators, support code reloading, and write documentation.
This way you can learn Hanami 2 by building apps (hint: this would be great for API apps, the router is really fast).
For this release, things will look complete from a full stack web framework perspective. Hanami apps will support views, helpers, assets, and persistence (based on rom-rb).
Today we’re releasing the following gems:
hanami-rspecv3.11.0.beta1 (it follows RSpec’s versioning)
For specific changes from the last alpha release, please see each gem’s own CHANGELOG.
⚡ gem install hanami --pre ⚡ hanami new bookshelf ⚡ cd bookshelf ⚡ bundle exec hanami --help
Thank you to these fine people for contributing to this release!
Thank you as always for supporting Hanami!
We can’t wait to hear from you about this release, and we’re looking forward to checking in with you again soon. 🌸