$watch
有没有办法记录脚本化过程的整个会话?
在此示例中,输出应类似于:
require 'pty'
require 'expect'
reader, writer, _pid = PTY.spawn('irb')
# log = StringIO.new # or maybe something else
# Attach/Tee logger to reader/writer
reader.expect(/.*> /, 1) do |line|
puts "Line = #{line}"
writer.puts '1+1'
end
10.times do
reader.expect(/.*[\r\n]/, 1) { |line| puts "Line = #{line}" }
end
# puts log.string