wee 0.10.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (369) hide show
  1. data/README.rdoc +127 -0
  2. data/Rakefile +11 -32
  3. data/doc/rdoc/classes/Array.html +28 -24
  4. data/doc/rdoc/classes/Hash.html +28 -24
  5. data/doc/rdoc/classes/Object.html +37 -84
  6. data/doc/rdoc/classes/String.html +89 -21
  7. data/doc/rdoc/classes/Struct.html +32 -82
  8. data/doc/rdoc/classes/Wee.html +285 -86
  9. data/doc/rdoc/classes/Wee/AnswerDecoration.html +111 -48
  10. data/doc/rdoc/classes/Wee/{Context.html → AnswerDecoration/Answer.html} +61 -51
  11. data/doc/rdoc/classes/Wee/Application.html +161 -322
  12. data/doc/rdoc/classes/Wee/Application/SessionCache.html +162 -0
  13. data/doc/rdoc/classes/Wee/Brush.html +147 -62
  14. data/doc/rdoc/classes/{Enumerable.html → Wee/Brush/ActionInputTag.html} +68 -41
  15. data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +150 -100
  16. data/doc/rdoc/classes/Wee/Brush/CheckboxTag.html +132 -46
  17. data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +63 -41
  18. data/doc/rdoc/classes/Wee/Brush/FormTag.html +184 -78
  19. data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +48 -65
  20. data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +83 -37
  21. data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +334 -310
  22. data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +74 -54
  23. data/doc/rdoc/classes/Wee/Brush/HiddenInputTag.html +58 -43
  24. data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +64 -74
  25. data/doc/rdoc/classes/Wee/Brush/ImageTag.html +109 -86
  26. data/doc/rdoc/classes/Wee/Brush/InputTag.html +205 -45
  27. data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +96 -34
  28. data/doc/rdoc/classes/Wee/Brush/Page.html +129 -67
  29. data/doc/rdoc/classes/Wee/{Utils/LRUCache.html → Brush/PasswordInputTag.html} +65 -38
  30. data/doc/rdoc/classes/Wee/Brush/RadioButtonTag.html +132 -78
  31. data/doc/rdoc/classes/Wee/Brush/{RadioButtonTag/RadioGroup.html → RadioGroup.html} +91 -53
  32. data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +301 -127
  33. data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +96 -33
  34. data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +59 -44
  35. data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +94 -57
  36. data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +96 -33
  37. data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +181 -121
  38. data/doc/rdoc/classes/Wee/Brush/TableTag.html +94 -32
  39. data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +257 -71
  40. data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +58 -43
  41. data/doc/rdoc/classes/Wee/CallAnswerMixin.html +289 -0
  42. data/doc/rdoc/classes/Wee/CallbackMixin.html +233 -0
  43. data/doc/rdoc/classes/Wee/CallbackRegistry.html +179 -155
  44. data/doc/rdoc/classes/Wee/Callbacks.html +262 -0
  45. data/doc/rdoc/classes/Wee/Component.html +228 -779
  46. data/doc/rdoc/classes/Wee/Decoration.html +144 -159
  47. data/doc/rdoc/classes/Wee/DecorationMixin.html +340 -0
  48. data/doc/rdoc/classes/Wee/Delegate.html +119 -76
  49. data/doc/rdoc/classes/Wee/DupReplaceSnapshotMixin.html +64 -47
  50. data/doc/rdoc/classes/Wee/ErrorResponse.html +59 -62
  51. data/doc/rdoc/classes/Wee/FormDecoration.html +51 -37
  52. data/doc/rdoc/classes/Wee/GenericResponse.html +60 -35
  53. data/doc/rdoc/classes/Wee/HtmlCanvas.html +1000 -602
  54. data/doc/rdoc/classes/Wee/HtmlDocument.html +288 -0
  55. data/doc/rdoc/classes/Wee/HtmlWriter.html +227 -126
  56. data/doc/rdoc/classes/Wee/IdGenerator.html +60 -31
  57. data/doc/rdoc/classes/Wee/IdGenerator/Secure.html +282 -0
  58. data/doc/rdoc/classes/Wee/{SimpleIdGenerator.html → IdGenerator/Sequential.html} +76 -49
  59. data/doc/rdoc/classes/Wee/JQuery.html +221 -0
  60. data/doc/rdoc/classes/Wee/LRUCache.html +514 -0
  61. data/doc/rdoc/classes/Wee/LRUCache/Item.html +158 -0
  62. data/doc/rdoc/classes/Wee/ObjectSnapshotMixin.html +187 -0
  63. data/doc/rdoc/classes/Wee/PageDecoration.html +88 -59
  64. data/doc/rdoc/classes/Wee/Presenter.html +124 -704
  65. data/doc/rdoc/classes/Wee/RedirectResponse.html +64 -33
  66. data/doc/rdoc/classes/Wee/RefreshResponse.html +59 -44
  67. data/doc/rdoc/classes/Wee/Renderer.html +234 -54
  68. data/doc/rdoc/classes/Wee/Request.html +151 -286
  69. data/doc/rdoc/classes/Wee/Response.html +29 -212
  70. data/doc/rdoc/classes/Wee/Session.html +585 -360
  71. data/doc/rdoc/classes/Wee/{StateHolder.html → Session/AbortCallbackProcessing.html} +67 -40
  72. data/doc/rdoc/classes/Wee/Session/MutexSerializer.html +166 -0
  73. data/doc/rdoc/classes/{Cache/Strategy/LFU/Item.html → Wee/Session/Page.html} +26 -27
  74. data/doc/rdoc/classes/Wee/Session/ThreadSerializer.html +219 -0
  75. data/doc/rdoc/classes/Wee/State.html +307 -0
  76. data/doc/rdoc/classes/{Cache/Strategy/LRU/Item.html → Wee/State/Snapshot.html} +26 -27
  77. data/doc/rdoc/classes/{Cache/Strategy/Unbounded/Item.html → Wee/State/SnapshotIVars.html} +26 -27
  78. data/doc/rdoc/classes/Wee/StructSnapshotMixin.html +183 -0
  79. data/doc/rdoc/classes/Wee/WrapperDecoration.html +101 -35
  80. data/doc/rdoc/created.rid +1 -1
  81. data/doc/rdoc/files/README_rdoc.html +243 -0
  82. data/doc/rdoc/files/lib/wee/application_rb.html +22 -30
  83. data/doc/rdoc/files/lib/wee/{page_rb.html → call_answer_rb.html} +14 -25
  84. data/doc/rdoc/files/lib/wee/callback_rb.html +12 -29
  85. data/doc/rdoc/files/lib/wee/component_rb.html +22 -27
  86. data/doc/rdoc/files/lib/wee/decoration_rb.html +19 -20
  87. data/doc/rdoc/files/lib/wee/{idgen_rb.html → html_brushes_rb.html} +14 -25
  88. data/doc/rdoc/files/lib/wee/html_canvas_rb.html +15 -23
  89. data/doc/rdoc/files/lib/wee/{abstractsession_rb.html → html_document_rb.html} +17 -25
  90. data/doc/rdoc/files/lib/wee/html_writer_rb.html +15 -23
  91. data/doc/rdoc/files/lib/wee/{webrick_rb.html → id_generator_rb.html} +19 -25
  92. data/doc/rdoc/files/lib/wee/{core/page_rb.html → jquery/jquery_rb.html} +14 -25
  93. data/doc/rdoc/files/lib/wee/{state_registry_rb.html → jquery_rb.html} +17 -27
  94. data/doc/rdoc/files/lib/{cache/cache_rb.html → wee/lru_cache_rb.html} +14 -25
  95. data/doc/rdoc/files/lib/wee/presenter_rb.html +12 -34
  96. data/doc/rdoc/files/lib/wee/{holder_rb.html → renderer_rb.html} +14 -25
  97. data/doc/rdoc/files/lib/wee/request_rb.html +18 -32
  98. data/doc/rdoc/files/lib/wee/response_rb.html +17 -24
  99. data/doc/rdoc/files/lib/wee/session_rb.html +21 -23
  100. data/doc/rdoc/files/lib/wee/state_rb.html +90 -0
  101. data/doc/rdoc/files/lib/wee_rb.html +48 -40
  102. data/doc/rdoc/fr_class_index.html +111 -75
  103. data/doc/rdoc/fr_file_index.html +46 -76
  104. data/doc/rdoc/fr_method_index.html +473 -480
  105. data/doc/rdoc/index.html +6 -9
  106. data/doc/rdoc/rdoc-style.css +210 -119
  107. data/examples/ObjectSpaceBrowser.rb +33 -23
  108. data/examples/ajax.rb +71 -0
  109. data/examples/continuations.rb +28 -0
  110. data/examples/demo.rb +92 -36
  111. data/examples/demo/calculator.rb +63 -0
  112. data/examples/demo/calendar.rb +42 -55
  113. data/examples/demo/counter.rb +38 -0
  114. data/{lib/wee/examples → examples/demo}/editable_counter.rb +11 -6
  115. data/examples/demo/example.rb +28 -24
  116. data/examples/demo/file_upload.rb +19 -0
  117. data/{lib/wee/components → examples/demo}/messagebox.rb +3 -3
  118. data/examples/demo/radio.rb +33 -0
  119. data/{lib/wee/examples → examples/demo}/window.rb +15 -10
  120. data/examples/hw.rb +3 -4
  121. data/{lib/wee/components → examples}/pager.rb +14 -14
  122. data/lib/wee.rb +48 -25
  123. data/lib/wee/application.rb +69 -131
  124. data/lib/wee/call_answer.rb +118 -0
  125. data/lib/wee/callback.rb +88 -0
  126. data/lib/wee/component.rb +141 -0
  127. data/lib/wee/decoration.rb +242 -0
  128. data/lib/wee/html_brushes.rb +725 -0
  129. data/lib/wee/html_canvas.rb +241 -0
  130. data/lib/wee/html_document.rb +45 -0
  131. data/lib/wee/html_writer.rb +71 -0
  132. data/lib/wee/id_generator.rb +70 -0
  133. data/lib/wee/jquery.rb +1 -0
  134. data/lib/wee/jquery/jquery.rb +17 -0
  135. data/lib/wee/jquery/public/jquery-1.3.2.min.js +19 -0
  136. data/lib/wee/jquery/public/wee-jquery.js +19 -0
  137. data/lib/wee/lru_cache.rb +89 -0
  138. data/lib/wee/presenter.rb +43 -0
  139. data/lib/wee/renderer.rb +65 -0
  140. data/lib/wee/request.rb +37 -113
  141. data/lib/wee/response.rb +43 -70
  142. data/lib/wee/session.rb +304 -113
  143. data/lib/wee/state.rb +85 -0
  144. data/test/component_spec.rb +17 -0
  145. data/wee.gemspec +4 -3
  146. metadata +249 -452
  147. data/ChangeLog +0 -657
  148. data/INSTALL +0 -17
  149. data/README +0 -272
  150. data/TODO +0 -142
  151. data/benchmark/Centrino1300/result.2000.counter.action +0 -45
  152. data/benchmark/Centrino1300/result.2000.counter.render +0 -43
  153. data/benchmark/Centrino1300/result.2000.filehandler +0 -43
  154. data/benchmark/Centrino600/result.2000.counter.action +0 -47
  155. data/benchmark/Centrino600/result.2000.counter.render +0 -45
  156. data/benchmark/Centrino600/result.2000.filehandler +0 -43
  157. data/benchmark/Makefile +0 -53
  158. data/benchmark/counter.rb +0 -77
  159. data/benchmark/filehandler.rb +0 -6
  160. data/benchmark/report_req.rb +0 -12
  161. data/bin/wee +0 -100
  162. data/doc/rdoc/classes/ActionView.html +0 -107
  163. data/doc/rdoc/classes/ActionView/Base.html +0 -133
  164. data/doc/rdoc/classes/Cache.html +0 -126
  165. data/doc/rdoc/classes/Cache/StorageCache.html +0 -320
  166. data/doc/rdoc/classes/Cache/Strategy.html +0 -128
  167. data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +0 -269
  168. data/doc/rdoc/classes/Cache/Strategy/LFU.html +0 -238
  169. data/doc/rdoc/classes/Cache/Strategy/LRU.html +0 -238
  170. data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +0 -225
  171. data/doc/rdoc/classes/LiteralMethod.html +0 -196
  172. data/doc/rdoc/classes/Main.html +0 -289
  173. data/doc/rdoc/classes/OgApplication.html +0 -126
  174. data/doc/rdoc/classes/OgScaffolder.html +0 -827
  175. data/doc/rdoc/classes/OgScaffolder/Editor.html +0 -565
  176. data/doc/rdoc/classes/OgSession.html +0 -172
  177. data/doc/rdoc/classes/Recipe.html +0 -113
  178. data/doc/rdoc/classes/Wee/AbstractSession.html +0 -502
  179. data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +0 -148
  180. data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +0 -146
  181. data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +0 -154
  182. data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +0 -141
  183. data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +0 -141
  184. data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +0 -148
  185. data/doc/rdoc/classes/Wee/Brush/SelectListTag/SelectListCallback.html +0 -158
  186. data/doc/rdoc/classes/Wee/Brush/ToCallback.html +0 -146
  187. data/doc/rdoc/classes/Wee/Callback.html +0 -231
  188. data/doc/rdoc/classes/Wee/CallbackStream.html +0 -227
  189. data/doc/rdoc/classes/Wee/Canvas.html +0 -235
  190. data/doc/rdoc/classes/Wee/CanvasMixin.html +0 -225
  191. data/doc/rdoc/classes/Wee/Component/OnAnswer.html +0 -153
  192. data/doc/rdoc/classes/Wee/ComponentDispatcher.html +0 -289
  193. data/doc/rdoc/classes/Wee/ComponentRunner.html +0 -321
  194. data/doc/rdoc/classes/Wee/ErrorPage.html +0 -175
  195. data/doc/rdoc/classes/Wee/Examples.html +0 -114
  196. data/doc/rdoc/classes/Wee/Examples/Calculator.html +0 -319
  197. data/doc/rdoc/classes/Wee/Examples/Counter.html +0 -289
  198. data/doc/rdoc/classes/Wee/Examples/EditableCounter.html +0 -210
  199. data/doc/rdoc/classes/Wee/Examples/Window.html +0 -346
  200. data/doc/rdoc/classes/Wee/FastCGIAdaptor.html +0 -227
  201. data/doc/rdoc/classes/Wee/Helper.html +0 -148
  202. data/doc/rdoc/classes/Wee/HtmlCanvasRenderer.html +0 -1230
  203. data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +0 -198
  204. data/doc/rdoc/classes/Wee/LoginDecoration.html +0 -261
  205. data/doc/rdoc/classes/Wee/Md5IdGenerator.html +0 -181
  206. data/doc/rdoc/classes/Wee/MessageBox.html +0 -180
  207. data/doc/rdoc/classes/Wee/MethodCallback.html +0 -193
  208. data/doc/rdoc/classes/Wee/Nitro.html +0 -114
  209. data/doc/rdoc/classes/Wee/Nitro/ControllerClassMixin.html +0 -192
  210. data/doc/rdoc/classes/Wee/Nitro/ControllerMixin.html +0 -345
  211. data/doc/rdoc/classes/Wee/Nitro/FormTag.html +0 -155
  212. data/doc/rdoc/classes/Wee/Nitro/HtmlCanvasRenderer.html +0 -178
  213. data/doc/rdoc/classes/Wee/Page.html +0 -115
  214. data/doc/rdoc/classes/Wee/PagelessApplication.html +0 -154
  215. data/doc/rdoc/classes/Wee/PagelessComponentDriver.html +0 -296
  216. data/doc/rdoc/classes/Wee/PagelessRequest.html +0 -208
  217. data/doc/rdoc/classes/Wee/PagelessSession.html +0 -359
  218. data/doc/rdoc/classes/Wee/Pager.html +0 -534
  219. data/doc/rdoc/classes/Wee/Rails.html +0 -114
  220. data/doc/rdoc/classes/Wee/Rails/ControllerClassMixin.html +0 -192
  221. data/doc/rdoc/classes/Wee/Rails/ControllerMixin.html +0 -342
  222. data/doc/rdoc/classes/Wee/Rails/FormTag.html +0 -155
  223. data/doc/rdoc/classes/Wee/Rails/HtmlCanvasRenderer.html +0 -177
  224. data/doc/rdoc/classes/Wee/RenderingContext.html +0 -283
  225. data/doc/rdoc/classes/Wee/RequestHandler.html +0 -341
  226. data/doc/rdoc/classes/Wee/Snapshot.html +0 -211
  227. data/doc/rdoc/classes/Wee/StateRegistry.html +0 -434
  228. data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +0 -320
  229. data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +0 -153
  230. data/doc/rdoc/classes/Wee/Utils.html +0 -300
  231. data/doc/rdoc/classes/Wee/ValueHolder.html +0 -220
  232. data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +0 -368
  233. data/doc/rdoc/files/INSTALL.html +0 -130
  234. data/doc/rdoc/files/README.html +0 -471
  235. data/doc/rdoc/files/lib/wee/adaptors/fastcgi_rb.html +0 -108
  236. data/doc/rdoc/files/lib/wee/adaptors/nitro_rb.html +0 -101
  237. data/doc/rdoc/files/lib/wee/adaptors/rails_rb.html +0 -101
  238. data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +0 -108
  239. data/doc/rdoc/files/lib/wee/component_ext_rb.html +0 -101
  240. data/doc/rdoc/files/lib/wee/components/component_dispatcher_rb.html +0 -108
  241. data/doc/rdoc/files/lib/wee/components/form_decoration_rb.html +0 -101
  242. data/doc/rdoc/files/lib/wee/components/login_decoration_rb.html +0 -101
  243. data/doc/rdoc/files/lib/wee/components/messagebox_rb.html +0 -101
  244. data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +0 -101
  245. data/doc/rdoc/files/lib/wee/components/pager_rb.html +0 -101
  246. data/doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html +0 -101
  247. data/doc/rdoc/files/lib/wee/components_rb.html +0 -114
  248. data/doc/rdoc/files/lib/wee/context_rb.html +0 -101
  249. data/doc/rdoc/files/lib/wee/continuation/core/component_rb.html +0 -101
  250. data/doc/rdoc/files/lib/wee/continuation/session_rb.html +0 -108
  251. data/doc/rdoc/files/lib/wee/continuation_rb.html +0 -116
  252. data/doc/rdoc/files/lib/wee/core/callback_rb.html +0 -115
  253. data/doc/rdoc/files/lib/wee/core/component_rb.html +0 -108
  254. data/doc/rdoc/files/lib/wee/core/componentrunner_rb.html +0 -110
  255. data/doc/rdoc/files/lib/wee/core/context_rb.html +0 -101
  256. data/doc/rdoc/files/lib/wee/core/decoration_rb.html +0 -133
  257. data/doc/rdoc/files/lib/wee/core/idgen_rb.html +0 -101
  258. data/doc/rdoc/files/lib/wee/core/presenter_rb.html +0 -112
  259. data/doc/rdoc/files/lib/wee/core/renderer_rb.html +0 -107
  260. data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +0 -113
  261. data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +0 -110
  262. data/doc/rdoc/files/lib/wee/core_ext_rb.html +0 -101
  263. data/doc/rdoc/files/lib/wee/core_rb.html +0 -124
  264. data/doc/rdoc/files/lib/wee/databases/og/application_rb.html +0 -101
  265. data/doc/rdoc/files/lib/wee/databases/og/old_scaffolder_rb.html +0 -101
  266. data/doc/rdoc/files/lib/wee/databases/og/scaffolder_rb.html +0 -115
  267. data/doc/rdoc/files/lib/wee/databases/og/session_rb.html +0 -101
  268. data/doc/rdoc/files/lib/wee/databases/og_rb.html +0 -111
  269. data/doc/rdoc/files/lib/wee/examples/calculator_rb.html +0 -107
  270. data/doc/rdoc/files/lib/wee/examples/counter_rb.html +0 -101
  271. data/doc/rdoc/files/lib/wee/examples/editable_counter_rb.html +0 -114
  272. data/doc/rdoc/files/lib/wee/examples/window_rb.html +0 -101
  273. data/doc/rdoc/files/lib/wee/idgen/md5_rb.html +0 -115
  274. data/doc/rdoc/files/lib/wee/idgen/simple_rb.html +0 -107
  275. data/doc/rdoc/files/lib/wee/pageless/application_rb.html +0 -108
  276. data/doc/rdoc/files/lib/wee/pageless/request_rb.html +0 -101
  277. data/doc/rdoc/files/lib/wee/pageless/session_rb.html +0 -109
  278. data/doc/rdoc/files/lib/wee/pageless_rb.html +0 -110
  279. data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +0 -101
  280. data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +0 -108
  281. data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +0 -108
  282. data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +0 -101
  283. data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +0 -101
  284. data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +0 -108
  285. data/doc/rdoc/files/lib/wee/requesthandler_rb.html +0 -101
  286. data/doc/rdoc/files/lib/wee/skeleton/og/components/main_rb.html +0 -101
  287. data/doc/rdoc/files/lib/wee/skeleton/og/conf/db_rb.html +0 -114
  288. data/doc/rdoc/files/lib/wee/skeleton/og/models/recipe_rb.html +0 -101
  289. data/doc/rdoc/files/lib/wee/skeleton/og/run_rb.html +0 -115
  290. data/doc/rdoc/files/lib/wee/skeleton/simple/components/main_rb.html +0 -101
  291. data/doc/rdoc/files/lib/wee/skeleton/simple/run_rb.html +0 -111
  292. data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +0 -101
  293. data/doc/rdoc/files/lib/wee/snapshot_rb.html +0 -107
  294. data/doc/rdoc/files/lib/wee/stuff_rb.html +0 -144
  295. data/doc/rdoc/files/lib/wee/template_rb.html +0 -101
  296. data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +0 -101
  297. data/doc/rdoc/files/lib/wee/utils/cache_rb.html +0 -108
  298. data/doc/rdoc/files/lib/wee/utils/helper_rb.html +0 -101
  299. data/doc/rdoc/files/lib/wee/utils_rb.html +0 -110
  300. data/examples/ajax/ajax.js +0 -444
  301. data/examples/ajax/ajax.rb +0 -31
  302. data/examples/cc.rb +0 -74
  303. data/examples/dispatcher.rb +0 -37
  304. data/examples/draw.rb +0 -94
  305. data/examples/live-update.rb +0 -45
  306. data/examples/nitro/run.rb +0 -42
  307. data/examples/og-test.rb +0 -60
  308. data/examples/radio.rb +0 -44
  309. data/examples/test.rb +0 -39
  310. data/install.rb +0 -14
  311. data/lib/cache/cache.rb +0 -167
  312. data/lib/wee/abstractsession.rb +0 -96
  313. data/lib/wee/adaptors/fastcgi.rb +0 -76
  314. data/lib/wee/adaptors/nitro.rb +0 -155
  315. data/lib/wee/adaptors/rails.rb +0 -154
  316. data/lib/wee/adaptors/webrick.rb +0 -89
  317. data/lib/wee/components.rb +0 -7
  318. data/lib/wee/components/component_dispatcher.rb +0 -46
  319. data/lib/wee/components/form_decoration.rb +0 -7
  320. data/lib/wee/components/login_decoration.rb +0 -35
  321. data/lib/wee/components/page_decoration.rb +0 -14
  322. data/lib/wee/components/wrapper_decoration.rb +0 -7
  323. data/lib/wee/continuation.rb +0 -5
  324. data/lib/wee/continuation/core/component.rb +0 -56
  325. data/lib/wee/continuation/session.rb +0 -64
  326. data/lib/wee/core.rb +0 -16
  327. data/lib/wee/core/callback.rb +0 -121
  328. data/lib/wee/core/component.rb +0 -356
  329. data/lib/wee/core/componentrunner.rb +0 -73
  330. data/lib/wee/core/context.rb +0 -27
  331. data/lib/wee/core/decoration.rb +0 -138
  332. data/lib/wee/core/idgen.rb +0 -5
  333. data/lib/wee/core/page.rb +0 -1
  334. data/lib/wee/core/presenter.rb +0 -100
  335. data/lib/wee/core/renderer.rb +0 -23
  336. data/lib/wee/core/snapshot.rb +0 -21
  337. data/lib/wee/core/valueholder.rb +0 -19
  338. data/lib/wee/core_ext.rb +0 -122
  339. data/lib/wee/databases/og.rb +0 -4
  340. data/lib/wee/databases/og/application.rb +0 -3
  341. data/lib/wee/databases/og/old_scaffolder.rb +0 -98
  342. data/lib/wee/databases/og/scaffolder.rb +0 -255
  343. data/lib/wee/databases/og/session.rb +0 -9
  344. data/lib/wee/examples/calculator.rb +0 -70
  345. data/lib/wee/examples/counter.rb +0 -33
  346. data/lib/wee/idgen/md5.rb +0 -21
  347. data/lib/wee/idgen/sequential.rb +0 -11
  348. data/lib/wee/pageless.rb +0 -3
  349. data/lib/wee/pageless/application.rb +0 -13
  350. data/lib/wee/pageless/request.rb +0 -27
  351. data/lib/wee/pageless/session.rb +0 -74
  352. data/lib/wee/renderer/html/brushes.rb +0 -667
  353. data/lib/wee/renderer/html/canvas.rb +0 -265
  354. data/lib/wee/renderer/html/writer.rb +0 -80
  355. data/lib/wee/requesthandler.rb +0 -81
  356. data/lib/wee/skeleton/og/README +0 -38
  357. data/lib/wee/skeleton/og/components/main.rb +0 -20
  358. data/lib/wee/skeleton/og/conf/db.rb +0 -8
  359. data/lib/wee/skeleton/og/models/recipe.rb +0 -5
  360. data/lib/wee/skeleton/og/run.rb +0 -23
  361. data/lib/wee/skeleton/simple/README +0 -32
  362. data/lib/wee/skeleton/simple/components/main.rb +0 -25
  363. data/lib/wee/skeleton/simple/run.rb +0 -12
  364. data/lib/wee/snapshot_ext.rb +0 -41
  365. data/lib/wee/template.rb +0 -42
  366. data/lib/wee/utils.rb +0 -5
  367. data/lib/wee/utils/autoreload.rb +0 -56
  368. data/lib/wee/utils/cache.rb +0 -7
  369. data/lib/wee/utils/helper.rb +0 -51
