rack-emstream 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/config.ru ADDED
@@ -0,0 +1,28 @@
1
+ $: << File.expand_path('../lib', __FILE__)
2
+ require 'rack-emstream'
3
+
4
+ class Sender
5
+ def initialize
6
+ @times = 100
7
+ @data = "data"
8
+ end
9
+
10
+ def each
11
+ @times.times { |i|
12
+ yield @data
13
+ }
14
+ end
15
+
16
+ def length
17
+ @times * @data.length
18
+ end
19
+ end
20
+
21
+ require 'logger'
22
+
23
+ use Rack::EMStream
24
+ run lambda { |env|
25
+ sender = Sender.new
26
+
27
+ [ 200, { 'Content-Length' => sender.length.to_s }, sender ]
28
+ }
data/lib/rack-emstream.rb CHANGED
@@ -22,6 +22,8 @@ module Rack
22
22
  EM.next_tick {
23
23
  env['async.callback'].call [ result[0], result[1], self ]
24
24
 
25
+ result[2].close if result[2].respond_to?(:close)
26
+
25
27
  result[2].each { |data| EM.next_tick { @callback.call(data) } }
26
28
  EM.next_tick { succeed }
27
29
  }
@@ -1,5 +1,5 @@
1
1
  module Rack
2
- module EMStream
3
- VERSION = "0.1.0"
2
+ class EMStream
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-emstream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -39,6 +39,7 @@ files:
39
39
  - LICENSE
40
40
  - README.md
41
41
  - Rakefile
42
+ - config.ru
42
43
  - lib/rack-emstream.rb
43
44
  - lib/rack-emstream/version.rb
44
45
  - lib/rack/emstream.rb
@@ -68,4 +69,3 @@ signing_key:
68
69
  specification_version: 3
69
70
  summary: Super-simple Rack streaming with Thin
70
71
  test_files: []
71
- has_rdoc: