wee 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/README +0 -1
  2. data/Rakefile +5 -0
  3. data/TODO +6 -0
  4. data/doc/rdoc/classes/Enumerable.html +6 -6
  5. data/doc/rdoc/classes/Wee/AnswerDecoration.html +10 -10
  6. data/doc/rdoc/classes/Wee/Application.html +110 -52
  7. data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +8 -15
  8. data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +8 -19
  9. data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +22 -22
  10. data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +156 -0
  11. data/doc/rdoc/classes/Wee/Brush/FormTag.html +50 -25
  12. data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +12 -12
  13. data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +36 -36
  14. data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +12 -12
  15. data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +16 -16
  16. data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +8 -15
  17. data/doc/rdoc/classes/Wee/Brush/InputTag.html +12 -12
  18. data/doc/rdoc/classes/Wee/Brush/Page.html +14 -14
  19. data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +28 -28
  20. data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +14 -14
  21. data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +7 -7
  22. data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +14 -14
  23. data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +7 -7
  24. data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +36 -36
  25. data/doc/rdoc/classes/Wee/Brush/TableTag.html +6 -6
  26. data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +28 -28
  27. data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +7 -7
  28. data/doc/rdoc/classes/Wee/Brush.html +19 -19
  29. data/doc/rdoc/classes/Wee/CallbackRegistry.html +33 -33
  30. data/doc/rdoc/classes/Wee/CallbackStream.html +18 -18
  31. data/doc/rdoc/classes/Wee/Canvas.html +24 -24
  32. data/doc/rdoc/classes/Wee/Component.html +163 -138
  33. data/doc/rdoc/classes/Wee/Decoration.html +72 -41
  34. data/doc/rdoc/classes/Wee/Delegate.html +31 -31
  35. data/doc/rdoc/classes/Wee/ErrorResponse.html +12 -12
  36. data/doc/rdoc/classes/Wee/GenericResponse.html +6 -6
  37. data/doc/rdoc/classes/Wee/Helper.html +148 -0
  38. data/doc/rdoc/classes/Wee/HtmlCanvas.html +267 -166
  39. data/doc/rdoc/classes/Wee/HtmlWriter.html +40 -40
  40. data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +12 -12
  41. data/doc/rdoc/classes/Wee/PageDecoration.html +199 -0
  42. data/doc/rdoc/classes/Wee/Presenter.html +69 -69
  43. data/doc/rdoc/classes/Wee/RedirectResponse.html +6 -6
  44. data/doc/rdoc/classes/Wee/RefreshResponse.html +6 -6
  45. data/doc/rdoc/classes/Wee/Request.html +18 -18
  46. data/doc/rdoc/classes/Wee/RequestHandler.html +32 -31
  47. data/doc/rdoc/classes/Wee/Response.html +24 -24
  48. data/doc/rdoc/classes/Wee/Session.html +83 -64
  49. data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +18 -18
  50. data/doc/rdoc/classes/Wee/Snapshot.html +19 -19
  51. data/doc/rdoc/classes/Wee/Utils/LRUCache.html +6 -6
  52. data/doc/rdoc/classes/Wee/ValueHolder.html +18 -18
  53. data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +66 -62
  54. data/doc/rdoc/classes/Wee.html +63 -2
  55. data/doc/rdoc/created.rid +1 -1
  56. data/doc/rdoc/files/README.html +6 -9
  57. data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +1 -1
  58. data/doc/rdoc/files/lib/wee/application_rb.html +1 -1
  59. data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +101 -0
  60. data/doc/rdoc/files/lib/wee/components_rb.html +108 -0
  61. data/doc/rdoc/files/lib/wee/core/callback_rb.html +1 -1
  62. data/doc/rdoc/files/lib/wee/core/component_rb.html +1 -1
  63. data/doc/rdoc/files/lib/wee/core/decoration_rb.html +1 -1
  64. data/doc/rdoc/files/lib/wee/core_rb.html +3 -3
  65. data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +1 -1
  66. data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +1 -1
  67. data/doc/rdoc/files/lib/wee/requesthandler_rb.html +1 -1
  68. data/doc/rdoc/files/lib/wee/session_rb.html +2 -1
  69. data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +101 -0
  70. data/doc/rdoc/files/lib/wee/utils/helper_rb.html +108 -0
  71. data/doc/rdoc/files/lib/wee_rb.html +2 -1
  72. data/doc/rdoc/fr_class_index.html +3 -1
  73. data/doc/rdoc/fr_file_index.html +4 -0
  74. data/doc/rdoc/fr_method_index.html +203 -191
  75. data/examples/example.rb +2 -16
  76. data/examples/test.rb +15 -18
  77. data/lib/wee/adaptors/webrick.rb +3 -1
  78. data/lib/wee/application.rb +55 -19
  79. data/lib/wee/components/page_decoration.rb +14 -0
  80. data/lib/wee/components.rb +1 -0
  81. data/lib/wee/core/callback.rb +1 -1
  82. data/lib/wee/core/component.rb +27 -3
  83. data/lib/wee/core/decoration.rb +9 -0
  84. data/lib/wee/renderer/html/brushes.rb +21 -23
  85. data/lib/wee/renderer/html/canvas.rb +25 -4
  86. data/lib/wee/requesthandler.rb +1 -0
  87. data/lib/wee/session.rb +21 -1
  88. data/lib/wee/utils/autoreload.rb +27 -0
  89. data/lib/wee/utils/helper.rb +15 -0
  90. data/lib/wee.rb +2 -1
  91. metadata +203 -191
  92. data/test/components/page_decoration.rb +0 -7