@@ -1,147 +1,85 @@
1
- # A Wee::Application manages all Wee::RequestHandler's of a single application,
2
- # where most of the time the request handlers are Wee::Session objects. It
3
- # dispatches the request to the correct handler by examining the request.
1
+ require 'thread'
2
+ require 'wee/id_generator'
3
+ require 'wee/lru_cache'
4
4
 
5
- class Wee::Application
5
+ module Wee
6
6
 
7
- # The generator used for creating unique request handler id's.
8
-
9
- attr_accessor :id_generator
10
-
11
- # The maximum number of request handlers
12
-
13
- attr_accessor :max_request_handlers
14
-
15
- # Get or set the default request handler. The default request handler is used
16
- # if no request handler id is given in a request.
17
-
18
- def default_request_handler(&block)
19
- if block.nil?
20
- @default_request_handler
21
- else
22
- @default_request_handler = block
23
- end
24
- end
25
-
26
- # Creates a new application. The block is used to initialize the attributes:
27
7
  #
28
- # Wee::Application.new {|app|
29
- # app.default_request_handler { MySession.new }
30
- # app.id_generator = Wee::SequentialIdGenerator.new
31
- # app.max_request_handlers = 1000
32
- # }
8
+ # A Wee::Application manages all Session's of a single application. It
9
+ # dispatches the request to the correct handler by examining the request.
10
+ #
11
+ class Application
33
12
 
