class Fudge::Description
A class that represents a FudgeFile definition in Ruby class form.
Attributes
builds[R]
Public Class Methods
new(file)
click to toggle source
Sets builds to an initial empty array
# File lib/fudge/description.rb, line 10 def initialize(file) @path = file.path @builds = {} @task_groups = {} instance_eval(file.read, __FILE__, __LINE__) end
Public Instance Methods
build(name, options={}) { || ... }
click to toggle source
Adds a build to the current description
# File lib/fudge/description.rb, line 18 def build(name, options={}) @builds[name] = build = Build.new(options) with_scope(build) { yield } end
find_task_group(name)
click to toggle source
Gets a task group of the given name
# File lib/fudge/description.rb, line 33 def find_task_group(name) @task_groups[name].tap do |block| raise Exceptions::TaskGroupNotFound.new(name) unless block end end
on_failure(&block)
click to toggle source
Add actions to be invoked upon failure
# File lib/fudge/description.rb, line 45 def on_failure(&block) apply_hook(:failure, &block) end
on_success(&block)
click to toggle source
Add actions to be invoked upon success
# File lib/fudge/description.rb, line 40 def on_success(&block) apply_hook(:success, &block) end
task_group(name, *args, &block)
click to toggle source
Adds a task group to the current description or includes a task group
# File lib/fudge/description.rb, line 24 def task_group(name, *args, &block) if block @task_groups[name] = block else find_task_group(name).call(*args) end end
Private Instance Methods
apply_hook(event) { || ... }
click to toggle source
# File lib/fudge/description.rb, line 51 def apply_hook(event) task = Fudge::Tasks::CompositeTask.new hooks = current_scope.public_send("#{event}_hooks") hooks << task with_scope(task) { yield } end