data/README CHANGED
@@ -16,7 +16,6 @@ things.
16
16
  Known Bugs:
17
17
 
18
18
  * Continuations leak memory!
19
- * Sessions get never reclaimed (easy to fix).
20
19
 
21
20
  == Introduction
22
21
 
data/Rakefile CHANGED
@@ -21,6 +21,11 @@ task :package do
21
21
  sh 'gem build wee.gemspec'
22
22
  end
23
23
 
24
+ task :local_install => [:package] do
25
+ sh 'gem uninstall wee || true'
26
+ sh 'gem install wee-*.gem'
27
+ end
28
+
24
29
  task :clean => [:clobber_rdoc]
25
30
 
26
31
  task :default => [:test, :rdoc, :clean]
data/TODO CHANGED
@@ -1,3 +1,9 @@
1
+ * req-handler gc interval
2
+
3
+ * use LiteralMethod object instead of block if callback(:method_name) is given
4
+
5
+ * log requests
6
+
1
7
  * call method #backtrack from backtrack_state. you don't need to call super for #backtrack (at least for direct subclasses of Component).
2
8
  * call method #setup from initialize. same reason as for #backtrack.
3
9
 
@@ -86,7 +86,7 @@ for Ruby 1.8
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000216">min_by</a>&nbsp;&nbsp;
89
+ <a href="#M000228">min_by</a>&nbsp;&nbsp;
90
90
  </div>
91
91
  </div>
92
92
 
@@ -108,19 +108,19 @@ for Ruby 1.8
108
108
  <div id="methods">
109
109
  <h3 class="section-bar">Public Instance methods</h3>
110
110
 
111
- <div id="method-M000216" class="method-detail">
112
- <a name="M000216"></a>
111
+ <div id="method-M000228" class="method-detail">
112
+ <a name="M000228"></a>
113
113
 
114
114
  <div class="method-heading">
115
- <a href="#M000216" class="method-signature">
115
+ <a href="#M000228" class="method-signature">
116
116
  <span class="method-name">min_by</span><span class="method-args">(&amp;block)</span>
117
117
  </a>
118
118
  </div>
119
119
 
120
120
  <div class="method-description">
121
121
  <p><a class="source-toggle" href="#"