34
- def initialize(&block)
35
- @request_handlers = Hash.new
36
- block.call(self)
37
- @id_generator ||= Wee::SequentialIdGenerator.new(rand(1_000_000))
38
- if @default_request_handler.nil?
39
- raise ArgumentError, "No default request handler specified"
13
+ class SessionCache < Wee::LRUCache
14
+ def garbage_collect
15
+ delete_if {|id, session| session.dead? }
16
+ end
40
17
  end
41
- @mutex = Mutex.new
42
-
43
- # start request-handler collecting thread
44
- # run once every minute
45
- @gc_thread = Thread.new {
46
- sleep 60
47
- @mutex.synchronize { garbage_collect_handlers }
48
- }
49
- end
50
-
51
- def handle_request(context)
52
- request_handler_id = context.request.request_handler_id
53
- request_handler = @mutex.synchronize { @request_handlers[request_handler_id] }
54
-
55
- if request_handler_id.nil?
56
-
57
- # No id was given -> check whether the maximum number of request-handlers
58
- # limit is reached. if not, create new id and handler
59
-
60
- request_handler = @default_request_handler.call
61
- insert_new_request_handler(request_handler)
62
- context.request.request_handler_id = request_handler.id
63
- handle_request(context)
64
- return
65
-
66
- elsif request_handler.nil?
67
-
68
- # A false request handler id was given. This might indicate that a
69
- # request handler has expired.
70
-
71
- request_handler_expired(context)
72
- return
73
-
74
- elsif !request_handler.alive?
75
-
76
- # The request_handler is not alive anymore.
77
-
78
- request_handler_expired(context)
79
- return
80
18
 
