Class: TTYtest::Tmux::Session
- Inherits:
-
Object
- Object
- TTYtest::Tmux::Session
- Defined in:
- lib/ttytest/tmux/session.rb
Class Method Summary collapse
- .finalize(driver, name) ⇒ Object private
Instance Method Summary collapse
- #capture ⇒ Object
-
#initialize(driver, name) ⇒ Session
constructor
private
A new instance of Session.
- #send_keys(*keys) ⇒ Object
Constructor Details
#initialize(driver, name) ⇒ Session
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Session.
7 8 9 10 11 12 |
# File 'lib/ttytest/tmux/session.rb', line 7 def initialize(driver, name) @driver = driver @name = name ObjectSpace.define_finalizer(self, self.class.finalize(driver, name)) end |
Class Method Details
.finalize(driver, name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/ttytest/tmux/session.rb', line 15 def self.finalize(driver, name) proc { driver.tmux(*%W[kill-session -t #{name}]) } end |
Instance Method Details
#capture ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ttytest/tmux/session.rb', line 19 def capture contents = driver.tmux(*%W[capture-pane -t #{name} -p]) str = driver.tmux(*%W[display-message -t #{name} -p #\{cursor_x},#\{cursor_y},#\{cursor_flag},#\{pane_width},#\{pane_height},#\{pane_dead},#\{pane_dead_status},]) x, y, cursor_flag, width, height, pane_dead, pane_dead_status, _newline = str.split(',') if pane_dead == "1" raise Driver::TmuxError, "Tmux pane has died\nCommand exited with status: #{pane_dead_status}\nEntire screen:\n#{contents}" end TTYtest::Capture.new( contents.chomp("\n"), cursor_x: x.to_i, cursor_y: y.to_i, width: width.to_i, height: height.to_i, cursor_visible: (cursor_flag != '0') ) end |
#send_keys(*keys) ⇒ Object
38 39 40 |
# File 'lib/ttytest/tmux/session.rb', line 38 def send_keys(*keys) driver.tmux(*%W[send-keys -t #{name} -l], *keys) end |