122
- onclick="toggleCode('M000216-source');return false;">[Source]</a></p>
123
- <div class="method-source-code" id="M000216-source">
122
+ onclick="toggleCode('M000228-source');return false;">[Source]</a></p>
123
+ <div class="method-source-code" id="M000228-source">
124
124
  <pre>
125
125
  <span class="ruby-comment cmt"># File lib/cache/cache.rb, line 4</span>
126
126
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">min_by</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
@@ -84,9 +84,9 @@
84
84
  <p>
85
85
  A <a href="AnswerDecoration.html">Wee::AnswerDecoration</a> is wrapped
86
86
  around a component that will call <a
87
- href="Component.html#M000179">Component#answer</a>. This makes it possible
87
+ href="Component.html#M000188">Component#answer</a>. This makes it possible
88
88
  to use such components without the need to call them (<a
89
- href="Component.html#M000178">Component#call</a>), e.g. as child components
89
+ href="Component.html#M000187">Component#call</a>), e.g. as child components
90
90
  of other components.
91
91
  </p>
92
92
 
@@ -99,7 +99,7 @@ of other components.
99
99
  <h3 class="section-bar">Methods</h3>
100
100
 
101
101
  <div class="name-list">
102
- <a href="#M000042">process_callbacks</a>&nbsp;&nbsp;
102
+ <a href="#M000044">process_callbacks</a>&nbsp;&nbsp;
103
103
  </div>
104
104
  </div>
105
105
 
@@ -125,7 +125,7 @@ of other components.
125
125
  <td class="context-item-desc">
126
126
  When a component answers, <tt>on_answer.call(args)</tt> will be executed
127
127
  (unless nil), where <tt>args</tt> are the arguments passed to <a
128
- href="Component.html#M000179">Component#answer</a>. Note that no snapshot
128
+ href="Component.html#M000188">Component#answer</a>. Note that no snapshot
129
129
  of on_answer is taken, so you should avoid modifying it!
130
130
 
131
131
  </td>
@@ -140,21 +140,21 @@ of on_answer is taken, so you should avoid modifying it!
140
140
  <div id="methods">
141
141
  <h3 class="section-bar">Public Instance methods</h3>
142
142
 
143
- <div id="method-M000042" class="method-detail">
144
- <a name="M000042"></a>
143
+ <div id="method-M000044" class="method-detail">
144
+ <a name="M000044"></a>
145
145
 
146
146
  <div class="method-heading">
147
- <a href="#M000042" class="method-signature">
147
+ <a href="#M000044" class="method-signature">
148
148
  <span class="method-name">process_callbacks</span><span class="method-args">(callback_stream)</span>
149
149
  </a>
150
150
  </div>
151
151
 
152
152
  <div class="method-description">
153
153
  <p><a class="source-toggle" href="#"
154
- onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
155
- <div class="method-source-code" id="M000042-source">
154
+ onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
155
+ <div class="method-source-code" id="M000044-source">
156
156
  <pre>
157
- <span class="ruby-comment cmt"># File lib/wee/core/decoration.rb, line 122</span>
157
+ <span class="ruby-comment cmt"># File lib/wee/core/decoration.rb, line 131</span>
158
158
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_callbacks</span>(<span class="ruby-identifier">callback_stream</span>)
159
159
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:wee_answer</span>) { <span class="ruby-keyword kw">super</span>; <span class="ruby-keyword kw">nil</span> }
160
160
  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
@@ -98,11 +98,12 @@ the correct handler by examining the request.
98
98
  <h3 class="section-bar">Methods</h3>
99
99
 
100
100
  <div class="name-list">
