Class: Tango::Runner

Inherits:
Object
  • Object
show all
Includes:
ConfigFiles, Contexts::Helpers, Delegate, Fetch, Helpers::FileManipulationHelpers, MetAndMeet, Shell
Defined in:
lib/tango/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shell

#shell, #shell!

Methods included from MetAndMeet

#meet, #met?

Methods included from Fetch

#fetch

Methods included from Delegate

included

Methods included from Contexts::Helpers

#as_user, #in_context, #in_directory, #with_umask

Methods included from ConfigFiles

#write

Class Method Details

.step(step_name, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tango/runner.rb', line 21

def self.step(step_name, &block)
  define_method(step_name) do |*args|
    description = step_description(step_name, args)

    logger.begin_step(description)
    begin
      result = instance_exec(*args, &block)
    rescue StandardError
      logger.step_not_met(description)
      raise
    else
      logger.step_met(description)
    end

    result
  end
end

Instance Method Details

#loggerObject



47
48
49
# File 'lib/tango/runner.rb', line 47

def logger
  Logger.instance
end

#step_description(step_name, args) ⇒ Object



39
40
41
42
43
# File 'lib/tango/runner.rb', line 39

def step_description(step_name, args)
  description = "#{self.class.name}.#{step_name}"
  description << "(" + args.map {|arg| arg.inspect }.join(", ") + ")" unless args.empty?
  description
end