v1.0.0.beta1 release marks Hanami's feature freeze for 1.0, along with a couple new features, and a few bug fixes.
From now on, Hanami API's are stable and won't be changed until 2.0.
The stable release (
v1.0.0) will happen between the end of March and the beginning of April 2017, which coincides with the Hanami season in Japan. 🌸
Between now and then, we'll release other beta and release candidate versions.
Hanami is now compatible with Ruby 2.3+ (including the latest 2.4) and with Rack 2.0 only.
We added the project logger, available at
If you need to log a piece of information, use it like this:
Because of this change, the application-specific loggers were removed (eg.
Therefore, logger settings for individual application are not supported anymore (e.g. inside
To configure the logger, please edit
A project that uses Hanami will automatically log each incoming HTTP request, SQL query and migration.
When a project is used in development mode, the logging format is human readable:
[bookshelf] [INFO] [2017-02-11 15:42:48 +0100] HTTP/1.1 GET 200 127.0.0.1 /books/1 451 0.018576 [bookshelf] [INFO] [2017-02-11 15:42:48 +0100] (0.000381s) SELECT "id", "title", "created_at", "updated_at" FROM "books" WHERE ("book"."id" = '1') ORDER BY "books"."id"
For the production environment, the default format is JSON instead. JSON is parseable and more machine-oriented. It works great with log aggregators or SaaS logging products.
Migrations will print on standard output the operations applied to the database schema.
➜ bundle exec hanami db migrate [hanami] [INFO] Begin applying migration 20170213123250_create_books.rb, direction: up [hanami] [INFO] (0.001756s) CREATE TABLE `books` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255) NOT NULL, `created_at` timestamp NOT NULL, `updated_at` timestamp NOT NULL) [hanami] [INFO] (0.001738s) INSERT INTO `schema_migrations` (`filename`) VALUES ('20170213123250_create_books.rb') [hanami] [INFO] Finished applying migration 20170213123250_create_books.rb, direction: up, took 0.004091 seconds
The model generator now creates a migration file for a given entity.
➜ bundle exec hanami generate model book create lib/bookshelf/entities/book.rb create lib/bookshelf/repositories/book_repository.rb create db/migrations/20170213123250_create_books.rb create spec/bookshelf/entities/book_spec.rb create spec/bookshelf/repositories/book_repository_spec.rb
It generates an entity with the corresponding repository, migration, and testing code.
The migration will already contain the code for the creation of the table, the primary key and the timestamps:
# db/migrations/20170213123250_create_books.rb Hanami::Model.migration do change do create_table :books do primary_key :id column :created_at, DateTime, null: false column :updated_at, DateTime, null: false end end end
New projects will be generated with a new file:
require_relative './environment' Hanami.boot
This is useful to boot a Hanami project outside of the server or the console. A typical use case is Sidekiq. If you want to run background jobs with this queue, you can start the process with:
bundle exec sidekiq -r ./config/boot.rb
We're grateful for each person who contributed to this release. These lovely people are:
- Adrian Madrid
- Alfonso Uceda
- Andy Holland
- Bhanu Prakash
- Gabriel Gizotti
- Jakub Pavlík
- Kai Kuchenbecker
- Ksenia Zalesnaya
- Leonardo Saraiva
- Lucas Hosseini
- Marcello Rocha
- Marion Duprey
- Marion Schleifer
- Matias H. Leidemer
- Mikhail Grachev
- Nick Rowlands
- Nikita Shilnikov
- Oana Sipos
- Ozawa Sakuro
- Pascal Betz
- Philip Arndt
- Piotr Solnica
- Semyon Pupkov
- Thorbjørn Hermansen
- Tiago Farias
- Victor Franco
- Vladimir Dralo
If you're upgrading you project from
v0.9, please have a look at the related upgrade guide article.