101
- <a href="#M000138">default_request_handler</a>&nbsp;&nbsp;
102
- <a href="#M000140">handle_request</a>&nbsp;&nbsp;
103
- <a href="#M000139">new</a>&nbsp;&nbsp;
104
- <a href="#M000142">request_handler_expired</a>&nbsp;&nbsp;
105
- <a href="#M000141">unique_request_handler_id</a>&nbsp;&nbsp;
101
+ <a href="#M000146">default_request_handler</a>&nbsp;&nbsp;
102
+ <a href="#M000150">garbage_collect_handlers</a>&nbsp;&nbsp;
103
+ <a href="#M000148">handle_request</a>&nbsp;&nbsp;
104
+ <a href="#M000147">new</a>&nbsp;&nbsp;
105
+ <a href="#M000151">request_handler_expired</a>&nbsp;&nbsp;
106
+ <a href="#M000149">unique_request_handler_id</a>&nbsp;&nbsp;
106
107
  </div>
107
108
  </div>
108
109
 
@@ -148,11 +149,11 @@ The maximum number of request handlers
148
149
  <div id="methods">
149
150
  <h3 class="section-bar">Public Class methods</h3>
150
151
 
151
- <div id="method-M000139" class="method-detail">
152
- <a name="M000139"></a>
152
+ <div id="method-M000147" class="method-detail">
153
+ <a name="M000147"></a>
153
154
 
154
155
  <div class="method-heading">
155
- <a href="#M000139" class="method-signature">
156
+ <a href="#M000147" class="method-signature">
156
157
  <span class="method-name">new</span><span class="method-args">(&amp;block)</span>
157
158
  </a>
158
159
  </div>
@@ -169,8 +170,8 @@ Creates a new application. The block is used to initialize the attributes:
169
170
  }
170
171
  </pre>
171
172
  <p><a class="source-toggle" href="#"
172
- onclick="toggleCode('M000139-source');return false;">[Source]</a></p>
173
- <div class="method-source-code" id="M000139-source">
173
+ onclick="toggleCode('M000147-source');return false;">[Source]</a></p>
174
+ <div class="method-source-code" id="M000147-source">
174
175
  <pre>
175
176
  <span class="ruby-comment cmt"># File lib/wee/application.rb, line 34</span>
176
177
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
@@ -181,6 +182,13 @@ Creates a new application. The block is used to initialize the attributes:
181
182
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;No default request handler specified&quot;</span>
182
183
  <span class="ruby-keyword kw">end</span>
183
184
  <span class="ruby-ivar">@mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
185
+
186
+ <span class="ruby-comment cmt"># start request-handler collecting thread</span>
187
+ <span class="ruby-comment cmt"># run once every minute</span>
188
+ <span class="ruby-ivar">@gc_thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {
189
+ <span class="ruby-identifier">sleep</span> <span class="ruby-value">60</span>
190
+ <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> { <span class="ruby-identifier">garbage_collect_handlers</span> }
191
+ }
184
192
  <span class="ruby-keyword kw">end</span>
185
193
  </pre>
186
194
  </div>
@@ -189,11 +197,11 @@ Creates a new application. The block is used to initialize the attributes:
189
197
 
190
198
  <h3 class="section-bar">Public Instance methods</h3>
191
199
 
192
- <div id="method-M000138" class="method-detail">
193
- <a name="M000138"></a>
200
+ <div id="method-M000146" class="method-detail">
201
+ <a name="M000146"></a>
194
202
 
195
203
  <div class="method-heading">
196
- <a href="#M000138" class="method-signature">
204
+ <a href="#M000146" class="method-signature">
197
205
  <span class="method-name">default_request_handler</span><span class="method-args">(&amp;block)</span>
198
206
  </a>
199
207
  </div>
@@ -204,8 +212,8 @@ Get or set the default request handler. The default request handler is used
204
212
  if no request handler id is given in a request.
205
213
  </p>
206
214
  <p><a class="source-toggle" href="#"
207
- onclick="toggleCode('M000138-source');return false;">[Source]</a></p>
208
- <div class="method-source-code" id="M000138-source">
215
+ onclick="toggleCode('M000146-source');return false;">[Source]</a></p>
216
+ <div class="method-source-code" id="M000146-source">
209
217
  <pre>
210
218
  <span class="ruby-comment cmt"># File lib/wee/application.rb, line 18</span>
