Class: RakeCommandFilter::RakeTask

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

Overview

Provides a custom rake task.

require ‘rake_command_filter’ RakeCommandFilter::RakeTask.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &task_block) ⇒ RakeTask

default rake task initializer



53
54
55
56
57
58
59
60
61
62
# File 'lib/rake_command_filter.rb', line 53

def initialize(*args, &task_block)
  @name = args.shift || :filter_tasks
  @verbose = true
  @commands = []

  desc 'TODO: FILL THIS IN THE BLOCK WHERE YOU CREATE THE TASK'

  instance_eval(&task_block)
  run_task(name, *args)
end

Instance Attribute Details

#fail_on_errorObject

Returns the value of attribute fail_on_error.



46
47
48
# File 'lib/rake_command_filter.rb', line 46

def fail_on_error
  @fail_on_error
end

#formattersObject

Returns the value of attribute formatters.



48
49
50
# File 'lib/rake_command_filter.rb', line 48

def formatters
  @formatters
end

#nameObject

Returns the value of attribute name.



44
45
46
# File 'lib/rake_command_filter.rb', line 44

def name
  @name
end

#optionsObject

Returns the value of attribute options.



50
51
52
# File 'lib/rake_command_filter.rb', line 50

def options
  @options
end

#patternsObject

Returns the value of attribute patterns.



47
48
49
# File 'lib/rake_command_filter.rb', line 47

def patterns
  @patterns
end

#requiresObject

Returns the value of attribute requires.



49
50
51
# File 'lib/rake_command_filter.rb', line 49

def requires
  @requires
end

#verboseObject

Returns the value of attribute verbose.



45
46
47
# File 'lib/rake_command_filter.rb', line 45

def verbose
  @verbose
end

Instance Method Details

#run_definition(defin) { ... } ⇒ Object

call this to run a CommandDefinition subclass

Parameters:

  • defin

    an instance of a command definition subclass

Yields:

  • in the block, you can modify the internal state of the command, using desc, add_filter, etc.



68
69
70
71
72
# File 'lib/rake_command_filter.rb', line 68

def run_definition(defin, &block)
  command = defin
  defin.instance_eval(&block) if block
  add_command(command)
end

#run_main_task(verbose) ⇒ Object

run all the tasks that have been added via #run_definition.



75
76
77
# File 'lib/rake_command_filter.rb', line 75

def run_main_task(verbose)
  run_tasks(verbose)
end