Class: Torba::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/torba/rake_task.rb

Overview

Calling Torba::RakeTask.new defines a “torba:pack” Rake task that does the same thing as ‘bundle exec torba pack`. Furthermore, if the :before option is specified, the “torba:pack” task will be installed as a prerequisite to the specified task.

This is useful for deployment because it allows for packing as part of the “assets:precompile” flow, which platforms like Heroku already know to invoke. By hooking into “assets:precompile” as a prerequisite, Torba can participate automatically, with no change to the deployment process.

Typical use is as follows:

# In Rakefile
require "torba/rake_task"
Torba::RakeTask.new("torba:pack", :before => "assets:precompile")

You can also provide a block, which will be executed before packing process:

Torba::RakeTask.new do
  # some preconfiguration to be run when the "torba:pack" task is executed
end

Note that when you require “torba/rails” in a Rails app, this Rake task is installed for you automatically. You only need to install the task yourself if you are using something different, like Sinatra.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = "torba:pack", options = {}, &before_pack) ⇒ RakeTask

Returns a new instance of RakeTask.

Since:

  • 0.1.0



34
35
36
37
38
# File 'lib/torba/rake_task.rb', line 34

def initialize(name="torba:pack", options={}, &before_pack)
  @torba_pack_task_name = name
  define_task(before_pack)
  install_as_prerequisite(options[:before]) if options[:before]
end

Instance Attribute Details

#torba_pack_task_nameObject (readonly)

Since:

  • 0.1.0



32
33
34
# File 'lib/torba/rake_task.rb', line 32

def torba_pack_task_name
  @torba_pack_task_name
end