211
219
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default_request_handler</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
@@ -220,50 +228,71 @@ if no request handler id is given in a request.
220
228
  </div>
221
229
  </div>
222
230
 
223
- <div id="method-M000140" class="method-detail">
224
- <a name="M000140"></a>
231
+ <div id="method-M000148" class="method-detail">
232
+ <a name="M000148"></a>
225
233
 
226
234
  <div class="method-heading">
227
- <a href="#M000140" class="method-signature">
235
+ <a href="#M000148" class="method-signature">
228
236
  <span class="method-name">handle_request</span><span class="method-args">(context)</span>
229
237
  </a>
230
238
  </div>
231
239
 
232
240
  <div class="method-description">
233
- <p>
234
- TODO: we have to use mutexes here NOTE that id_generator must be
235
- thread-safe! TODO: test for max_request_handlers
236
- </p>
237
241
  <p><a class="source-toggle" href="#"
238
- onclick="toggleCode('M000140-source');return false;">[Source]</a></p>
239
- <div class="method-source-code" id="M000140-source">
242
+ onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
243
+ <div class="method-source-code" id="M000148-source">
240
244
  <pre>
241
- <span class="ruby-comment cmt"># File lib/wee/application.rb, line 48</span>
245
+ <span class="ruby-comment cmt"># File lib/wee/application.rb, line 51</span>
242
246
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
243
- <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
244
- <span class="ruby-identifier">request_handler_id</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">request_handler_id</span>
245
- <span class="ruby-identifier">request_handler</span> = <span class="ruby-ivar">@request_handlers</span>[<span class="ruby-identifier">request_handler_id</span>]
247
+ <span class="ruby-identifier">request_handler_id</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">request_handler_id</span>
248
+ <span class="ruby-identifier">request_handler</span> = <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> { <span class="ruby-ivar">@request_handlers</span>[<span class="ruby-identifier">request_handler_id</span>] }
249
+
250
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request_handler_id</span>.<span class="ruby-identifier">nil?</span>
246
251
 
247
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request_handler_id</span>.<span class="ruby-identifier">nil?</span>
248
- <span class="ruby-comment cmt"># No id was given -&gt; create new id and handler</span>
249
- <span class="ruby-identifier">request_handler_id</span> = <span class="ruby-identifier">unique_request_handler_id</span>()
252
+ <span class="ruby-comment cmt"># No id was given -&gt; check whether the maximum number of request-handlers</span>
253
+ <span class="ruby-comment cmt"># limit is reached. if not, create new id and handler</span>
254
+
255
+ <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> {
256
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@max_request_handlers</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@request_handlers</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-ivar">@max_request_handlers</span>
257
+ <span class="ruby-comment cmt"># limit reached -&gt; remove non-alive handlers...</span>
258
+ <span class="ruby-identifier">garbage_collect_handlers</span>()
259
+
260
+ <span class="ruby-comment cmt"># ...and test again</span>
261
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@request_handlers</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-ivar">@max_request_handlers</span>
262
+ <span class="ruby-comment cmt"># TODO: show a custom error message</span>
263
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;maximum number of request-handlers reached&quot;</span>
264
+ <span class="ruby-keyword kw">end</span>
265
+ <span class="ruby-keyword kw">end</span>
266
+
267
+ <span class="ruby-identifier">request_handler_id</span> = <span class="ruby-identifier">unique_request_handler_id</span>()
250
268
  <span class="ruby-identifier">request_handler</span> = <span class="ruby-ivar">@default_request_handler</span>.<span class="ruby-identifier">call</span>
251
269
  <span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">id</span> = <span class="ruby-identifier">request_handler_id</span>
252
270
  <span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">application</span> = <span class="ruby-keyword kw">self</span>
253
271
  <span class="ruby-ivar">@request_handlers</span>[<span class="ruby-identifier">request_handler_id</span>] = <span class="ruby-identifier">request_handler</span>
272
+ }
273
+
274
+ <span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">RedirectResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">build_url</span>(<span class="ruby-identifier">request_handler_id</span>))
275
+ <span class="ruby-keyword kw">return</span>
254
276
 
