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/MethodLength

Since:

  • 0.6.0



21
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
63
64
65
66
# File 'lib/hanami/rake_helper.rb', line 21

def install
  desc "Load the full project"
  task :environment do
    require 'hanami/environment'
    Hanami::Environment.new.require_project_environment
    Components.resolve('all')
  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.
  #
  # If you're not in control and your deployment requires these "standard"
  # Rake tasks, they are here to solve this only specific problem.
  namespace :db do
    task :migrate do
      run_hanami_command("db migrate")
    end
  end

  namespace :assets do
    task :precompile do
      run_hanami_command("assets precompile")
    end
  end
end