Class: Henry::Task

Inherits:
Object
  • Object
show all
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

RakeTask

Defined Under Namespace

Classes: CucumberTask, MiniTestTask, RakeTask, RspecTask

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, data) ⇒ Task

Initialize the Task with the given name and data.



20
21
22
23
24
25
# File 'lib/henry/task.rb', line 20

def initialize(name, data)
  self.name = name
  self.data = OpenStruct.new(data)
  self.enabled = true
  self.execution.task_name = self.name
end

Instance Attribute Details

#dataObject

Accessors for name, data and enabled



9
10
11
# File 'lib/henry/task.rb', line 9

def data
  @data
end

#enabledObject

Accessors for name, data and enabled



9
10
11
# File 'lib/henry/task.rb', line 9

def enabled
  @enabled
end

#nameObject

Accessors for name, data and enabled



9
10
11
# File 'lib/henry/task.rb', line 9

def name
  @name
end

Class Method Details

.create(name, data) ⇒ Task

Note:

Factory to create X Task instances.

Returns an instance of the target Task class.

Returns:



15
16
17
# File 'lib/henry/task.rb', line 15

def self.create(name, data)
  return Kernel.eval(data['class_name']).new(name, data)
end

Instance Method Details

#after_executeObject

Code to be run justafter the execution



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

def after_execute
  LoggerService.stop
end

#before_executeObject

Code to be run just before the execution



28
29
30
# File 'lib/henry/task.rb', line 28

def before_execute
  LoggerService.start(self.logger)
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.



96
97
# File 'lib/henry/task.rb', line 96

def configure(params, extended_context={})
end

#disable!Object

Makes the Task disabled



85
86
87
# File 'lib/henry/task.rb', line 85

def disable!
  self.enabled = false
end

#disabled?True, False

Returns true whenever the Task is disabled.

Returns:

  • (True, False)


75
76
77
# File 'lib/henry/task.rb', line 75

def disabled?
  !self.enabled?
end

#enable!Object

Makes the Task enabled



80
81
82
# File 'lib/henry/task.rb', line 80

def enable!
  self.enabled = true
end

#enabled?True, False

Returns true whenever the Task is enabled.

Returns:

  • (True, False)


68
69
70
# File 'lib/henry/task.rb', line 68

def enabled?
  self.enabled
end

#executeObject

The execution code should be defined under this method on the specific Task class.



90
91
92
# File 'lib/henry/task.rb', line 90

def execute
  abort "Your task class ('#{self.class}' may be?) MUST define this method with its execution logic."
end

#executionExecution

Returns the Task Execution.

Returns:



54
55
56
# File 'lib/henry/task.rb', line 54

def execution
  @execution ||= Execution.new
end

#export_params(params) ⇒ Object

Exports the Task params to the ENV.

Parameters:

  • params (Hash)

    the Task params to be exported.



47
48
49
# File 'lib/henry/task.rb', line 47

def export_params(params)
  Input.export!(params)
end

#loggerLogger

Returns the Task Logger.

Returns:



61
62
63
# File 'lib/henry/task.rb', line 61

def logger
  @logger ||= Logger.new
end

#reportHash

Returns the json ready hash report of the task execution.

Returns:

  • (Hash)


40
41
42
# File 'lib/henry/task.rb', line 40

def report
  self.execution.report
end