Class: Bcome::Interactive::Session
- Inherits:
-
Object
- Object
- Bcome::Interactive::Session
- Defined in:
- lib/objects/interactive/session.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node, item_klass, init_data) ⇒ Session
constructor
A new instance of Session.
- #start ⇒ Object
- #start_item ⇒ Object
Constructor Details
#initialize(node, item_klass, init_data) ⇒ Session
Returns a new instance of Session.
32 33 34 35 36 37 |
# File 'lib/objects/interactive/session.rb', line 32 def initialize(node, item_klass, init_data) @item_klass = item_klass @node = node @responses = {} @init_data = init_data end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
30 31 32 |
# File 'lib/objects/interactive/session.rb', line 30 def node @node end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
30 31 32 |
# File 'lib/objects/interactive/session.rb', line 30 def responses @responses end |
Class Method Details
.run(node, session_type, init_data = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/objects/interactive/session.rb', line 6 def run(node, session_type, init_data = {}) = "\ninteractive session ended\n".informational begin session_klass = session_type.is_a?(Symbol) ? session_type_to_klass[session_type] : session_type session = ::Bcome::Interactive::Session.new(node, session_klass, init_data) session.start rescue ::Bcome::Exception::InteractiveSessionHalt => e puts rescue ::Bcome::Exception::CouldNotInitiateSshConnection => e puts 'Caught connection error #2' puts e..error rescue ::IRB::Abort puts end end |
.session_type_to_klass ⇒ Object
22 23 24 25 26 27 |
# File 'lib/objects/interactive/session.rb', line 22 def session_type_to_klass { interactive_ssh: ::Bcome::Interactive::SessionItem::TransparentSsh, capture_input: ::Bcome::Interactive::SessionItem::CaptureInput } end |
Instance Method Details
#start ⇒ Object
39 40 41 42 |
# File 'lib/objects/interactive/session.rb', line 39 def start print start_item. if start_item. start_item.do end |
#start_item ⇒ Object
44 45 46 |
# File 'lib/objects/interactive/session.rb', line 44 def start_item @start_item ||= @item_klass.new(self, @init_data) end |