Sinatra 1.3 Streaming w/ Ruby stdout redirection
问题 I would like to use Sinatra's Streaming capability introduced in 1.3 coupled with some stdout redirection. It would basically be a live streaming output of a long running job. I looked into this question and the Sinatra streaming sample in the README. Running 1.8.7 on OSX: require 'stringio' require 'sinatra' $stdout.sync = true module Kernel def capture_stdout out = StringIO.new $stdout = out yield out ensure $stdout = STDOUT end end get '/' do stream do |out| out << "Part one of a three