Hanami v1.0.0.beta1 released
- Transfer

About Hanami already wrote on Habré , and the team has something to please us with:
Feature freezing, project-level logger, automatic logging of HTTP requests, SQL queries and migrations. Minor bug fixes.
The release v1.0.0.beta1freezes the development of new Hanami functionality for 1.0, but at the same time adds a couple of new features and a few fixes.
From now on, Hanami API's will remain stable up to version 2.0 .
A stable release ( v1.0.0) is expected between the end of March and the beginning of April 2017, which coincides with the tradition of admiring the blooming Sakura (Hanami) in Japan .
During this time, the Hanami team will release other beta and release candidate versions.
Opportunities
Hanami is now compatible with Ruby 2.3+ (including the latest 2.4) and Rack only 2.0.
Project Logger
We have added a project level logger available as Hanami.logger. If you need to bring something to the log, do something like this: Hanami.logger.debug "hello".
For this reason, application level loggers had to be removed (eg. Web.logger, Admin.logger).
Therefore, the settings of the loggers for individual applications are no longer supported (i.e. internally apps/web/application.rb). To configure the logger, edit config/environment.rb.
Auto Logging
A project built on Hanami can automatically log incoming HTTP requests, SQL queries, and migrations.
When a project is launched in development mode, the log format looks more 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 production, by contrast, JSON has become the default format. JSON is easier to parse and it is more machine oriented. This works well with SaaS log aggregators.
{"app":"bookshelf","severity":"INFO","time":"2017-02-10T22:31:51Z","http":"HTTP/1.1","verb":"GET","status":"200","ip":"127.0.0.1","path":"/books/1","query":"","length":"451","elapsed":0.000391478}Migrations will write to the standard output stream operations performed with 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 secondsImproved Model Generator
The model generator now creates a migration file for the entity that it generates.
➜ 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.rbThis will generate the entity, as well as the corresponding repository, migration, and test templates.
Migrations immediately contain code for creating the table, primary key, and 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
endconfig/boot.rb
New projects will be created with a new file: config/boot.rb
require_relative './environment'
Hanami.bootThis is useful for running Hanami environment services, especially without access to a server or console. A typical scenario is Sidekiq Sidekiq . If you want to run asynchronous tasks with this message queue, start the process like this:
bundle exec sidekiq -r ./config/boot.rbMinor changes
For a complete list of changes, see CHANGELOG and features list .
Updated gems
hanami-1.0.0.beta1hanami-model-1.0.0.beta1hamami-controller-1.0.0.beta1hanami-assets-1.0.0.beta1hanami-mailer-1.0.0.beta1hanami-helpers-1.0.0.beta1hanami-view-1.0.0.beta1hanami-validations-1.0.0.beta1hanami-router-1.0.0.beta1hanami-utils-1.0.0.beta1
Contributors
We are grateful to everyone who helped release the release. Here is a list of these wonderful people:
- Adrian madrid
- Alfonso uceda
- Andy holland
- Bhanu prakash
- Gabriel gizotti
- Jakub pavlík
- Kai kuchenbecker
- Ksenia zalesnaya
- Leonardo saraiva
- Lucas hosseini
- Marcello rocha
- Marion duper
- Marion schleifer
- Matias H. Leidemer
- Mikhail Grachev
- Nick rowland
- Nikita Shilnikov
- Oana sipos
- Ozawa sakuro
- Pascal betz
- Philip arndt
- Piotr solnica
- Semyon Pupkov
- Thorbjørn hermansen
- Tiago farias
- Victor franco
- Vladimir Dralo
- alexd16
- b264
- yjukaku
How to upgrade from a previous version
If you want to update your project with v0.9, pay attention to the update guide .
From translator
Since the final release is just around the corner, it's time to finally try this framework if you haven't done it yet.
For those who are accustomed to reading in Russian - good news: the translation of official documentation and guides is already underway. Look at the pool requests, join, send yours.