255
- <span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">RedirectResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">build_url</span>(<span class="ruby-identifier">request_handler_id</span>))
256
- <span class="ruby-keyword kw">return</span>
277
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">nil?</span>
257
278
 
258
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">nil?</span>
259
- <span class="ruby-comment cmt"># A false request handler id was given. This might indicate that a</span>
260
- <span class="ruby-comment cmt"># request handler has expired. </span>
261
- <span class="ruby-identifier">request_handler_expired</span>(<span class="ruby-identifier">context</span>)
262
- <span class="ruby-keyword kw">return</span>
263
- <span class="ruby-keyword kw">end</span>
279
+ <span class="ruby-comment cmt"># A false request handler id was given. This might indicate that a</span>
280
+ <span class="ruby-comment cmt"># request handler has expired. </span>
281
+
282
+ <span class="ruby-identifier">request_handler_expired</span>(<span class="ruby-identifier">context</span>)
283
+ <span class="ruby-keyword kw">return</span>
284
+
285
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">alive?</span>
286
+
287
+ <span class="ruby-comment cmt"># The request_handler is not alive anymore.</span>
288
+
289
+ <span class="ruby-identifier">request_handler_expired</span>(<span class="ruby-identifier">context</span>)
290
+ <span class="ruby-keyword kw">return</span>
264
291
 
265
- <span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
266
292
  <span class="ruby-keyword kw">end</span>
293
+
294
+ <span class="ruby-identifier">request_handler</span>.<span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
295
+
267
296
  <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">exn</span>
268
297
  <span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">ErrorResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">exn</span>)
269
298
  <span class="ruby-keyword kw">end</span>
@@ -274,21 +303,47 @@ thread-safe! TODO: test for max_request_handlers
274
303
 
275
304
  <h3 class="section-bar">Private Instance methods</h3>
276
305
 
277
- <div id="method-M000142" class="method-detail">
278
- <a name="M000142"></a>
306
+ <div id="method-M000150" class="method-detail">
307
+ <a name="M000150"></a>
279
308
 
280
309
  <div class="method-heading">
281
- <a href="#M000142" class="method-signature">
310
+ <a href="#M000150" class="method-signature">
311
+ <span class="method-name">garbage_collect_handlers</span><span class="method-args">()</span>
312
+ </a>
313
+ </div>
314
+
315
+ <div class="method-description">
316
+ <p>
317
+ MUST be called while holding @mutex
318
+ </p>
319
+ <p><a class="source-toggle" href="#"
320
+ onclick="toggleCode('M000150-source');return false;">[Source]</a></p>
321
+ <div class="method-source-code" id="M000150-source">
322
+ <pre>
323
+ <span class="ruby-comment cmt"># File lib/wee/application.rb, line 117</span>
324
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">garbage_collect_handlers</span>
325
+ <span class="ruby-ivar">@request_handlers</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">id</span>,<span class="ruby-identifier">rh</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rh</span>.<span class="ruby-identifier">alive?</span> }
326
+ <span class="ruby-keyword kw">end</span>
327
+ </pre>
328
+ </div>
329
+ </div>
330
+ </div>
331
+
332
+ <div id="method-M000151" class="method-detail">
333
+ <a name="M000151"></a>
334
+
335
+ <div class="method-heading">
336
+ <a href="#M000151" class="method-signature">
282
337
  <span class="method-name">request_handler_expired</span><span class="method-args">(context)</span>
283
338
  </a>
284
339
  </div>
285
340
 
286
341
  <div class="method-description">
287
342
  <p><a class="source-toggle" href="#"
288
- onclick="toggleCode('M000142-source');return false;">[Source]</a></p>
289
- <div class="method-source-code" id="M000142-source">
343
+ onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
344
+ <div class="method-source-code" id="M000151-source">
290
345
  <pre>
