Class: Hanami::RakeHelper Private

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/hanami/rake_helper.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Install Rake tasks in projects

Since:

  • 0.6.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install_tasksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0


13
14
15
# File 'lib/hanami/rake_helper.rb', line 13

def self.install_tasks
  new.install
end

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength

Since:

  • 0.6.0


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/hanami/rake_helper.rb', line 22

def install
  desc "Load the full project"
  task environment: :preload do
    Components.resolve('apps')
  end

  # Ruby ecosystem compatibility
  #
  # Most of the SaaS automatic tasks are designed after Ruby on Rails.
  # They expect the following Rake tasks to be present:
  #
  #   * db:migrate
  #   * assets:precompile
  #
  # See https://github.com/heroku/heroku-buildpack-ruby/issues/442
  #
  # ===
  #
  # These Rake tasks aren't listed when someone runs `rake -T`, because we
  # want to encourage developers to use `hanami` commands.
  #
  # In order to migrate the database or precompile assets a developer should
  # use:
  #
  #   * hanami db migrate
  #   * hanami assets precompile
  #
  # This is the preferred way to run Hanami command line tasks.
  # Please use them when you're in control of your deployment environment.
  namespace :db do
    task :migrate do
      system("bundle exec hanami db migrate") || exit($?.exitstatus)
    end
  end

  namespace :assets do
    task :precompile do
      system("bundle exec hanami assets precompile") || exit($?.exitstatus)
    end
  end
end