Class: Shellfie::SessionRunner
- Inherits:
-
Object
- Object
- Shellfie::SessionRunner
- Defined in:
- lib/shellfie/session_runner.rb
Constant Summary collapse
- MAX_OUTPUT_BYTES =
10 * 1_048_576
- REGEXP_TIMEOUT =
0.1- MAX_GOLDEN_BYTES =
1_048_576- KEYS =
{ "enter" => "\r", "tab" => "\t", "esc" => "\e", "escape" => "\e", "up" => "\e[A", "down" => "\e[B", "right" => "\e[C", "left" => "\e[D", "home" => "\e[H", "end" => "\e[F", "pageup" => "\e[5~", "pagedown" => "\e[6~", "delete" => "\e[3~", "insert" => "\e[2~", "backspace" => "\x7f", "shift-tab" => "\e[Z" }.freeze
Instance Method Summary collapse
- #execute_session ⇒ Object
-
#initialize(config) ⇒ SessionRunner
constructor
A new instance of SessionRunner.
- #run ⇒ Object
Constructor Details
#initialize(config) ⇒ SessionRunner
Returns a new instance of SessionRunner.
28 29 30 31 32 33 |
# File 'lib/shellfie/session_runner.rb', line 28 def initialize(config) @config = config @visible = true @redactions = config.redactions.map { |pattern| Regexp.new(pattern.to_s) } @utf8_pending = +"".b end |
Instance Method Details
#execute_session ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/shellfie/session_runner.rb', line 44 def execute_session @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) check_requirements! validate_working_directories! @session = Session.new(columns: terminal[:columns], rows: terminal[:rows], title: @config.title) @live_screen = TerminalScreen.new( columns: terminal[:columns], rows: terminal[:rows], graphics_policy: @config.render.dig(:window, :graphics_policy) || "ignore" ) start_pty @config.steps.each do |step| execute(step) check_reader_error! end @session end |
#run ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/shellfie/session_runner.rb', line 35 def run total_timeout = terminal[:total_timeout] && parse_duration(terminal[:total_timeout]) return Timeout.timeout(total_timeout, ExecutionError, "Session exceeded total timeout of #{total_timeout}s") { execute_session } if total_timeout execute_session ensure stop_pty end |