291
- <span class="ruby-comment cmt"># File lib/wee/application.rb, line 85</span>
346
+ <span class="ruby-comment cmt"># File lib/wee/application.rb, line 121</span>
292
347
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_handler_expired</span>(<span class="ruby-identifier">context</span>)
293
348
  <span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">RefreshResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;Invalid or expired request handler!&quot;</span>, <span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">application_path</span>)
294
349
  <span class="ruby-keyword kw">end</span>
@@ -297,21 +352,24 @@ thread-safe! TODO: test for max_request_handlers
297
352
  </div>
298
353
  </div>
299
354
 
300
- <div id="method-M000141" class="method-detail">
301
- <a name="M000141"></a>
355
+ <div id="method-M000149" class="method-detail">
356
+ <a name="M000149"></a>
302
357
 
303
358
  <div class="method-heading">
304
- <a href="#M000141" class="method-signature">
359
+ <a href="#M000149" class="method-signature">
305
360
  <span class="method-name">unique_request_handler_id</span><span class="method-args">()</span>
306
361
  </a>
307
362
  </div>
308
363
 
309
364
  <div class="method-description">
365
+ <p>
366
+ MUST be called while holding @mutex
367
+ </p>
310
368
  <p><a class="source-toggle" href="#"
311
- onclick="toggleCode('M000141-source');return false;">[Source]</a></p>
312
- <div class="method-source-code" id="M000141-source">
369
+ onclick="toggleCode('M000149-source');return false;">[Source]</a></p>
370
+ <div class="method-source-code" id="M000149-source">
313
371
  <pre>
314
- <span class="ruby-comment cmt"># File lib/wee/application.rb, line 79</span>
372
+ <span class="ruby-comment cmt"># File lib/wee/application.rb, line 109</span>
315
373
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unique_request_handler_id</span>
316
374
  <span class="ruby-identifier">id</span> = <span class="ruby-ivar">@id_generator</span>.<span class="ruby-identifier">next</span>.<span class="ruby-identifier">to_s</span>
317
375
  <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;failed to create unique request handler id&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@request_handlers</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">id</span>)
@@ -80,7 +80,7 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000075">callback</a>&nbsp;&nbsp;
83
+ <a href="#M000081">callback</a>&nbsp;&nbsp;
84
84
  </div>
85
85
  </div>
86
86
 
@@ -88,13 +88,6 @@
88
88
 
89
89
 
90
90
  <!-- if includes -->
91
- <div id="includes">
92
- <h3 class="section-bar">Included Modules</h3>
93
-
94
- <div id="includes-list">
95
- <span class="include-name"><a href="CallbackMixin.html">Brush::CallbackMixin</a></span>
96
- </div>
97
- </div>
98
91
 
99
92
  <div id="section">
100
93
 
@@ -109,25 +102,25 @@
109
102
  <div id="methods">
110
103
  <h3 class="section-bar">Public Instance methods</h3>
111
104
 
112
- <div id="method-M000075" class="method-detail">
113
- <a name="M000075"></a>
105
+ <div id="method-M000081" class="method-detail">
106
+ <a name="M000081"></a>
114
107
 
115
108
  <div class="method-heading">
116
- <a href="#M000075" class="method-signature">
109
+ <a href="#M000081" class="method-signature">
117
110
  <span class="method-name">callback</span><span class="method-args">(symbol=nil, &amp;block)</span>
118
111
  </a>
119
112
  </div>
120
113
 
121
114
  <div class="method-description">
122
115
  <p><a class="source-toggle" href="#"
123
- onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
124
- <div class="method-source-code" id="M000075-source">
116
+ onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
117
+ <div class="method-source-code" id="M000081-source">
125
118
  <pre>
126
- <span class="ruby-comment cmt"># File lib/wee/renderer/html/brushes.rb, line 178</span>
119
+ <span class="ruby-comment cmt"># File lib/wee/renderer/html/brushes.rb, line 165</span>
127
120
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">callback</span>(<span class="ruby-identifier">symbol</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
128
121
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">symbol</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">block</span>
129
122
  <span class="ruby-identifier">block</span> = <span class="ruby-ivar">@canvas</span>.<span class="ruby-identifier">current_component</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">symbol</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
