thin_async 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/thin/async.rb +19 -0
  3. data/thin_async.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6621dc207fddf2a5be133698ac007650bb408cac
4
- data.tar.gz: 82d1f517ecee486f69249c8d6bdf3efdcbbb91ee
3
+ metadata.gz: 711e55ba4b239b5d7c0015b48bfb04c0fb098fc2
4
+ data.tar.gz: 412a90435208ecd29038fe8f4abee78cba26315c
5
5
  SHA512:
6
- metadata.gz: 6142c8a43ac121ff3d367a6f332226b9e6ae3dd170198b6cb36d7645f6f60bc5f04ac72702e1ff4346398abd684ba7a1da6402c90ef770a28ac8de1fc6290786
7
- data.tar.gz: 4de77c64062848014713de59beae69c23bd36d81be3ff3166b2d8e27c006315b099ca45200c7703b0f7068c9752f046f0e904bcb78636374150abc179ad57e2d
6
+ metadata.gz: 7268a4f5e3ffa41a2ec9114fc18afc12545763150b3e6b5e97c75b008eed343ab86ee844136f06a3bc0a574000e154860d8b9b4ed97aadf0d741422d10b8b764
7
+ data.tar.gz: c1e8d91c78168985351307498ece1229cfa83f489527c6dab4557c75691c4f10bf71cef5dec9e0b98cd0a041d3e330d042c735e4edc01819c0d3909041d52ceb
@@ -49,6 +49,7 @@ module Thin
49
49
 
50
50
  def initialize(env, status=200, headers={})
51
51
  @callback = env['async.callback']
52
+ @close = env['async.close']
52
53
  @body = DeferrableBody.new
53
54
  @status = status
54
55
  @headers = headers
@@ -85,6 +86,24 @@ module Thin
85
86
  @done
86
87
  end
87
88
 
89
+ # Specify a block to be executed when the response is done
90
+ #
91
+ # Calling this method before the response has completed will cause the
92
+ # callback block to be stored on an internal list.
93
+ # If you call this method after the response is done, the block will
94
+ # be executed immediately.
95
+ #
96
+ def callback &block
97
+ @close.callback(&block)
98
+ self
99
+ end
100
+
101
+ # Cancels an outstanding callback to &block if any. Undoes the action of #callback.
102
+ #
103
+ def cancel_callback block
104
+ @close.cancel_callback(block)
105
+ end
106
+
88
107
  # Tell Thin the response is gonna be sent asynchronously.
89
108
  # The status code of -1 is the magic trick here.
90
109
  def finish
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "thin_async"
3
- s.version = "0.2.0"
3
+ s.version = "0.3.0"
4
4
  s.summary = "A nice wrapper to send response body asynchronously with Thin"
5
5
 
6
6
  s.author = "Marc-Andre Cournoyer"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin_async
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-Andre Cournoyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thin