19
+ #
20
+ # Creates a new application. The block, when called, must
21
+ # return a new Session instance.
22
+ #
23
+ # Wee::Application.new { Wee::Session.new(root_component) }
24
+ #
25
+ def initialize(max_sessions=10_000, &block)
26
+ @session_factory = block || raise(ArgumentError)
27
+ @session_ids ||= Wee::IdGenerator::Secure.new
28
+ @sessions = SessionCache.new(max_sessions)
29
+ @mutex = Mutex.new
81
30
  end
82
31
 
83
- request_handler.handle_request(context)
84
-
85
- rescue => exn
86
- context.response = Wee::ErrorResponse.new(exn)
87
- end
88
-
89
- def insert_new_request_handler(request_handler)
90
- @mutex.synchronize {
91
- if @max_request_handlers != nil and @request_handlers.size >= @max_request_handlers
92
- # limit reached -> remove non-alive handlers...
93
- garbage_collect_handlers()
94
-
95
- # ...and test again
96
- if @request_handlers.size >= @max_request_handlers
97
- # TODO: show a custom error message
98
- raise "maximum number of request-handlers reached"
32
+ #
33
+ # Garbage collect dead sessions
34
+ #
35
+ def cleanup_sessions
36
+ @mutex.synchronize { @sessions.garbage_collect }
37
+ end
38
+
39
+ #
40
+ # Handles a web request
41
+ #
42
+ def call(env)
43
+ request = Wee::Request.new(env)
44
+
45
+ if request.session_id
46
+ session = @mutex.synchronize { @sessions[request.session_id] }
47
+ if session and session.alive?
48
+ session.call(env)
49
+ else
50
+ url = request.build_url(:session_id => nil, :page_id => nil)
51
+ Wee::RefreshResponse.new("Invalid or expired session", url).finish
99
52
  end
53
+ else
54
+ session = new_session()
55
+ url = request.build_url(:session_id => session.id, :page_id => nil)
56
+ Wee::RedirectResponse.new(url).finish
100
57
  end
101
-
102
- request_handler.id = unique_request_handler_id()
103
- request_handler.application = self
104
- @request_handlers[request_handler.id] = request_handler
105
- }
106
- end
107
-
108
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109
- # :section: Properties
110
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111
-
112
- def properties() @__properties end
113
- def properties=(props) @__properties = props end
114
-
115
- # Returns an "owned" property for the given +klass+.
116
-
117
- def get_property(prop, klass)
118
- if self.properties
119
- self.properties.fetch(klass, {})[prop]
120
- else
121
- nil
122
58
  end
