Class: Fudge::Description
- Inherits:
-
Object
- Object
- Fudge::Description
- Includes:
- TaskDSL
- Defined in:
- lib/fudge/description.rb
Overview
A class that represents a FudgeFile definition in Ruby class form.
Instance Attribute Summary collapse
-
#builds ⇒ Object
readonly
Returns the value of attribute builds.
Instance Method Summary collapse
-
#build(name, options = {}) ⇒ Object
Adds a build to the current description.
-
#find_task_group(name) ⇒ Object
Gets a task group of the given name.
-
#initialize(file) ⇒ Description
constructor
Sets builds to an initial empty array.
-
#on_failure(&block) ⇒ Object
Add actions to be invoked upon failure.
-
#on_success(&block) ⇒ Object
Add actions to be invoked upon success.
-
#task_group(name, *args, &block) ⇒ Object
Adds a task group to the current description or includes a task group.
Methods included from TaskDSL
included, #method_missing, #scope, #task
Constructor Details
#initialize(file) ⇒ Description
Sets builds to an initial empty array
10 11 12 13 14 15 |
# File 'lib/fudge/description.rb', line 10 def initialize(file) @path = file.path @builds = {} @task_groups = {} instance_eval(file.read, __FILE__, __LINE__) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Fudge::TaskDSL
Instance Attribute Details
#builds ⇒ Object (readonly)
Returns the value of attribute builds.
7 8 9 |
# File 'lib/fudge/description.rb', line 7 def builds @builds end |
Instance Method Details
#build(name, options = {}) ⇒ Object
Adds a build to the current description
18 19 20 21 |
# File 'lib/fudge/description.rb', line 18 def build(name, ={}) @builds[name] = build = Build.new() with_scope(build) { yield } end |
#find_task_group(name) ⇒ Object
Gets a task group of the given name
33 34 35 36 37 |
# 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) ⇒ Object
Add actions to be invoked upon failure
45 46 47 |
# File 'lib/fudge/description.rb', line 45 def on_failure(&block) apply_hook(:failure, &block) end |
#on_success(&block) ⇒ Object
Add actions to be invoked upon success
40 41 42 |
# File 'lib/fudge/description.rb', line 40 def on_success(&block) apply_hook(:success, &block) end |
#task_group(name, *args, &block) ⇒ Object
Adds a task group to the current description or includes a task group
24 25 26 27 28 29 30 |
# 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 |