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.

To define multiple Warbler configurations in a single project, use code like the following in a Rakefile:

Warbler::Task.new("war1", Warbler::Config.new do |config|
  config.war_name = "war1"
  # ...
end
Warbler::Task.new("war2", Warbler::Config.new do |config|
  config.war_name = "war2"
  # ...
end

With this setup, you can create two separate war files two different configurations by running rake war1 war2.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:

  • _self (Warbler::Task)

    the object that the method was called on



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/warbler/task.rb', line 41

def initialize(name = :war, config = nil)
  @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 "Warbler::Config not provided by override in initializer or #{Config::FILE}; using defaults"
    @config = Config.new
  end
  @war = Warbler::War.new
  yield self if block_given?
  define_tasks
end

Instance Attribute Details

#configObject

Warbler::Config



36
37
38
# File 'lib/warbler/task.rb', line 36

def config
  @config
end

#nameObject

Task name



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

def name
  @name
end

#warObject

Warbler::War



39
40
41
# File 'lib/warbler/task.rb', line 39

def war
  @war
end