130
- <span class="ruby-identifier">name</span>(<span class="ruby-identifier">register_callback</span>(<span class="ruby-identifier">:action</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>))
123
+ <span class="ruby-identifier">name</span>(<span class="ruby-ivar">@canvas</span>.<span class="ruby-identifier">register_callback</span>(<span class="ruby-identifier">:action</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>))
131
124
  <span class="ruby-keyword kw">end</span>
132
125
  </pre>
133
126
  </div>
@@ -86,7 +86,7 @@ The callback id is listed in the URL (not as a form-data field)
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000074">callback</a>&nbsp;&nbsp;
89
+ <a href="#M000080">callback</a>&nbsp;&nbsp;
90
90
  </div>
91
91
  </div>
92
92
 
@@ -94,13 +94,6 @@ The callback id is listed in the URL (not as a form-data field)
94
94
 
95
95
 
96
96
  <!-- if includes -->
97
- <div id="includes">
98
- <h3 class="section-bar">Included Modules</h3>
99
-
100
- <div id="includes-list">
101
- <span class="include-name"><a href="CallbackMixin.html">Brush::CallbackMixin</a></span>
102
- </div>
103
- </div>
104
97
 
105
98
  <div id="section">
106
99
 
@@ -115,27 +108,23 @@ The callback id is listed in the URL (not as a form-data field)
115
108
  <div id="methods">
116
109
  <h3 class="section-bar">Public Instance methods</h3>
117
110
 
118
- <div id="method-M000074" class="method-detail">
119
- <a name="M000074"></a>
111
+ <div id="method-M000080" class="method-detail">
112
+ <a name="M000080"></a>
120
113
 
121
114
  <div class="method-heading">
122
- <a href="#M000074" class="method-signature">
115
+ <a href="#M000080" class="method-signature">
123
116
  <span class="method-name">callback</span><span class="method-args">(symbol=nil, &amp;block)</span>
124
117
  </a>
125
118
  </div>
126
119
 
127
120
  <div class="method-description">
128
121
  <p><a class="source-toggle" href="#"
129
- onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
130
- <div class="method-source-code" id="M000074-source">
122
+ onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
123
+ <div class="method-source-code" id="M000080-source">
131
124
  <pre>
132
- <span class="ruby-comment cmt"># File lib/wee/renderer/html/brushes.rb, line 191</span>
125
+ <span class="ruby-comment cmt"># File lib/wee/renderer/html/brushes.rb, line 176</span>
133
126
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">callback</span>(<span class="ruby-identifier">symbol</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
134
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">symbol</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">block</span>
135
- <span class="ruby-identifier">block</span> = <span class="ruby-ivar">@canvas</span>.<span class="ruby-identifier">current_component</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">symbol</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
136
- <span class="ruby-identifier">req</span> = <span class="ruby-ivar">@canvas</span>.<span class="ruby-identifier">rendering_context</span>.<span class="ruby-identifier">request</span>
137
- <span class="ruby-identifier">url</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">build_url</span>(<span class="ruby-identifier">req</span>.<span class="ruby-identifier">request_handler_id</span>, <span class="ruby-identifier">req</span>.<span class="ruby-identifier">page_id</span>, <span class="ruby-identifier">register_callback</span>(<span class="ruby-identifier">:action</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>))
138
- <span class="ruby-identifier">__set_url</span>(<span class="ruby-identifier">url</span>)
127
+ <span class="ruby-identifier">__set_url</span>(<span class="ruby-ivar">@canvas</span>.<span class="ruby-identifier">url_for_callback</span>(<span class="ruby-identifier">symbol</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>))
139
128
  <span class="ruby-keyword kw">end</span>
140
129
  </pre>
141
130
  </div>