rad_core 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) hide show
  1. data/Rakefile +4 -3
  2. data/lib/components/config.rb +6 -0
  3. data/lib/components/controller.rb +5 -0
  4. data/lib/components/controller.yml +3 -0
  5. data/lib/components/conveyors.rb +7 -0
  6. data/lib/components/environment.rb +5 -0
  7. data/lib/components/environment.yml +3 -0
  8. data/lib/components/flash.rb +5 -0
  9. data/lib/components/html.rb +4 -0
  10. data/lib/components/html.yml +3 -0
  11. data/lib/components/http.rb +6 -0
  12. data/lib/components/http.yml +13 -0
  13. data/lib/components/logger.rb +5 -0
  14. data/lib/components/mailer.rb +9 -0
  15. data/lib/components/remote.rb +4 -0
  16. data/lib/components/router.rb +13 -0
  17. data/lib/components/router.yml +2 -0
  18. data/lib/components/template.rb +8 -0
  19. data/lib/components/template.yml +1 -0
  20. data/lib/components/web.rb +8 -0
  21. data/lib/components/workspace.rb +1 -0
  22. data/lib/rad/{support → _support}/active_support/locales/en/actionpack.yml +0 -0
  23. data/lib/rad/{support → _support}/active_support/locales/en/activesupport.yml +0 -0
  24. data/lib/rad/_support/active_support/locales/ru/actionview.yml +162 -0
  25. data/lib/rad/_support/active_support/locales/ru/activesupport.yml +16 -0
  26. data/lib/rad/_support/active_support/locales/ru/datetime.yml +49 -0
  27. data/lib/rad/{support → _support}/active_support/micelaneous.rb +0 -0
  28. data/lib/rad/{support → _support}/active_support/time.rb +0 -0
  29. data/lib/rad/{support → _support}/active_support.rb +14 -2
  30. data/lib/rad/{support → _support}/addressable.rb +0 -0
  31. data/lib/rad/_support/callbacks.rb +166 -0
  32. data/lib/rad/_support/class_loader.rb +9 -0
  33. data/lib/rad/_support/encoding.rb +3 -0
  34. data/lib/rad/_support/exception.rb +45 -0
  35. data/lib/rad/_support/extensions.rb +20 -0
  36. data/lib/rad/_support/filters.rb +32 -0
  37. data/lib/rad/{support → _support}/hacks_and_fixes.rb +0 -0
  38. data/lib/rad/{support → _support}/mime.rb +6 -0
  39. data/lib/rad/{support → _support}/module.rb +7 -9
  40. data/lib/rad/_support/require.rb +62 -0
  41. data/lib/rad/{support → _support}/rson.rb +0 -0
  42. data/lib/rad/{support → _support}/ruby_ext_with_active_support.rb +0 -0
  43. data/lib/rad/{support → _support}/string.rb +9 -1
  44. data/lib/rad/controller/_abstract/micelaneous.rb +27 -0
  45. data/lib/rad/controller/_abstract/render.rb +159 -0
  46. data/lib/rad/controller/_abstract/responder.rb +13 -0
  47. data/lib/rad/controller/_abstract.rb +37 -0
  48. data/lib/rad/controller/_context.rb +15 -0
  49. data/lib/rad/controller/_http.rb +50 -0
  50. data/lib/rad/controller/_require.rb +19 -0
  51. data/lib/rad/controller/abstract.rb +1 -0
  52. data/lib/rad/controller/context.rb +1 -0
  53. data/lib/rad/controller/http.rb +1 -0
  54. data/lib/rad/controller/processors/controller_caller.rb +22 -24
  55. data/lib/rad/controller/processors/controller_error_handling.rb +46 -48
  56. data/lib/rad/controller/processors/controller_logger.rb +7 -9
  57. data/lib/rad/controller.rb +1 -28
  58. data/lib/rad/conveyors/_conveyor.rb +73 -0
  59. data/lib/rad/conveyors/_conveyors.rb +19 -0
  60. data/lib/rad/conveyors/_params.rb +10 -0
  61. data/lib/rad/conveyors/_processor.rb +13 -0
  62. data/lib/rad/conveyors/_require.rb +10 -0
  63. data/lib/rad/conveyors/_workspace.rb +34 -0
  64. data/lib/rad/conveyors/params.rb +1 -0
  65. data/lib/rad/conveyors/processor.rb +1 -0
  66. data/lib/rad/conveyors/processors/conveyor_logger.rb +23 -0
  67. data/lib/rad/conveyors/workspace.rb +1 -0
  68. data/lib/rad/conveyors.rb +1 -0
  69. data/lib/rad/core_web/_controller_micelaneous_helper.rb +17 -0
  70. data/lib/rad/core_web/_require.rb +25 -0
  71. data/lib/rad/core_web/_router/abstract_routing_helper.rb +20 -0
  72. data/lib/rad/core_web/_router/controller_routing_helper.rb +56 -0
  73. data/lib/rad/core_web/_router/view_routing_helper.rb +57 -0
  74. data/lib/rad/environment/_config.rb +27 -0
  75. data/lib/rad/environment/_environment.rb +17 -0
  76. data/lib/rad/environment/_files_helper.rb +55 -0
  77. data/lib/rad/environment/_logger.rb +53 -0
  78. data/lib/rad/environment/_require.rb +24 -0
  79. data/lib/rad/environment/config.rb +1 -111
  80. data/lib/rad/environment.rb +1 -55
  81. data/lib/{rad_core → rad}/gems.rb +2 -3
  82. data/lib/rad/html/_flash.rb +40 -0
  83. data/lib/rad/html/_helpers/basic_html_helper.rb +72 -0
  84. data/lib/rad/html/_helpers/flash_helper.rb +3 -0
  85. data/lib/rad/html/_helpers/form_helper.rb +114 -0
  86. data/lib/rad/html/_helpers/html_helper.rb +3 -0
  87. data/lib/rad/html/_helpers/javascript_helper.rb +27 -0
  88. data/lib/rad/html/_helpers/model_helper.rb +143 -0
  89. data/lib/rad/html/_require.rb +15 -0
  90. data/lib/rad/html/processors/prepare_flash.rb +22 -23
  91. data/lib/rad/html/processors/scoped_params.rb +18 -21
  92. data/lib/rad/html.rb +1 -26
  93. data/lib/rad/http/_http.rb +11 -0
  94. data/lib/rad/http/_http_adapter.rb +44 -0
  95. data/lib/rad/http/_request.rb +50 -0
  96. data/lib/rad/http/_require.rb +33 -0
  97. data/lib/rad/http/_response.rb +84 -0
  98. data/lib/rad/http/{support → _support}/rack/fixes.rb +0 -0
  99. data/lib/rad/http/_support/rack/rack_adapter.rb +57 -0
  100. data/lib/rad/http/processors/evaluate_format.rb +16 -19
  101. data/lib/rad/http/processors/http_logger.rb +10 -12
  102. data/lib/rad/http/processors/http_writer.rb +24 -26
  103. data/lib/rad/http/processors/prepare_params.rb +19 -18
  104. data/lib/rad/http/request.rb +1 -0
  105. data/lib/rad/http/response.rb +1 -0
  106. data/lib/rad/http.rb +1 -48
  107. data/lib/rad/mailer/_letter.rb +28 -0
  108. data/lib/rad/mailer/_mailer.rb +13 -0
  109. data/lib/rad/mailer/_mailer_controller.rb +38 -0
  110. data/lib/rad/mailer/_require.rb +7 -0
  111. data/lib/rad/mailer/mailer_controller.rb +1 -0
  112. data/lib/rad/mailer/processors/letter_builder.rb +34 -0
  113. data/lib/rad/mailer.rb +1 -0
  114. data/lib/rad/profiles/mailer.rb +5 -0
  115. data/lib/rad/profiles/web.rb +29 -52
  116. data/lib/rad/remote/_remote_controller.rb +9 -0
  117. data/lib/rad/remote/_require.rb +6 -0
  118. data/lib/rad/remote/processors/remote_caller.rb +44 -46
  119. data/lib/rad/remote/processors/remote_logger.rb +8 -10
  120. data/lib/rad/remote/remote_controller.rb +1 -0
  121. data/lib/rad/remote.rb +1 -9
  122. data/lib/rad/router/_abstract_router.rb +50 -0
  123. data/lib/rad/router/_alias_router.rb +124 -0
  124. data/lib/rad/router/_basic_router.rb +72 -0
  125. data/lib/rad/router/_configurator.rb +19 -0
  126. data/lib/rad/router/_core_routing_helper.rb +39 -0
  127. data/lib/rad/router/_default_format_processor.rb +10 -0
  128. data/lib/rad/router/_object_router.rb +184 -0
  129. data/lib/rad/router/_require.rb +31 -0
  130. data/lib/rad/router/_restful_router.rb +124 -0
  131. data/lib/rad/router/_router.rb +294 -0
  132. data/lib/rad/router/_simple_router.rb +21 -0
  133. data/lib/rad/router/abstract_router.rb +1 -0
  134. data/lib/rad/router/alias_router.rb +1 -0
  135. data/lib/rad/router/configurator.rb +1 -0
  136. data/lib/rad/router/micelaneous_router.rb +1 -0
  137. data/lib/rad/router/object_router.rb +1 -0
  138. data/lib/rad/router/processors/router.rb +23 -0
  139. data/lib/rad/router/restful_router.rb +1 -0
  140. data/lib/rad/{html/include_into_controller.rb → router/simple_router.rb} +0 -0
  141. data/lib/rad/router.rb +1 -29
  142. data/lib/rad/spec/controller.rb +20 -11
  143. data/lib/rad/spec/environment.rb +22 -38
  144. data/lib/rad/spec/http.rb +13 -86
  145. data/lib/rad/spec/http_controller.rb +105 -0
  146. data/lib/rad/spec/mailer.rb +27 -0
  147. data/lib/rad/spec/remote.rb +2 -2
  148. data/lib/rad/spec/router.rb +9 -11
  149. data/lib/rad/spec/template.rb +8 -2
  150. data/lib/rad/spec/xhtml.rb +0 -2
  151. data/lib/rad/spec.rb +4 -2
  152. data/lib/rad/template/_context.rb +92 -0
  153. data/lib/rad/template/_relative_path_resolver.rb +8 -0
  154. data/lib/rad/template/_require.rb +15 -0
  155. data/lib/rad/template/{support → _support}/tilt.rb +0 -0
  156. data/lib/rad/template/{support → _support}/tilt_fixes.rb +0 -0
  157. data/lib/rad/template/_template.rb +175 -0
  158. data/lib/rad/template/template_context.rb +1 -62
  159. data/lib/rad/template.rb +1 -25
  160. data/lib/rad.rb +8 -0
  161. data/readme.md +40 -12
  162. data/spec/controller/{abstract_controller_spec → abstract_spec}/views/OperationsOrderSpec/action.erb +0 -0
  163. data/spec/controller/{abstract_controller_spec → abstract_spec}/views/ViewVariablesSpec/action.erb +0 -0
  164. data/spec/controller/abstract_spec.rb +126 -0
  165. data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/NamespaceSpec/ClassSpec}/show.erb +0 -0
  166. data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/actions.erb +0 -0
  167. data/spec/controller/{controller_context_spec/views/NamespaceSpec/ClassSpec → context_spec/views/item_spec}/show.erb +0 -0
  168. data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/update.erb +0 -0
  169. data/spec/controller/{controller_context_spec → context_spec}/views/namespace_spec/class_spec/update.erb +0 -0
  170. data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/actions.erb +0 -0
  171. data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/show.erb +0 -0
  172. data/spec/controller/context_spec.rb +123 -0
  173. data/spec/controller/error_handling_spec.rb +21 -27
  174. data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperMethodSpec/action.erb +0 -0
  175. data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperSpec/action.erb +0 -0
  176. data/spec/controller/{controller_helper_spec.rb → helper_spec.rb} +7 -13
  177. data/spec/controller/{http_controller_spec.rb → http_spec.rb} +17 -23
  178. data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/action.erb +0 -0
  179. data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/custom_template.erb +0 -0
  180. data/spec/controller/{controller_render_spec/views/AnotherActionSpec → render_spec/views/another_action_spec}/another_action.erb +0 -0
  181. data/spec/controller/{controller_render_spec/views/AnotherLayout → render_spec/views/another_layout}/action.erb +0 -0
  182. data/spec/controller/{controller_render_spec/views/ForbidPartialAsActionSpec → render_spec/views/forbid_partial_as_action_spec}/_action.erb +0 -0
  183. data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.html.erb +0 -0
  184. data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.js.erb +0 -0
  185. data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_with_layout.erb +0 -0
  186. data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_without_layout.erb +0 -0
  187. data/spec/controller/{controller_render_spec/views/LayoutSpec → render_spec/views/layout_spec}/action.erb +0 -0
  188. data/spec/controller/{controller_render_spec → render_spec}/views/layouts/admin.erb +0 -0
  189. data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.html.erb +0 -0
  190. data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.js.erb +0 -0
  191. data/spec/controller/{controller_render_spec/views/MultipleActions → render_spec/views/multiple_actions}/actions.haml +0 -0
  192. data/spec/controller/render_spec/views/relative_spec/a/form.erb +1 -0
  193. data/spec/controller/render_spec/views/relative_spec/a/show.erb +1 -0
  194. data/spec/controller/render_spec/views/relative_spec/b/form.erb +1 -0
  195. data/spec/controller/{controller_render_spec → render_spec}/views/some_template.erb +0 -0
  196. data/spec/controller/{controller_render_spec → render_spec}/views/standalone.html.erb +0 -0
  197. data/spec/controller/{controller_render_spec.rb → render_spec.rb} +37 -27
  198. data/spec/{conveyor/conveyor_spec.rb → conveyors/conveyors_spec.rb} +36 -14
  199. data/spec/environment/config_spec.rb +13 -21
  200. data/spec/environment/environment_spec.rb +14 -41
  201. data/spec/environment/logger_spec.rb +4 -13
  202. data/spec/environment/minimal_app_spec/app.rb +1 -1
  203. data/spec/environment/minimal_app_spec.rb +12 -14
  204. data/spec/environment/standard_app_spec/app/lib/app/init.rb +1 -1
  205. data/spec/environment/standard_app_spec/plugin_a/lib/plugin_a/init.rb +1 -1
  206. data/spec/environment/standard_app_spec.rb +17 -25
  207. data/spec/html/basic_html_helper_spec.rb +7 -4
  208. data/spec/html/form_helper_spec.rb +5 -5
  209. data/spec/html/javascript_helper_spec.rb +9 -5
  210. data/spec/html/model_helper_spec.rb +9 -6
  211. data/spec/html/scoped_params_spec.rb +2 -2
  212. data/spec/html/spec_helper.rb +16 -24
  213. data/spec/http/http_spec.rb +14 -35
  214. data/spec/http/micelaneous_spec.rb +3 -3
  215. data/spec/{mail → mailer}/mail_controller_spec/views/body_template_spec/signup.erb +0 -0
  216. data/spec/{mail → mailer}/mail_controller_spec.rb +36 -12
  217. data/spec/mailer/spec_helper.rb +5 -0
  218. data/spec/remote/remote_spec.rb +23 -8
  219. data/spec/router/alias_router_spec.rb +29 -30
  220. data/spec/router/basic_router_spec.rb +44 -0
  221. data/spec/router/configurator_spec.rb +9 -6
  222. data/spec/router/integration_spec.rb +10 -7
  223. data/spec/router/object_router_spec.rb +186 -0
  224. data/spec/router/persistent_params_spec.rb +4 -4
  225. data/spec/router/restful_router_spec.rb +61 -53
  226. data/spec/router/{basic_spec.rb → router_spec.rb} +26 -23
  227. data/spec/router/routing_helper_spec.rb +5 -6
  228. data/spec/spec_helper.rb +4 -0
  229. data/spec/support/callbacks_spec.rb +1 -1
  230. data/spec/support/filters_spec.rb +2 -2
  231. data/spec/support/spec_helper.rb +1 -1
  232. data/spec/template/template_spec/views/format_for_partials/dialog.js.erb +1 -1
  233. data/spec/template/template_spec/views/nested/format/a.erb +1 -1
  234. data/spec/template/template_spec/views/nested/format/b.js.erb +1 -0
  235. data/spec/template/template_spec/views/nesting_format/dialog.js.erb +1 -1
  236. data/spec/template/template_spec.rb +62 -48
  237. data/spec/template/tilt_spec/views/concat_and_capture.erb +1 -1
  238. data/spec/template/tilt_spec/views/concat_and_capture.haml +1 -1
  239. data/spec/template/tilt_spec.rb +17 -19
  240. data/spec/{integration → web}/basic_spec/views/smoke_test_spec/action.erb +0 -0
  241. data/spec/{integration → web}/basic_spec.rb +31 -12
  242. data/spec/{integration → web}/controller_routing_helper_spec.rb +13 -11
  243. data/spec/{integration → web}/flash_spec.rb +57 -42
  244. data/spec/{integration → web}/spec_helper_spec.rb +11 -10
  245. data/spec/{integration → web}/view_routing_helper_spec.rb +44 -36
  246. metadata +338 -318
  247. data/lib/rad/controller/abstract_controller/micelaneous.rb +0 -31
  248. data/lib/rad/controller/abstract_controller/render.rb +0 -160
  249. data/lib/rad/controller/abstract_controller/responder.rb +0 -17
  250. data/lib/rad/controller/abstract_controller.rb +0 -64
  251. data/lib/rad/controller/controller_context.rb +0 -15
  252. data/lib/rad/controller/http_controller.rb +0 -48
  253. data/lib/rad/conveyor/conveyor.rb +0 -74
  254. data/lib/rad/conveyor/conveyors.rb +0 -20
  255. data/lib/rad/conveyor/params.rb +0 -14
  256. data/lib/rad/conveyor/processor.rb +0 -68
  257. data/lib/rad/conveyor/processors/conveyor_logger.rb +0 -25
  258. data/lib/rad/conveyor/workspace.rb +0 -36
  259. data/lib/rad/conveyor.rb +0 -29
  260. data/lib/rad/environment/dependency_resolver.rb +0 -107
  261. data/lib/rad/environment/environment.rb +0 -29
  262. data/lib/rad/environment/files_helper.rb +0 -55
  263. data/lib/rad/environment/logger.rb +0 -21
  264. data/lib/rad/html/flash.rb +0 -42
  265. data/lib/rad/html/helpers/basic_html_helper.rb +0 -83
  266. data/lib/rad/html/helpers/flash_helper.rb +0 -5
  267. data/lib/rad/html/helpers/form_helper.rb +0 -115
  268. data/lib/rad/html/helpers/html_helper.rb +0 -5
  269. data/lib/rad/html/helpers/javascript_helper.rb +0 -18
  270. data/lib/rad/html/helpers/model_helper.rb +0 -135
  271. data/lib/rad/http/http.rb +0 -21
  272. data/lib/rad/http/http_adapter.rb +0 -36
  273. data/lib/rad/http/middleware/static_files.rb +0 -21
  274. data/lib/rad/http/support/rack/rack_adapter.rb +0 -67
  275. data/lib/rad/http/support/rack/request.rb +0 -42
  276. data/lib/rad/http/support/rack/response.rb +0 -86
  277. data/lib/rad/integration/controller_micelaneous_helper.rb +0 -19
  278. data/lib/rad/integration/router/abstract_routing_helper.rb +0 -22
  279. data/lib/rad/integration/router/controller_routing_helper.rb +0 -58
  280. data/lib/rad/integration/router/view_routing_helper.rb +0 -104
  281. data/lib/rad/integration.rb +0 -30
  282. data/lib/rad/mail/letter.rb +0 -30
  283. data/lib/rad/mail/mail_controller.rb +0 -31
  284. data/lib/rad/mail/mailer.rb +0 -23
  285. data/lib/rad/mail/processors/letter_builder.rb +0 -36
  286. data/lib/rad/mail.rb +0 -15
  287. data/lib/rad/profiles/mail.rb +0 -16
  288. data/lib/rad/profiles/web_require.rb +0 -5
  289. data/lib/rad/remote/remote.rb +0 -15
  290. data/lib/rad/router/core/configurator.rb +0 -25
  291. data/lib/rad/router/core/core_routing_helper.rb +0 -41
  292. data/lib/rad/router/core/default_format_processor.rb +0 -12
  293. data/lib/rad/router/core/processors/router.rb +0 -29
  294. data/lib/rad/router/core/router.rb +0 -271
  295. data/lib/rad/router/core/simple_router.rb +0 -23
  296. data/lib/rad/router/routers/abstract_router.rb +0 -62
  297. data/lib/rad/router/routers/alias_router.rb +0 -113
  298. data/lib/rad/router/routers/restful_router.rb +0 -113
  299. data/lib/rad/spec/mail.rb +0 -31
  300. data/lib/rad/spec/view.rb +0 -10
  301. data/lib/rad/support/buffered_logger.rb +0 -44
  302. data/lib/rad/support/callbacks.rb +0 -168
  303. data/lib/rad/support/exception.rb +0 -31
  304. data/lib/rad/support/filters.rb +0 -34
  305. data/lib/rad/support/format.rb +0 -17
  306. data/lib/rad/support/micon.rb +0 -13
  307. data/lib/rad/support.rb +0 -63
  308. data/lib/rad/template/template.rb +0 -250
  309. data/spec/controller/abstract_controller_spec.rb +0 -132
  310. data/spec/controller/controller_context_spec.rb +0 -123
  311. data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/action.erb +0 -1
  312. data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/another_action.erb +0 -1
  313. data/spec/controller/spec_helper.rb +0 -19
  314. data/spec/conveyor/spec_helper.rb +0 -3
  315. data/spec/environment/config_spec/config.default.yml +0 -3
  316. data/spec/environment/config_spec/config.development.yml +0 -3
  317. data/spec/environment/config_spec/config.yml +0 -5
  318. data/spec/environment/spec_helper.rb +0 -1
  319. data/spec/http/http_spec/app/lib/app/init.rb +0 -10
  320. data/spec/http/http_spec/app/runtime/public/emptygit +0 -0
  321. data/spec/http/http_spec/plugin_a/lib/plugin_a/init.rb +0 -0
  322. data/spec/http/http_spec/plugin_b/lib/plugin_b/init.rb +0 -5
  323. data/spec/http/http_spec/plugin_b/static/emptygit +0 -0
  324. data/spec/http/spec_helper.rb +0 -5
  325. data/spec/integration/spec_helper.rb +0 -5
  326. data/spec/mail/spec_helper.rb +0 -7
  327. data/spec/remote/spec_helper.rb +0 -17
  328. data/spec/router/spec_helper.rb +0 -20
  329. data/spec/template/spec_helper.rb +0 -6
  330. data/spec/template/template_spec/views/nested/format/b.erb +0 -1
