Class: Uttk::Strategies::Strategy::StrategyHooker
- Includes:
- Hooker
- Defined in:
- lib/uttk/strategies/Strategy.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#symtbl ⇒ Object
readonly
Returns the value of attribute symtbl.
Instance Method Summary collapse
- #already_killed(data) ⇒ Object
- #before_exec(cmd, data) ⇒ Object
- #display_command(cmd) ⇒ Object
- #exception_raised_during_exec ⇒ Object
-
#initialize(symtbl, log, env = {}) ⇒ StrategyHooker
constructor
A new instance of StrategyHooker.
Constructor Details
#initialize(symtbl, log, env = {}) ⇒ StrategyHooker
Returns a new instance of StrategyHooker.
477 478 479 |
# File 'lib/uttk/strategies/Strategy.rb', line 477 def initialize symtbl, log, env={} @env, @symtbl, @log = env, symtbl, log end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
475 476 477 |
# File 'lib/uttk/strategies/Strategy.rb', line 475 def env @env end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
475 476 477 |
# File 'lib/uttk/strategies/Strategy.rb', line 475 def log @log end |
#symtbl ⇒ Object (readonly)
Returns the value of attribute symtbl.
475 476 477 |
# File 'lib/uttk/strategies/Strategy.rb', line 475 def symtbl @symtbl end |
Instance Method Details
#already_killed(data) ⇒ Object
499 500 501 |
# File 'lib/uttk/strategies/Strategy.rb', line 499 def already_killed data @log.already_killed = data.pid end |
#before_exec(cmd, data) ⇒ Object
486 487 488 489 490 491 492 |
# File 'lib/uttk/strategies/Strategy.rb', line 486 def before_exec cmd, data env_sub = proc do |k,v| ENV[k.to_s] = v.do_symtbl_gsub(@symtbl).gsub(/\$(\w+)/) { ENV[$1] } end @env.each(&env_sub) @symtbl[:env].each(&env_sub) if @symtbl[:env] end |
#display_command(cmd) ⇒ Object
481 482 483 484 |
# File 'lib/uttk/strategies/Strategy.rb', line 481 def display_command cmd cmd.do_symtbl_gsub! @symtbl @log[:running] = cmd.to_sh end |
#exception_raised_during_exec ⇒ Object
494 495 496 497 |
# File 'lib/uttk/strategies/Strategy.rb', line 494 def exception_raised_during_exec @data.status = 127 fail 'exception raised during exec' end |