Class: Jisota::ScriptContext
- Inherits:
-
Object
- Object
- Jisota::ScriptContext
- Defined in:
- lib/jisota/script_context.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#packages ⇒ Object
Returns the value of attribute packages.
-
#params ⇒ Object
Returns the value of attribute params.
-
#ssh_session ⇒ Object
Returns the value of attribute ssh_session.
Instance Method Summary collapse
- #command(cmd) ⇒ Object
-
#initialize(options = {}) ⇒ ScriptContext
constructor
A new instance of ScriptContext.
- #param_scope(scope_params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ScriptContext
5 6 7 8 9 10 |
# File 'lib/jisota/script_context.rb', line 5 def initialize( = {}) @ssh_session = .fetch(:ssh_session) { nil } @logger = .fetch(:logger) { NilOutput.new } @params = .fetch(:params) { Hash.new } @packages = .fetch(:packages) { Collection.new } end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/jisota/script_context.rb', line 3 def logger @logger end |
#packages ⇒ Object
Returns the value of attribute packages.
3 4 5 |
# File 'lib/jisota/script_context.rb', line 3 def packages @packages end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/jisota/script_context.rb', line 3 def params @params end |
#ssh_session ⇒ Object
Returns the value of attribute ssh_session.
3 4 5 |
# File 'lib/jisota/script_context.rb', line 3 def ssh_session @ssh_session end |
Instance Method Details
#command(cmd) ⇒ Object
12 13 14 |
# File 'lib/jisota/script_context.rb', line 12 def command(cmd) ssh_session.command(cmd, logger) end |
#param_scope(scope_params) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/jisota/script_context.rb', line 16 def param_scope(scope_params) old_params = params self.params = scope_params result = yield if block_given? self.params = old_params result end |