mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
parent
cdc3338f08
commit
2224ddbf8b
4 changed files with 1 additions and 49 deletions
|
@ -12,6 +12,7 @@ PATH
|
|||
specs:
|
||||
sinatra-contrib (1.4.0)
|
||||
backports (>= 2.0)
|
||||
multi_json
|
||||
rack-protection
|
||||
rack-test
|
||||
sinatra (~> 1.4.0)
|
||||
|
@ -23,7 +24,6 @@ GEM
|
|||
backports (3.3.3)
|
||||
diff-lcs (1.2.2)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.0.3)
|
||||
haml (4.0.1)
|
||||
tilt
|
||||
json (1.7.7)
|
||||
|
@ -54,7 +54,6 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
erubis
|
||||
eventmachine
|
||||
haml
|
||||
json
|
||||
multi_json
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require 'sinatra/base'
|
||||
require 'eventmachine'
|
||||
require 'backports'
|
||||
|
||||
module Sinatra
|
||||
|
@ -25,23 +24,6 @@ module Sinatra
|
|||
# end
|
||||
# end
|
||||
#
|
||||
# == Proper Deferrable
|
||||
#
|
||||
# Handy when using EventMachine.
|
||||
#
|
||||
# list = []
|
||||
#
|
||||
# get '/' do
|
||||
# stream(:keep_open) do |out|
|
||||
# list << out
|
||||
# out.callback { list.delete out }
|
||||
# out.errback do
|
||||
# logger.warn "lost connection"
|
||||
# list.delete out
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# == Better Middleware Handling
|
||||
#
|
||||
# Blocks passed to #map! or #map will actually be applied when streaming
|
||||
|
@ -103,7 +85,6 @@ module Sinatra
|
|||
end
|
||||
|
||||
module Stream
|
||||
include EventMachine::Deferrable
|
||||
|
||||
attr_accessor :app, :lineno, :pos, :transformer, :closed
|
||||
alias tell pos
|
||||
|
@ -169,11 +150,6 @@ module Sinatra
|
|||
nil
|
||||
end
|
||||
|
||||
def close
|
||||
@scheduler.schedule { succeed }
|
||||
nil
|
||||
end
|
||||
|
||||
def close_read
|
||||
raise IOError, "closing non-duplex IO for reading"
|
||||
end
|
||||
|
|
|
@ -121,10 +121,8 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency "tilt", "~> 1.3"
|
||||
s.add_dependency "rack-test"
|
||||
s.add_dependency "rack-protection"
|
||||
s.add_dependency "eventmachine"
|
||||
s.add_dependency "multi_json"
|
||||
|
||||
s.add_development_dependency "eventmachine"
|
||||
s.add_development_dependency "rspec", "~> 2.3"
|
||||
s.add_development_dependency "haml"
|
||||
s.add_development_dependency "erubis"
|
||||
|
|
|
@ -62,27 +62,6 @@ describe Sinatra::Streaming do
|
|||
end
|
||||
end
|
||||
|
||||
context EventMachine::Deferrable do
|
||||
it 'allows attaching more than one callback' do
|
||||
a = b = false
|
||||
stream do |out|
|
||||
out.callback { a = true }
|
||||
out.callback { b = true }
|
||||
end
|
||||
a.should be_true
|
||||
b.should be_true
|
||||
end
|
||||
|
||||
it 'triggers callbacks after streaming' do
|
||||
triggered = false
|
||||
stream do |out|
|
||||
out.callback { triggered = true }
|
||||
triggered.should be_false
|
||||
end
|
||||
triggered.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'app' do
|
||||
it 'is the app instance the stream was created from' do
|
||||
out = stream { }
|
||||
|
|
Loading…
Reference in a new issue