Class: Warg::Command::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/warg.rb

Defined Under Namespace

Classes: BlockProxy, Callback, CallbackFailedError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, run_object, hosts, order, &setup) ⇒ Step

Returns a new instance of Step.



1998
1999
2000
2001
2002
2003
2004
# File 'lib/warg.rb', line 1998

def initialize(command, run_object, hosts, order, &setup)
  @command = command
  @run_object = run_object
  @hosts = hosts
  @order = order
  @setup = setup
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



1992
1993
1994
# File 'lib/warg.rb', line 1992

def command
  @command
end

#hostsObject (readonly)

Returns the value of attribute hosts.



1993
1994
1995
# File 'lib/warg.rb', line 1993

def hosts
  @hosts
end

#nextObject

Returns the value of attribute next.



1994
1995
1996
# File 'lib/warg.rb', line 1994

def next
  @next
end

#previousObject

Returns the value of attribute previous.



1995
1996
1997
# File 'lib/warg.rb', line 1995

def previous
  @previous
end

#resultObject (readonly)

Returns the value of attribute result.



1996
1997
1998
# File 'lib/warg.rb', line 1996

def result
  @result
end

Class Method Details

.callback(command, last_step, order, block) ⇒ Object



1984
1985
1986
1987
1988
1989
1990
# File 'lib/warg.rb', line 1984

def self.callback(command, last_step, order, block)
  new \
    command,
    Callback.new(last_step, block),
    last_step.hosts,
    order
end

.local(command, banner, block) ⇒ Object



1980
1981
1982
# File 'lib/warg.rb', line 1980

def self.local(command, banner, block)
  new(command, BlockProxy.new(banner, block), LOCALHOST, :serial)
end

Instance Method Details

#and_then(order: :parallel, &block) ⇒ Object



2010
2011
2012
# File 'lib/warg.rb', line 2010

def and_then(order: :parallel, &block)
  @command.and_then order: order, &block
end


2006
2007
2008
# File 'lib/warg.rb', line 2006

def banner
  @run_object
end

#runObject



2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
# File 'lib/warg.rb', line 2014

def run
  @result = case @run_object
            when String
              @hosts.run_command(@run_object, order: @order, &@setup)
            when Script
              @hosts.run_script(@run_object, order: @order, &@setup)
            when Callback
              @run_object.run(@order)
            when BlockProxy
              # NOTE: A `Proc` means `@hosts` is `LOCALHOST`
              Executor::Result.new.tap do |result|
                result.update LOCALHOST.run(&@run_object)
              end
            end
end