Class: Henry::Task::RakeTask

Inherits:
Henry::Task show all
Defined in:
lib/henry/task/rake_task.rb

Overview

The Henry Task implementation for Rake Tasks

Direct Known Subclasses

CucumberTask, MiniTestTask, RspecTask

Constant Summary collapse

OUT_PATH =

The temporary output file path for the RakeTask execution.

Returns:

  • (String)

    the output file path.

'rake.out'
APPLICATION_NAME =

The Rake Application name.

Returns:

  • (String)

    the rake application name.

'rake'

Instance Attribute Summary

Attributes inherited from Henry::Task

#data, #enabled, #name, #timeout

Instance Method Summary collapse

Methods inherited from Henry::Task

#after_execute, #before_execute, create, #disable!, #disabled?, #enable!, #enabled?, #execution, #execution=, #export_config, #export_params, #initialize, #logger, #report

Constructor Details

This class inherits a constructor from Henry::Task

Instance Method Details

#configure(params, extended_context = {}, options = {}) ⇒ Object

Configures the Task.

Parameters:

  • params (Hash)

    the task params.

  • extended_context (Hash) (defaults to: {})

    task extended context.



51
52
# File 'lib/henry/task/rake_task.rb', line 51

def configure(params, extended_context={}, options={})
end

#executeObject

Executes the Task and returns its results.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/henry/task/rake_task.rb', line 21

def execute
  begin
    begin 
      Rake.application[self.application_name].invoke 
   
      self.execution.code ||= 'OK'
      self.execution.message ||= 'OK'
      self.execution.output = File.open(self.out_path, 'r').read
      self.execution.log = self.logger.log_as_hash
    
    rescue Exception => e
      self.execution.code = 'ERROR'
      self.execution.message = e.message
      self.execution.output = File.open(self.out_path, 'r').read
      self.execution.backtrace = e.backtrace
      self.execution.log = self.logger.log_as_hash
    end
  rescue Errno::ENOENT => e
    self.execution.code = 'ERROR'
    self.execution.message = e.message 
    self.execution.output = 'Output file missing, please check the task logs.'
    self.execution.backtrace = e.backtrace
    self.execution.log = self.logger.log_as_hash
  end
end