@@ -1,107 +0,0 @@
1
- # module Rad
2
- # class DependencyResolver
3
- # class Dependency
4
- # attr_accessor :name, :block, :before, :after
5
- #
6
- # def initialize name, block
7
- # @name, @block = name, block
8
- # @before, @after = [], []
9
- # end
10
- #
11
- # def inspect
12
- # "#<#{name} #{before.inspect}, #{after.inspect}>"
13
- # end
14
- # end
15
- #
16
- # def dependencies; @dependencies ||= {} end
17
- #
18
- # #
19
- # # Define dependency
20
- # #
21
- # def run name, options = {}, &block
22
- # options = options.to_openobject
23
- # # raise "Invalid usage, you must specify :after or :before!" unless options.before? or options.after?
24
- # d = Dependency.new name, block
25
- #
26
- # if options.before?
27
- # add_dependency d, :before, options.before.must_be.present
28
- # elsif options.after?
29
- # add_dependency d, :after, options.after.must_be.present
30
- # else
31
- # add_dependency d, nil, nil
32
- # end
33
- # end
34
- #
35
- #
36
- # #
37
- # # Call dependencies
38
- # #
39
- # def call name, &block
40
- # return unless dep = dependencies[name]
41
- #
42
- # # before
43
- # callees = []
44
- # dep_lists = [dep.before]
45
- # while !dep_lists.empty?
46
- # dep_lists.each do |list|
47
- # callees << list
48
- # end
49
- #
50
- # dep_lists = next_level dep_lists, :before
51
- # end
52
- # call_all callees.reverse
53
- #
54
- # # call
55
- # dep.block.call if dep.block
56
- #
57
- # # after
58
- # dep_lists = [dep.after]
59
- # while !dep_lists.empty?
60
- # call_all dep_lists
61
- #
62
- # dep_lists = next_level dep_lists, :after
63
- # end
64
- # end
65
- #
66
- # protected
67
- # def add_dependency dep, type, ref
68
- # raise "Dependency '#{dep.name}' already defined!" if dependencies.include? dep.name
69
- # dependencies[dep.name] = dep
70
- #
71
- # # add back reference
72
- # if type
73
- # catch :found do
74
- # dep_lists = [dependencies.values]
75
- # while !dep_lists.empty?
76
- # dep_lists.each do |list|
77
- # list.each do |d|
78
- # if d.name == ref
79
- # d.send(type) << dep
80
- # throw :found
81
- # end
82
- # end
83
- # end
84
- #
85
- # dep_lists = next_level dep_lists, type
86
- # end
87
- #
88
- # raise "Dependency '#{ref}' referenced from '#{dep.name}' not found!"
89
- # end
90
- # end
91
- # end
92
- #
93
- # def next_level dep_lists, type
94
- # r = []
95
- # dep_lists.each do |list|
96
- # list.each do |d|
97
- # r << d.send(type)
98
- # end
99
- # end
100
- # r
101
- # end
102
- #
103
- # def call_all list_of_lists
104
- # list_of_lists.each{|list| list.each{|d| d.block.call if d.block}}
105
- # end
106
- # end
107
- # end
@@ -1,29 +0,0 @@
1
- module Rad
2
- class Environment
3
- inject logger: :logger, config: :config
4
-
5
- class << self
6
- inject logger: :logger, config: :config
7
-
8
- # def initialize_runtime runtime_dir, environment = nil
9
- # init_file_path = "#{runtime_dir}/init.rb"
10
- # load init_file_path if File.exist? init_file_path
11
- #
12
- # Micon.after :config do |config|
13
- # config.runtime_dir = runtime_dir
14
- #
15
- # config.merge_config! "#{runtime_dir}/config/config.yml"
16
- # end
17
- # end
18
- #
19
- # def initialize_plugin plugin_dir
20
- # init_file_path = "#{plugin_dir}/init.rb"
21
- # load init_file_path if File.exist? init_file_path
22
- #
23
- # Micon.after :config do |config|
24
- # config.merge_config! "#{plugin_dir}/config/config.yml"
25
- # end
26
- # end
27
- end
28
- end
29
- end
@@ -1,55 +0,0 @@
1
- module Rad
2
- module FilesHelper
3
- def directories
4
- $LOAD_PATH
5
- end
6
-
7
- def file_exist? path, directories = nil
8
- find_files(path).size > 0
9
- end
10
-
11
- def find_files fname, directories = nil
12
- directories ||= self.directories
13
- FilesHelper.find_files fname, directories
14
- end
15
-
16
- def find_files_without_cache fname, directories = nil
17
- # directories ||= self.directories
18
- FilesHelper.find_files_without_cache fname, directories
19
- end
20
-
21
- def find_file fname, directories = nil
22
- files = find_files(fname, directories)
23
- raise "File '#{fname}' not found!" if files.size == 0
24
- raise "Found multiple files for '#{fname}'" if files.size > 1
25
- files.first
26
- end
27
-
28
- def find_files_by_pattern_without_cache pattern, directories = nil
29
- directories ||= self.directories
30
- patterns = directories.to_a.collect{|d| "#{d}#{pattern}"}
31
- Dir.glob patterns
32
- end
33
- alias_method :find_files_by_pattern, :find_files_by_pattern_without_cache
34
-
35
- def find_file_by_pattern pattern
36
- files = find_files_by_pattern(pattern)
37
- raise "File '#{pattern}' not found!" if files.size == 0
38
- raise "Found multiple files for '#{pattern}'" if files.size > 1
39
- files.first
40
- end
41
-
42
- class << self
43
- # don't move this class method to module, because there will be then
44
- # multiple cache for every object that includes it.
45
- def find_files fname, directories = nil
46
- fname.must =~ /\//
47
- directories.must_be.present # || raise('directories ')= self.directories
48
- files = directories.collect{|dir| "#{dir}#{fname}"}
49
- files.select{|f| File.exist? f}
50
- end
51
- cache_method_with_params_in_production :find_files
52
- end
53
- end
54
- end
55
-
@@ -1,21 +0,0 @@
1
- rad.register :logger do
2
- if defined?(SILENCE_LOGGER)
3
- logger = Logger.new nil
4
- else
5
- config = rad[:config]
6
- if config and config.runtime_dir? and File.exist?("#{config.runtime_dir}/log")
7
- logger = ActiveSupport::BufferedLogger.new rad.config.log_path
8
- logger.level = ActiveSupport::BufferedLogger.const_get config.log_level.to_s.upcase
9
- # logger.auto_flushing = false if config.production? and !config.stdout_logger(false)
10
- elsif config and config.test?
11
- logger = Logger.new nil
12
- elsif config
13
- logger = Logger.new STDOUT
14
- logger.warn "No log folder!"
15
- else
16
- logger = Logger.new STDOUT
17
- logger.warn "Config not initialized!"
18
- end
19
- end
20
- logger
21
- end
@@ -1,42 +0,0 @@
1
- module Rad
2
- class Flash < OpenObject
3
- attr_accessor :previous_messages, :current_messages
4
-
5
- def initialize format, previous_messages = {}
6
- self.current_messages, self.previous_messages = {}, previous_messages
7
- @keep = false
8
- end
9
-
10
- def [] key
11
- key = key.to_s
12
-
13
- if keep?
14
- previous_messages[key]
15
- else
16
- current_messages[key] || previous_messages[key]
17
- end
18
- end
19
-
20
- def []= key, value
21
- current_messages[key.to_s] = value.to_s
22
- end
23
-
24
- def keep!
25
- @keep = true
26
- self
27
- end
28
-
29
- def keep?
30
- !!@keep
31
- end
32
-
33
- def messages_for_next_request
34
- if keep?
35
- current_messages
36
- else
37
- {}
38
- end
39
- end
40
-
41
- end
42
- end
@@ -1,83 +0,0 @@
1
- module Rad
2
- module BasicHtmlHelper
3
- BOOLEAN_ATTRIBUTES = %w(disabled readonly multiple checked autobuffer
4
- autoplay controls loop selected hidden scoped async
5
- defer reversed ismap seemless muted required
6
- autofocus novalidate formnovalidate open).to_set
7
- BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map {|attr| attr.to_sym })
8
-
9
-
10
- #
11
- # authenticity_token
12
- #
13
- def authenticity_token; workspace.request.session['authenticity_token'] end
14
-
15
-
16
- #
17
- # JavaScript & StyleSheets
18
- #
19
- def stylesheet_link_tag *stylesheets
20
- Array(stylesheets).collect{|ssheet|
21
- tag :link, '', href: "#{config && config.url_root!}#{ssheet}", media: "screen", rel: "stylesheet", type: "text/css"
22
- }.join("\n")
23
- end
24
-
25
-
26
- #
27
- # Assets
28
- #
29
- def image_tag src, opt = {}
30
- opt[:src] = src
31
- tag :img, '', opt
32
- end
33
-
34
-
35
- #
36
- # Common HTML tags
37
- #
38
- def label_tag name, text, options = {}
39
- tag :label, text, options.merge(for: name)
40
- end
41
-
42
-
43
- #
44
- # Special
45
- #
46
- def tag name, content_or_options_with_block = nil, options = nil, escape = true, &block
47
- if block_given?
48
- options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
49
- content = capture(&block)
50
- concat "<#{name}#{tag_options(options)}>#{content}</#{name}>"
51
- else
52
- content = content_or_options_with_block
53
- "<#{name}#{tag_options(options)}>#{content}</#{name}>"
54
- end
55
- end
56
-
57
- # instance_methods(false).each do |m|
58
- # alias_method "html_#{m}", m
59
- # end
60
-
61
- # Escape
62
- def h obj; obj.to_s.html_escape end
63
-
64
- protected
65
-
66
- def tag_options options
67
- return "" unless options
68
- options.must_be.a Hash
69
- unless options.blank?
70
- attrs = []
71
- options.each_pair do |key, value|
72
- if BOOLEAN_ATTRIBUTES.include?(key)
73
- attrs << %(#{key}="#{key}") if value
74
- elsif !value.nil?
75
- final_value = value.is_a?(Array) ? value.join(" ") : value
76
- attrs << %(#{key}="#{final_value}")
77
- end
78
- end
79
- " #{attrs.sort * ' '}" unless attrs.empty?
80
- end
81
- end
82
- end
83
- end
@@ -1,5 +0,0 @@
1
- module Rad
2
- module FlashHelper
3
- inject flash: :flash
4
- end
5
- end
@@ -1,115 +0,0 @@
1
- module Rad
2
- module FormHelper
3
- #
4
- # Form
5
- #
6
- def form_for *args, &block
7
- model_helper, options = build_form_model_helper_and_form_options *args
8
-
9
- form_tag options do
10
- block.call model_helper if block
11
- end
12
- end
13
-
14
- def build_form_model_helper_and_form_options model_name, model, options = {}
15
- model_name.must_be.a String, Symbol
16
- return ModelHelper.new(self, self, model_name, model, options), options
17
- end
18
-
19
- def form_tag options = {}, &block
20
- options['method'] ||= options[:method] || 'post'
21
- tag :form, options, &block
22
- end
23
-
24
-
25
- #
26
- # Errors
27
- #
28
- # delegate :error_messages, :field_with_errors, to: :form_builder
29
- def error_messages *errors
30
- errors = errors.first if errors.size == 1 and errors.first.is_a? Array
31
- html = errors.join("<br/>")
32
- tag :div, html, class: :error_messages
33
- end
34
-
35
- def field_with_errors name, errors, options, field_html
36
- html = tag :div, errors.join("<br/>"), class: :field_error_messages
37
- html << tag(:span, field_html, class: :field_with_errors)
38
- html
39
- end
40
-
41
-
42
- #
43
- # Form fields
44
- #
45
- def check_box_tag name, checked = false, options = {}
46
- options = {type: "checkbox", name: name, value: '1'}.update(options)
47
- options[:checked] = "checked" if checked
48
- tag_with_style :input, '', options
49
- end
50
-
51
- def field_set_tag legend = nil, options = {}, &block
52
- content = ""
53
- content << tag(:legend, legend) unless legend.blank?
54
- content << capture(&block)
55
- tag_with_style :fieldset, content, options
56
- end
57
-
58
- def file_field_tag name, options = {}
59
- text_field_tag name, nil, options.update(type: "file")
60
- end
61
-
62
- def hidden_field_tag name, value = '', options = {}
63
- text_field_tag(name, value, options.update(type: "hidden"))
64
- end
65
-
66
- def password_field_tag name, value = nil, options = {}
67
- text_field_tag(name, value, options.update(type: "password"))
68
- end
69
-
70
- def radio_button_tag name, checked = false, options = {}
71
- options = {type: "radio", name: name, value: '1'}.update(options)
72
- options["checked"] = "checked" if checked
73
- tag_with_style :input, '', options
74
- end
75
-
76
- def select_tag name, selected, values, options = {}
77
- buff = "\n"
78
- values.each do |n, v|
79
- o = {}
80
- o[:value] = v if v
81
- o[:selected] = 'selected' if (v || n) == selected
82
- buff << tag(:option, n, o)
83
- buff << "\n"
84
- end
85
-
86
- tag_with_style :select, buff, {name: name}.update(options)
87
- end
88
-
89
- def text_field_tag name, value = '', options = {}
90
- tag_with_style :input, '', {type: "text", name: name, value: value}.update(options)
91
- end
92
-
93
- def text_area_tag name, value = '', options = {}
94
- tag_with_style :textarea, value, {name: name}.update(options)
95
- end
96
-
97
-
98
- #
99
- # Other
100
- #
101
- def submit_tag value, options = {}
102
- tag_with_style :input, '', {type: "submit", value: value}.update(options)
103
- end
104
-
105
- protected
106
- def tag_with_style name, value, options, &block
107
- # add special class to fix with CSS some problems with fields display
108
- klass = options.delete(:class) || options.delete('class') || ""
109
- klass << " #{options[:type] || options['type'] || name}_input"
110
- options['class'] = klass
111
-
112
- tag name, value, options, &block
113
- end
114
- end
115
- end
@@ -1,5 +0,0 @@
1
- module Rad
2
- module HtmlHelper
3
- inherit BasicHtmlHelper, FormHelper, JavascriptHelper, FlashHelper
4
- end
5
- end
@@ -1,18 +0,0 @@
1
- module Rad
2
- module JavascriptHelper
3
- def javascript_include_tag *scripts
4
- Array(scripts).collect{|script|
5
- tag :script, '', src: "#{config && config.url_root!}#{script}", type: "text/javascript"
6
- }.join("\n")
7
- end
8
-
9
- def javascript_tag value = nil, &block
10
- args = [{type: "text/javascript"}]
11
- args.unshift value if value
12
- tag :script, *args, &block
13
- end
14
-
15
- # Escape
16
- def js obj; obj.to_s.js_escape end
17
- end
18
- end
@@ -1,135 +0,0 @@
1
- module Rad
2
- class ModelHelper
3
- attr_accessor :template, :model_name, :model, :options, :form_helper
4
-
5
- def initialize template, form_helper, model_name, model, options
6
- self.template, self.form_helper, self.model_name, self.model, self.options = template, form_helper, model_name, model, options
7
- end
8
-
9
-
10
- #
11
- # Helpers
12
- #
13
- def check_box name, options = {}
14
- render_attribute name, options do |fname, value, o|
15
- form_helper.check_box_tag fname, !!value, o
16
- end
17
- end
18
-
19
- def file_field name, options = {}
20
- render_attribute name, options do |fname, value, o|
21
- form_helper.file_field_tag fname, o
22
- end
23
- end
24
-
25
- def hidden_field name, options = {}
26
- render_attribute name, options do |fname, value, o|
27
- form_helper.hidden_field_tag fname, value, o
28
- end
29
- end
30
-
31
- def password_field name, options = {}
32
- render_attribute name, options do |fname, value, o|
33
- form_helper.password_field_tag fname, nil, o
34
- end
35
- end
36
-
37
- def radio_button name, options = {}
38
- render_attribute name, options do |fname, value, o|
39
- form_helper.radio_button_tag fname, !!value, o
40
- end
41
- end
42
-
43
- def submit value, options = {}
44
- form_helper.submit_tag value, options
45
- end
46
-
47
- def text_field name, options = {}
48
- render_attribute name, options do |fname, value, o|
49
- form_helper.text_field_tag fname, value, o
50
- end
51
- end
52
-
53
- def text_area name, options = {}
54
- render_attribute name, options do |fname, value, o|
55
- form_helper.text_area_tag fname, value, o
56
- end
57
- end
58
-
59
- def select name, values, options = {}
60
- render_attribute name, options do |fname, value, o|
61
- form_helper.select_tag fname, value, values, o
62
- end
63
- end
64
-
65
- def error_messages
66
- merrors = errors[:base]
67
- form_helper.error_messages merrors.to_a unless merrors.blank?
68
- end
69
-
70
-
71
- protected
72
- def method_missing m, *args, &b
73
- form_helper.send m, *args, &b
74
- end
75
-
76
- def render_attribute name, options, &block
77
- name.must_be.a Symbol
78
- ferrors = errors_for(name)
79
-
80
- options = insert_human_readable_label name, options
81
-
82
- if form_helper.respond_to? :field_with_errors
83
- field_html = block.call field_name_for(name), value_of(name), options
84
- unless ferrors.blank?
85
- form_helper.field_with_errors name, ferrors, options, field_html
86
- else
87
- field_html
88
- end
89
- else
90
- options[:errors] = ferrors
91
- block.call field_name_for(name), value_of(name), options
92
- end
93
- end
94
-
95
- def errors
96
- unless @errors
97
- @errors = {}
98
- (
99
- (model.respond_to?(:errors) && model.errors) ||
100
- (model.respond_to?(:[]) && (model['errors'] || model[:errors])) ||
101
- {}
102
- ).each do |k, v|
103
- @errors[k.to_sym] = Array.wrap(v)
104
- end
105
- end
106
- @errors
107
- end
108
-
109
- def errors_for name
110
- name.must_be.a Symbol
111
- errors[name]
112
- end
113
-
114
- def field_name_for name
115
- "#{model_name}[#{name}]"
116
- end
117
-
118
- def value_of name
119
- if model.respond_to? name
120
- model.send name
121
- elsif model.respond_to? :[]
122
- model[name.to_sym] || model[name.to_s]
123
- else
124
- raise "Model not respond to :#{name} nor to :[]!"
125
- end
126
- end
127
-
128
- def insert_human_readable_label name, options
129
- unless options.include?(:label) or options.include?(:label)
130
- options[:label] = model.t(name) if model.respond_to? :t
131
- end
132
- options
133
- end
134
- end
135
- end
data/lib/rad/http/http.rb DELETED
@@ -1,21 +0,0 @@
1
- module Rad
2
- module HTTP
3
- class << self
4
- inject environment: :environment, config: :config
5
-
6
- def ensure_public_symlink symlink_name, plugin_public_folder
7
- plugin_public_folder = File.expand_path(plugin_public_folder)
8
- File.must.exist(plugin_public_folder)
9
-
10
- environment.must_be.defined
11
- if environment.config.static? and !environment.config.test?
12
- symlink_path = "#{config.public_dir!}/#{symlink_name}"
13
- unless File.exist?(symlink_path) # and File.symlink?(symlink_path)
14
- # File.delete(symlink_path) if File.symlink?(symlink_path)
15
- File.symlink(plugin_public_folder, symlink_path)
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,36 +0,0 @@
1
- module Rad
2
- module HTTPAdapter
3
- class << self
4
- inject conveyors: :conveyors, config: :config
5
-
6
- def call env, workspace = {}, &block
7
- # result, opt = nil, opt.to_openobject
8
- workspace = conveyors.web.call(
9
- {env: env, response: Rad::Response.new}.merge(workspace),
10
- &block
11
- )
12
-
13
- response = workspace.response.must_be.defined
14
- result = response.finish
15
-
16
- result
17
- end
18
- # synchronize_method :call
19
-
20
- # def mock_call env = {}, workspace = {}, &block
21
- # env['PATH_INFO'] ||= '/'
22
- # env['rack.input'] ||= StringIO.new
23
- #
24
- # call env, workspace, &block
25
- # end
26
-
27
- def mock_environment
28
- {
29
- 'rack.url_scheme' => 'http',
30
- 'PATH_INFO' => '/',
31
- 'rack.input' => StringIO.new
32
- }
33
- end
34
- end
35
- end
36
- end