Class: Warbler::Task

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

Overview

Warbler Rake task. Allows defining multiple configurations inside the same Rakefile by using different task names.

Constant Summary collapse

COPY_PROC =
proc {|t| cp t.prerequisites.last, t.name }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :war, config = nil, tasks = :define_tasks) {|_self| ... } ⇒ Task

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:

  • _self (Warbler::Task)

    the object that the method was called on



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/warbler/task.rb', line 36

def initialize(name = :war, config = nil, tasks = :define_tasks)
  @name   = name
  @config = config
  if @config.nil? && File.exists?(Config::FILE)
    @config = eval(File.open(Config::FILE) {|f| f.read})
  end
  @config ||= Config.new
  unless @config.kind_of? Config
    warn "War::Config not provided by override in initializer or #{Config::FILE}; using defaults"
    @config = Config.new
  end
  yield self if block_given?
  send tasks
end

Instance Attribute Details

#configObject

Warbler::Config



30
31
32
# File 'lib/warbler/task.rb', line 30

def config
  @config
end

#nameObject

Task name



27
28
29
# File 'lib/warbler/task.rb', line 27

def name
  @name
end

#verboseObject

Whether to print a line when a file or directory task is declared; helps to see what is getting included



34
35
36
# File 'lib/warbler/task.rb', line 34

def verbose
  @verbose
end