Hello Hanami community! Weβre thrilled to announce the release of Hanami 2.0.0.beta1!
App-centric revolution
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 codeapp/actions/
holds your actions andapp/action.rb
, withBookshelf::Action
as their superclassconfig/app.rb
defines your application (Bookshelf::App
) and its configurationconfig/settings.rb
defines your appβs settings, such as the database URLconfig/routes.rb
defines your appβs HTTP routeslib/
is the home for any general purpose code used by your application codelib/bookshelf/types.rb
defines your custom Ruby data types (using the dry-types gem)lib/tasks/
is there for any custom Rake tasksspec/
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.
CLI
This first beta comes with new CLI commands:
hanami new
to generate a new applicationhanami server
to start the HTTP server (Puma)hanami routes
to print application routes
Remember, hanami --help
, is also your friend π.
Hanami 2.0 & 2.1
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.
Hanami 2.0
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.
That's it!
This way you can learn Hanami 2 by building apps (hint: this would be great for API apps, the router is really fast).
Hanami 2.1
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).
Whatβs included?
Today weβre releasing the following gems:
hanami
v2.0.0.beta1hanami-rspec
v3.11.0.beta1 (it follows RSpecβs versioning)hanami-cli
v2.0.0.beta1hanami-controller
v2.0.0.beta1hanami-router
v2.0.0.beta1hanami-validations
v2.0.0.beta1hanami-utils
v2.0.0.beta1
For specific changes from the last alpha release, please see each gemβs own CHANGELOG.
How can I try it?
β‘ gem install hanami --pre
β‘ hanami new bookshelf
β‘ cd bookshelf
β‘ bundle exec hanami --help
Contributors
Thank you to these fine people for contributing to this release!
Thank you
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. πΈ