Class: Leeroy::Task::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers, Helpers::Env, Helpers::Logging, Helpers::State, Leeroy::Task
Defined in:
lib/leeroy/task/base.rb

Direct Known Subclasses

Fixture, Image, Instantiate, Sleep, Stub, Terminate

Constant Summary

Constants included from Helpers::Logging

Helpers::Logging::TRACE_FORMAT, Helpers::Logging::TRACE_LEVELS, Helpers::Logging::TRUNCATE_THRESHOLD

Instance Attribute Summary

Attributes included from Helpers::State

#state

Attributes included from Helpers::Env

#env

Attributes included from Leeroy::Task

#args, #global_options, #options

Instance Method Summary collapse

Methods included from Helpers::State

#dump_state, #load_state, #rotate_task_metadata, #state_from_pipe, #to_s

Methods included from Helpers::Logging

#logger

Methods included from Helpers::Env

#checkEnv

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/leeroy/task/base.rb', line 21

def initialize(params = {})
  begin
    @global_options = params.fetch(:global_options, {})
    @options = params.fetch(:options, {})
    @args = params.fetch(:args, {})

    @env = Leeroy::Env.new({}, params.fetch(:env, ENV))

    @state = Leeroy::State.new(state_from_pipe(params.fetch(:state, {})))
    

  rescue StandardError => e
    raise e
  end
end

Instance Method Details

#perform(args = self.args, options = self.options, global_options = self.global_options) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/leeroy/task/base.rb', line 37

def perform(args = self.args, options = self.options, global_options = self.global_options)
  begin
    logger.info("performing #{self.class.to_s}")
    logger.debug("args: #{args.inspect}")
    logger.debug("options: #{options.inspect}")
    logger.debug("global_options: #{global_options.inspect}")

  rescue StandardError => e
    raise e
  end
end