RottenSoftware

Random thoughs about software development

HANAMI 1.0.0 has been released!

06.04.2017 is a big date for Hanami framework - version 1.0.0 has been released! Since version 0.9.2 (which we were using) there should not be any breaking changes in the API, so the upgrade of the Shyshka project should go seamlessly.

How to upgrade to version 1.0?

There is not that much we need to do. Hanami maintainers provide description of what should be changed, you can find it here.

So, the first thing we need to do is to update the Gemfile

gem 'hanami',       '~> 1.0'
gem 'hanami-model', '~> 1.0'

Next udpate the gems by running:

bundle update hanami hanami-model

One of the new things in Hanami framework is the config/boot.rb, which should look like this:

require_relative './environment'
Hanami.boot

This file will be used for booting our project from external commands, for instance to use it with Sidekiq.

Another thing that has slightly changed is where we setup the logger for the application. We used to do this in apps/web/application.rb and we have to set this up in config/environment.rb.

Delete then all logger refences from the apps/web/application.rb file and add this code to the config/environment.rb:

  environment :development do
    # See: http://hanamirb.org/guides/projects/logging
    logger level: :info
  end

  environment :production do
    logger level: :info, formatter: :json

    mailer do
      delivery :smtp, address: ENV['SMTP_HOST'], port: ENV['SMTP_PORT']
    end
  end

Note that this should be added after the general settings like mount, model or mailer.

The last step is to add lib/shyshka.rb file that will define our main module. This file should look like this:

module Shyshka
end

Summary

That’s all we need to do to upgrade Hanami application from version 0.9.2 to 1.0. After adding this our tests should still pass and application should work the same as previously.

Written on April 16, 2017
>