Class: Tap::Tasks::Rake

Inherits:
Tap::Task show all
Defined in:
lib/tap/tasks/rake.rb

Overview

:startdoc::manifest run rake tasks

Simply enques the specified rake task(s) for execution. Useful when a rake task needs to be executed within a workflow. For example these are equivalent:

% tap run -- rake test
% rake test

The only exeception is in the use of the –help option. Use –rake-help to access the rake help, and –help to access this help.

Constant Summary

Constants inherited from Tap::Task

Tap::Task::DEFAULT_HELP_TEMPLATE

Instance Attribute Summary

Attributes inherited from Tap::Task

#name

Attributes included from Support::Executable

#_method_name, #app, #batch, #dependencies, #on_complete_block

Attributes included from Support::Configurable

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tap::Task

execute, help, inherited, #initialize, #initialize_batch_obj, #inspect, instance, intern, lazydoc, #log, parse, #process, #to_s

Methods included from Support::Executable

#_execute, #batch_index, #batch_with, #batched?, #check_terminate, #depends_on, #execute, #fork, initialize, #initialize_batch_obj, #inspect, #merge, #on_complete, #reset_dependencies, #resolve_dependencies, #sequence, #switch, #sync_merge, #unbatched_depends_on, #unbatched_enq, #unbatched_on_complete

Methods included from Support::Configurable

included, #initialize_copy, #reconfigure

Constructor Details

This class inherits a constructor from Tap::Task

Class Method Details

.parse!(argv, app = Tap::App.instance) ⇒ Object

Overrides Tap::Support::FrameworkClass#parse! to do

nothing so that all args get passed forward to rake.



23
24
25
26
27
28
29
# File 'lib/tap/tasks/rake.rb', line 23

def parse!(argv, app=Tap::App.instance) # => instance, argv
  if argv.include?('--help')
    puts help
    exit
  end
  [new({}, default_name, app), argv.collect {|arg| arg == '--rake-help' ? '--help' : arg}]
end

Instance Method Details

#enq(*argv) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tap/tasks/rake.rb', line 32

def enq(*argv)
  rake = ::Rake.application
  
  # run as if from command line using argv
  current_argv = ARGV.dup
  begin
    ARGV.clear
    ARGV.concat(argv)
    
    # now follow the same protocol as 
    # in run, handling options
    rake.init
    rake.load_rakefile
  ensure
    ARGV.clear
    ARGV.concat(current_argv)
  end

  rake.enq_top_level(app)

  nil
end