Class: Henry::Task
- Inherits:
-
Object
- Object
- Henry::Task
- Defined in:
- lib/henry/task.rb,
lib/henry/task/rake_task.rb,
lib/henry/task/rspec_task.rb,
lib/henry/task/cucumber_task.rb,
lib/henry/task/minitest_task.rb
Overview
Henry Task
Direct Known Subclasses
Defined Under Namespace
Classes: CucumberTask, MiniTestTask, RakeTask, RspecTask
Instance Attribute Summary collapse
-
#data ⇒ Object
Accessors for name, data and enabled.
-
#enabled ⇒ Object
Accessors for name, data and enabled.
-
#name ⇒ Object
Accessors for name, data and enabled.
-
#timeout ⇒ Object
Accessors for name, data and enabled.
Class Method Summary collapse
-
.create(name, data) ⇒ Henry::Task
Returns an instance of the target Task class.
Instance Method Summary collapse
-
#after_execute ⇒ Object
Code to be run justafter the execution.
-
#before_execute ⇒ Object
Code to be run just before the execution.
-
#configure(params, extended_context = {}) ⇒ Object
Nothing to be done here…
-
#disable! ⇒ Object
Makes the Task disabled.
-
#disabled? ⇒ True, False
Returns true whenever the Task is disabled.
-
#enable! ⇒ Object
Makes the Task enabled.
-
#enabled? ⇒ True, False
Returns true whenever the Task is enabled.
-
#execute ⇒ Object
The execution code should be defined under this method on the specific Task class.
-
#execution ⇒ Execution
Returns the Task Execution.
-
#execution=(value) ⇒ Execution
Sets the Task Execution.
-
#export_config(config) ⇒ Object
Exports the Task config to the ENV.
-
#export_params(params) ⇒ Object
Exports the Task params to the ENV.
-
#initialize(name, data) ⇒ Task
constructor
Initialize the Task with the given name and data.
-
#logger ⇒ Logger
Returns the Task Logger.
-
#report ⇒ Hash
Returns the json ready hash report of the task execution.
Constructor Details
#initialize(name, data) ⇒ Task
Initialize the Task with the given name and data.
22 23 24 25 26 27 28 |
# File 'lib/henry/task.rb', line 22 def initialize(name, data) self.data = OpenStruct.new(data) self.enabled = true self.execution.task_name = name self.name = name self.timeout = self.data.timeout || 18000 #The given timeout (in seconds) or 5 hours end |
Instance Attribute Details
#data ⇒ Object
Accessors for name, data and enabled
9 10 11 |
# File 'lib/henry/task.rb', line 9 def data @data end |
#enabled ⇒ Object
Accessors for name, data and enabled
9 10 11 |
# File 'lib/henry/task.rb', line 9 def enabled @enabled end |
#name ⇒ Object
Accessors for name, data and enabled
9 10 11 |
# File 'lib/henry/task.rb', line 9 def name @name end |
#timeout ⇒ Object
Accessors for name, data and enabled
9 10 11 |
# File 'lib/henry/task.rb', line 9 def timeout @timeout end |
Class Method Details
.create(name, data) ⇒ Henry::Task
Factory to create X Task instances.
Returns an instance of the target Task class.
17 18 19 |
# File 'lib/henry/task.rb', line 17 def self.create(name, data) return Kernel.eval(data['class_name']).new(name, data) end |
Instance Method Details
#after_execute ⇒ Object
Code to be run justafter the execution
39 40 41 42 43 44 |
# File 'lib/henry/task.rb', line 39 def after_execute self.execution.params = @params LoggerService.stop ExecutionService.stop end |
#before_execute ⇒ Object
Code to be run just before the execution
31 32 33 34 35 36 |
# File 'lib/henry/task.rb', line 31 def before_execute self.execution = nil self.execution.task_name = self.name LoggerService.start(self.logger) ExecutionService.start(self.execution) end |
#configure(params, extended_context = {}) ⇒ Object
Nothing to be done here… The Task configuration code should be defined under this method on the specific Task class.
121 122 |
# File 'lib/henry/task.rb', line 121 def configure(params, extended_context={}) end |
#disable! ⇒ Object
Makes the Task disabled
110 111 112 |
# File 'lib/henry/task.rb', line 110 def disable! self.enabled = false end |
#disabled? ⇒ True, False
Returns true whenever the Task is disabled.
100 101 102 |
# File 'lib/henry/task.rb', line 100 def disabled? !self.enabled? end |
#enable! ⇒ Object
Makes the Task enabled
105 106 107 |
# File 'lib/henry/task.rb', line 105 def enable! self.enabled = true end |
#enabled? ⇒ True, False
Returns true whenever the Task is enabled.
93 94 95 |
# File 'lib/henry/task.rb', line 93 def enabled? self.enabled end |
#execute ⇒ Object
The execution code should be defined under this method on the specific Task class.
115 116 117 |
# File 'lib/henry/task.rb', line 115 def execute abort "Your task class ('#{self.class}' may be?) MUST define this method with its execution logic." end |
#execution ⇒ Execution
Returns the Task Execution.
72 73 74 |
# File 'lib/henry/task.rb', line 72 def execution @execution ||= Execution.new end |
#execution=(value) ⇒ Execution
Sets the Task Execution.
79 80 81 |
# File 'lib/henry/task.rb', line 79 def execution=(value) @execution = value end |
#export_config(config) ⇒ Object
Exports the Task config to the ENV.
65 66 67 |
# File 'lib/henry/task.rb', line 65 def export_config(config) Henry::Config.export!(config) end |
#export_params(params) ⇒ Object
Exports the Task params to the ENV.
56 57 58 59 60 |
# File 'lib/henry/task.rb', line 56 def export_params(params) @params = params Input.export!(params) end |
#logger ⇒ Logger
Returns the Task Logger.
86 87 88 |
# File 'lib/henry/task.rb', line 86 def logger @logger ||= Logger.new end |
#report ⇒ Hash
Returns the json ready hash report of the task execution.
49 50 51 |
# File 'lib/henry/task.rb', line 49 def report self.execution.report end |