123
- end
124
-
125
- private
126
59
 
127
- # MUST be called while holding @mutex
60
+ protected
128
61
 
129
- def unique_request_handler_id
130
- id = @id_generator.next.to_s
131
- raise "failed to create unique request handler id" if @request_handlers.include?(id)
132
- return id
133
- end
134
-
135
- # MUST be called while holding @mutex
62
+ def new_session
63
+ session = @session_factory.call
64
+ session.application = self
65
+ insert_session(session)
66
+ return session
67
+ end
136
68
 
137
- def garbage_collect_handlers
138
- @request_handlers.delete_if {|id,rh| !rh.alive? }
139
- end
69
+ def insert_session(session, retries=3)
70
+ retries.times do
71
+ @mutex.synchronize {
72
+ id = @session_ids.next
73
+ if @sessions[id].nil?
74
+ @sessions[id] = session
75
+ session.id = id
76
+ return
77
+ end
78
+ }
79
+ end
80
+ raise
81
+ end
140
82
 
141
- def request_handler_expired(context)
142
- context.response = Wee::RefreshResponse.new("Invalid or expired request handler!",
143
- context.request.build_url(:request_handler_id => nil,
144
- :page_id => nil))
145
- end
83
+ end # class Application
146
84
 
147
- end
85
+ end # module Wee
@@ -0,0 +1,118 @@
1
+ module Wee
2
+
3
+ #
4
+ # A Wee::AnswerDecoration is wrapped around a component that will call
5
+ # Component#answer. This makes it possible to use such components without the
6
+ # need to call them (Component#call), e.g. as child components of other
7
+ # components.
8
+ #
9
+ class AnswerDecoration < Decoration
10
+
11
+ #
12
+ # Used to unwind the component call chain in Component#answer.
13
+ #
14
+ class Answer < Exception
15
+ attr_reader :args
16
+ def initialize(args) @args = args end
17
+ end
18
+
19
+ attr_accessor :answer_callback
20
+
21
+ def initialize(&answer_callback)
22
+ super()
23
+ @answer_callback = answer_callback
24
+ end
25
+
26
+ #
27
+ # When a component answers, <tt>@answer_callback.call(answer)</tt>
28
+ # will be executed, where +answer+ is of class Answer which includes the
29
+ # arguments passed to Component#answer.
30
+ #
31
+ def process_callbacks(callbacks)
32
+ begin
33
+ super
34
+ rescue Answer => answer
35
+ # return to the calling component
36
+ @answer_callback.call(answer)
37
+ end
38
+ end
39
+
40
+ end # class AnswerDecoration
41
+
42
+ module CallAnswerMixin
43
+
44
+ protected
45
+
46
+ #
47
+ # Call another component. The calling component is neither rendered nor are
48
+ # it's callbacks processed until the called component answers using method
49
+ # #answer.
50
+ #
51
+ # [+component+]
52
+ # The component to be called.
53
+ #
54
+ # [+return_callback+]
55
+ # Is invoked when the called component answers.
56
+ #
57
+ # <b>How it works</b>
58
+ #
59
+ # The component to be called is wrapped with an AnswerDecoration and a
60
+ # Delegate decoration. The latter is used to redirect to the called
61
+ # component. Once the decorations are installed, we end the processing of
62
+ # callbacks prematurely.
63
+ #
64
+ # When at a later point in time the called component invokes #answer, this
65
+ # will raise a AnswerDecoration::Answer exception which is catched by the
66
+ # AnswerDecoration we installed before calling this component, and as such,
67
+ # whose process_callbacks method was called before we gained control.
68
+ #
69
+ # The AnswerDecoration then invokes the <tt>answer_callback</tt> to cleanup
70
+ # the decorations we added during #call and finally passes control to the
71
+ # <tt>return_callback</tt>.
72
+ #
73
+ def call(component, &return_callback)
74
+ delegate = Wee::Delegate.new(component)
75
+ answer = Wee::AnswerDecoration.new {|answ|
76
+ remove_decoration(delegate)
77
+ component.remove_decoration(answer)
78
+ return_callback.call(*answ.args) if return_callback
79
+ }
80
+ add_decoration(delegate)
81
+ component.add_decoration(answer)
82
+ session.send_response(nil)
83
+ end
84
+
85
+ #
86
+ # Similar to method #call, but using continuations.
87
+ #
88
+ def callcc(component)
89
+ delegate = Wee::Delegate.new(component)
90
+ answer = Wee::AnswerDecoration.new
91
+
92
+ add_decoration(delegate)
93
+ component.add_decoration(answer)
94
+
95
+ answ = Kernel.callcc {|cc|
96
+ answer.answer_callback = cc
97
+ session.send_response(nil)
98
+ }
99
+
100
+ remove_decoration(delegate)
101
+ component.remove_decoration(answer)
102
+ return *answ.args
103
+ end
104
+
105
+ #
106
+ # Return from a called component.
107
+ #
108
+ # NOTE that #answer never returns.
109
+ #
110
+ # See #call for a detailed description of the call/answer mechanism.
111
+ #
112
+ def answer(*args)
113
+ raise AnswerDecoration::Answer.new(args)
114
+ end
115
+
116
+ end # module CallAnswerMixin
117
+
118
+ end # module Wee
@@ -0,0 +1,88 @@
1
+ module Wee
2
+
3
+ class CallbackRegistry
4
+ def initialize(prefix="")
5
+ @prefix = prefix
6
+ @next_id = 0
7
+ @callbacks = {} # {callback_id1 => callback1, callback_id2 => callback2}
8
+ @triggered = nil
9
+ @obj_map = {} # obj => [callback_id1, callback_id2, ...]
10
+ end
11
+
12
+ def register(object, callback)
13
+ id = @next_id
14
+ @next_id += 1
15
+ @callbacks[id] = callback
16
+ (@obj_map[object] ||= []) << id
17
+ return "#{@prefix}#{id}"
18
+ end
19
+
20
+ def unregister(object)
21
+ if arr = @obj_map.delete(object)
22
+ arr.each {|id| @callbacks.delete(id) }
23
+ end
24
+ end
25
+
26
+ #
27
+ # NOTE that if fields named "xxx" and "xxx.yyy" occur, the value of
28
+ # @fields['xxx'] is { nil => ..., 'yyy' => ... }. This is required
29
+ # to make image buttons work correctly.
30
+ #
31
+ def prepare_triggered(ids_and_values)
32
+ @triggered = {}
33
+ ids_and_values.each do |id, value|
34
+ if id =~ /^#{@prefix}(\d+)([.](.*))?$/
35
+ id, suffix = Integer($1), $3
36
+ next unless @callbacks[id]
37
+
38
+ if @triggered[id].kind_of?(Hash)
39
+ @triggered[id][suffix] = value
40
+ elsif suffix
41
+ @triggered[id] = {nil => @triggered[id], suffix => value}
42
+ else
43
+ @triggered[id] = value
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ def reset_triggered
50
+ @triggered = nil
51
+ end
52
+
53
+ def each_triggered(object)
54
+ if ary = @obj_map[object]
55
+ ary.each do |id|
56
+ yield @callbacks[id], @triggered[id] if @triggered.has_key?(id)
57
+ end
58
+ end
59
+ end
60
+
61
+ end # class CallbackRegistry
62
+
63
+ class Callbacks
64
+ attr_reader :input_callbacks
65
+ attr_reader :action_callbacks
66
+
67
+ def initialize
68
+ @input_callbacks = CallbackRegistry.new("")
69
+ @action_callbacks = CallbackRegistry.new("a")
70
+ end
71
+
72
+ def unregister(object)
73
+ @input_callbacks.unregister(object)
74
+ @action_callbacks.unregister(object)
75
+ end
76
+
77
+ def with_triggered(ids_and_values)
78
+ @input_callbacks.prepare_triggered(ids_and_values)
79
+ @action_callbacks.prepare_triggered(ids_and_values)
80
+ yield
81
+ ensure
82
+ @input_callbacks.reset_triggered
83
+ @action_callbacks.reset_triggered
84
+ end
85
+
86
+ end # class Callbacks
87
+
88
+ end # module Wee
@@ -0,0 +1,141 @@
1
+ require 'wee/presenter'
2
+ require 'wee/decoration'
3
+ require 'wee/call_answer'
4
+
5
+ module Wee
6
+
7
+ #
8
+ # The base class of all components. You should at least overwrite method
9
+ # #render in your own subclasses.
10
+ #
11
+ class Component < Presenter
12
+
13
+ #
14
+ # Initializes a newly created component.
15
+ #
16
+ # Call this method from your own components' <i>initialize</i> method using
17
+ # +super+, before setting up anything else!
18
+ #
19
+ def initialize() # :notnew:
20
+ @decoration = self
21
+ @children = nil
22
+ end
23
+
24
+ #
25
+ # This method renders the content of the component.
26
+ #
27
+ # *OVERWRITE* this method in your own component classes to implement the
28
+ # view. By default this method does nothing!
29
+ #
30
+ # [+r+]
31
+ # An instance of class <tt>renderer_class()</tt>
32
+ #
33
+ def render(r)
34
+ end
35
+
36
+ #
37
+ # Process and invoke all callbacks specified for this component and all of
38
+ # it's child components.
39
+ #
40
+ def process_callbacks(callbacks)
41
+ callbacks.input_callbacks.each_triggered(self) do |callback, value|
42
+ callback.call(value)
43
+ end
44
+
45
+ # process callbacks of all children
46
+ each_child do |child|
47
+ child.decoration.process_callbacks(callbacks)
48
+ end
49
+
50
+ callbacks.action_callbacks.each_triggered(self) do |callback, value|
51
+ callback.call
52
+ session.send_response(nil) # prematurely end callback processing
53
+ end
54
+ end
55
+
56
+ #
57
+ # Take snapshots of objects that should correctly be backtracked.
58
+ #
59
+ # Backtracking means that you can go back in time of the components' state.
60
+ # Therefore it is neccessary to take snapshots of those objects that want to
61
+ # participate in backtracking. Taking snapshots of the whole component tree
62
+ # would be too expensive and unflexible. Note that methods
63
+ # <i>take_snapshot</i> and <i>restore_snapshot</i> are called for those
64
+ # objects to take the snapshot (they behave like <i>marshal_dump</i> and
65
+ # <i>marshal_load</i>). Overwrite them if you want to define special
66
+ # behaviour.
67
+ #
68
+ # For example if you dynamically add children to your component, you might
69
+ # want to backtrack the children array:
70
+ #
71
+ # def backtrack(state)
72
+ # super
73
+ # backtrack_children(state)
74
+ # end
75
+ #
76
+ # By default only the decoration chain is backtracked. This is
77
+ # required to correctly backtrack called components. To disable
78
+ # backtracking of the decorations, change method
79
+ # Component#backtrack_decoration to a no-operation:
80
+ #
81
+ # def backtrack_decoration(state)
82
+ # # nothing here
83
+ # end
84
+ #
85
+ # [+state+]
86
+ # An object of class State
87
+ #
88
+ def backtrack(state)
89
+ backtrack_decoration(state)
90
+ each_child do |child|
91
+ child.decoration.backtrack(state)
92
+ end
93
+ end
94
+
95
+ protected
96
+
97
+ def backtrack_decoration(state)
98
+ state.add_ivar(self, :@decoration, @decoration)
99
+ end
100
+
101
+ def backtrack_children(state)
102
+ state.add_ivar(self, :@children, (@children and @children.dup))
103
+ end
104
+
105
+ #
106
+ # Iterates over all direct child components.
107
+ #
108
+ def each_child(&block)
109
+ @children.each(&block) if @children
110
+ end
111
+
112
+ #
113
+ # Add a child to the component. Example:
114
+ #
115
+ # class YourComponent < Wee::Component
116
+ # def initialize
117
+ # super()
118
+ # add_child ChildComponent.new
119
+ # end
120
+ # end
121
+ #
122
+ # If you dynamically add child components to a component at run-time (not in
123
+ # initialize), then you should consider to backtrack the children array (of
124
+ # course only if you want backtracking at all):
125
+ #
126
+ # def backtrack(state)
127
+ # super
128
+ # state.add(self.children)
129
+ # end
130
+ #
131
+ def add_child(child)
132
+ (@children ||= []) << child
133
+ child
134
+ end
135
+
136
+ include Wee::DecorationMixin
137
+ include Wee::CallAnswerMixin
138
+
139
+ end # class Component
140
+
141
+ end # module Wee