Class: Warbler::Task

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
RakeHelper
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.jar_name = "war1"
  # ...
end
Warbler::Task.new("war2", Warbler::Config.new do |config|
  config.jar_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

Methods included from RakeHelper

extended, included

Constructor Details

#initialize(name = nil, 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



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

def initialize(name = nil, config = nil)
  @config = config
  if @config.nil? && File.exists?(Config::FILE)
    @config = eval(File.read(Config::FILE), binding, Config::FILE, 0)
  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
  @name = name || @config.jar_extension
  @jar = Warbler::Jar.new
  yield self if block_given?
  define_tasks
end

Instance Attribute Details

#configObject

Warbler::Config



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

def config
  @config
end

#jarObject Also known as: war

Warbler::Jar



41
42
43
# File 'lib/warbler/task.rb', line 41

def jar
  @jar
end

#nameObject

Task name



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

def name
  @name
end