class TestLauncher::Shell::HistoryRunner

Public Class Methods

new(shell: Shell::Runner.new, history_path: "/tmp/test_launcher__history") click to toggle source

delegates to @shell

# File lib/test_launcher/shell/history_runner.rb, line 9
def initialize(shell: Shell::Runner.new, history_path: "/tmp/test_launcher__history")
  @shell = shell
  @history_path = history_path
end

Public Instance Methods

__getobj__() click to toggle source
# File lib/test_launcher/shell/history_runner.rb, line 36
def __getobj__
  @shell
end
exec(cmd) click to toggle source
# File lib/test_launcher/shell/history_runner.rb, line 14
def exec(cmd)
  record(cmd)
  @shell.exec(cmd)
end
recall() click to toggle source
# File lib/test_launcher/shell/history_runner.rb, line 32
def recall
  @recall ||= File.file?(@history_path) && File.read(@history_path).chomp
end
record(cmd) click to toggle source
# File lib/test_launcher/shell/history_runner.rb, line 28
def record(cmd)
  File.write(@history_path, cmd)
end
reexec() click to toggle source
# File lib/test_launcher/shell/history_runner.rb, line 19
def reexec
  if recall
    @shell.exec(recall)
  else
    warn "Cannot rerun: history file not found or is empty"
    exit
  end
end