lizarb 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +34 -7
  3. data/Gemfile.lock +176 -14
  4. data/README.md +53 -9
  5. data/app/dev/commands/color_command.rb +29 -0
  6. data/app/dev/commands/color_command_test.rb +10 -0
  7. data/app/dev/commands/stick_command.rb +102 -0
  8. data/app/dev/commands/stick_command_test.rb +19 -0
  9. data/app/dev_box.rb +49 -17
  10. data/app/happy_box.rb +3 -2
  11. data/app/net/databases/redis_db.rb +1 -1
  12. data/app/net/databases/redis_db_test.rb +5 -5
  13. data/app/net/databases/sqlite_db.rb +1 -1
  14. data/app/net/databases/sqlite_db_test.rb +5 -5
  15. data/app/net/records/app_record.rb +1 -1
  16. data/app/net/records/app_record_test.rb +1 -1
  17. data/app/net/records/post_record_test.rb +1 -1
  18. data/app/net/records/user_record_test.rb +1 -1
  19. data/app/net_box.rb +29 -6
  20. data/app/web/requests/app_request.rb +1 -1
  21. data/app/web/requests/app_request_test.rb +1 -1
  22. data/app/web/requests/foo_request.rb +26 -0
  23. data/app/web/requests/foo_request_test.rb +7 -0
  24. data/app/web_box.rb +16 -8
  25. data/app.rb +38 -6
  26. data/app_global.gemfile.rb +1 -1
  27. data/app_global.gemfile.rb.lock +25 -3
  28. data/app_global.rb +1 -0
  29. data/{app_new → examples/bench/app}/dev/benches/loops_bench.rb +10 -3
  30. data/{app_new → examples/bench/app}/dev/benches/loops_bench_test.rb +1 -2
  31. data/examples/bench/app/dev/benches/objects_bench.rb +48 -0
  32. data/{app_new → examples/bench/app}/dev/benches/objects_bench_test.rb +1 -2
  33. data/{app_new → examples/bench/app}/dev/benches/sorted_bench.rb +28 -8
  34. data/examples/bench/app/dev/benches/sorted_bench_test.rb +11 -0
  35. data/{app_new → examples/bench/app}/dev/benches/variables_bench.rb +8 -2
  36. data/{app_new → examples/bench/app}/dev/benches/variables_bench_test.rb +1 -2
  37. data/examples/client/app/net/clients/news_client.rb +42 -0
  38. data/examples/client/app/net/clients/news_client_test.rb +24 -0
  39. data/{app_new → examples/command/app}/dev/commands/calculator_command.rb +1 -1
  40. data/{app_new → examples/command/app}/dev/commands/calculator_command_test.rb +1 -2
  41. data/{app_new → examples/command/app}/dev/commands/circle_command.rb +1 -1
  42. data/{app_new → examples/command/app}/dev/commands/circle_command_test.rb +1 -2
  43. data/{app_new → examples/command/app}/dev/commands/narrative_method_command.rb +3 -3
  44. data/{app_new → examples/command/app}/dev/commands/narrative_method_command_test.rb +2 -3
  45. data/{app_new → examples/command/app}/dev/commands/quadratic_command.rb +1 -1
  46. data/{app_new → examples/command/app}/dev/commands/quadratic_command_test.rb +1 -2
  47. data/examples/command/app/dev_box.rb +3 -0
  48. data/examples/log/app/dev/logs/logger_log.rb +8 -0
  49. data/examples/log/app/dev/logs/logger_log_test.rb +16 -0
  50. data/examples/new/app/dev_box.rb +67 -0
  51. data/examples/new/app.rb +41 -0
  52. data/examples/shell/app/dev/shells/bash_adapter_shell.rb +25 -0
  53. data/examples/shell/app/dev/shells/bash_adapter_shell_test.rb +23 -0
  54. data/examples/shell/app/dev/shells/business_logic_shell.rb +42 -0
  55. data/examples/shell/app/dev/shells/business_logic_shell_test.rb +39 -0
  56. data/examples/shell/app/dev/shells/gem_adapter_shell.rb +33 -0
  57. data/examples/shell/app/dev/shells/gem_adapter_shell_test.rb +23 -0
  58. data/exe/liza +6 -1
  59. data/exe/lizarb +1 -1
  60. data/lib/app.rb +71 -74
  61. data/lib/art_system/art_box.rb +5 -0
  62. data/lib/art_system/art_box_test.rb +8 -0
  63. data/lib/art_system.rb +8 -0
  64. data/lib/crypto_system/crypto_box.rb +5 -0
  65. data/lib/crypto_system/crypto_box_test.rb +8 -0
  66. data/lib/crypto_system.rb +8 -0
  67. data/lib/deep_system/deep_box.rb +5 -0
  68. data/lib/deep_system/deep_box_test.rb +8 -0
  69. data/lib/deep_system.rb +8 -0
  70. data/lib/desk_system/commands/glimmer_command.rb +26 -0
  71. data/lib/desk_system/commands/glimmer_command_test.rb +10 -0
  72. data/lib/desk_system/desk_box.rb +5 -0
  73. data/lib/desk_system/desk_box_test.rb +8 -0
  74. data/lib/desk_system.rb +8 -0
  75. data/lib/dev_system/{dev/controllers/command → commands}/test_command.rb +32 -4
  76. data/lib/dev_system/{dev/controllers/command → commands}/test_command_test.rb +1 -2
  77. data/lib/dev_system/dev_box.rb +79 -0
  78. data/lib/dev_system/dev_box_test.rb +33 -0
  79. data/lib/dev_system/generators/env_generator.rb +87 -0
  80. data/lib/dev_system/generators/env_generator_test.rb +11 -0
  81. data/lib/dev_system/generators/gemfile_generator.rb +47 -0
  82. data/lib/dev_system/generators/gemfile_generator_test.rb +11 -0
  83. data/lib/dev_system/generators/system_generator.rb +70 -0
  84. data/lib/dev_system/generators/system_generator_test.rb +11 -0
  85. data/lib/dev_system/{dev/controllers → sub/bench}/bench.rb +4 -0
  86. data/lib/dev_system/{dev/panels → sub/bench}/bench_panel_test.rb +6 -2
  87. data/lib/dev_system/sub/bench/bench_test.rb +24 -0
  88. data/lib/dev_system/{dev/controllers/bench → sub/bench/benches}/not_found_bench.rb +1 -2
  89. data/lib/dev_system/{dev/controllers/bench → sub/bench/benches}/not_found_bench_test.rb +1 -2
  90. data/lib/dev_system/{dev/controllers/command → sub/bench/commands}/bench_command.rb +1 -5
  91. data/lib/dev_system/{dev/controllers/command → sub/bench/commands}/bench_command_test.rb +1 -2
  92. data/lib/dev_system/sub/bench/generators/bench_generator.rb +70 -0
  93. data/lib/dev_system/sub/bench/generators/bench_generator_test.rb +10 -0
  94. data/lib/dev_system/sub/command/command.rb +28 -0
  95. data/lib/dev_system/sub/command/command_panel.rb +151 -0
  96. data/lib/dev_system/sub/command/command_panel_test.rb +78 -0
  97. data/lib/dev_system/{dev/controllers → sub/command}/command_test.rb +6 -2
  98. data/lib/dev_system/sub/command/commands/base_command.rb +48 -0
  99. data/lib/dev_system/sub/command/commands/base_command_test.rb +11 -0
  100. data/lib/dev_system/{dev/controllers/terminal/irb_terminal.rb → sub/command/commands/irb_command.rb} +3 -7
  101. data/lib/dev_system/sub/command/commands/irb_command_test.rb +11 -0
  102. data/lib/dev_system/sub/command/commands/not_found_command.rb +156 -0
  103. data/lib/dev_system/sub/command/commands/not_found_command_test.rb +11 -0
  104. data/lib/dev_system/{dev/controllers/terminal/pry_terminal.rb → sub/command/commands/pry_command.rb} +2 -2
  105. data/lib/dev_system/sub/command/commands/pry_command_test.rb +11 -0
  106. data/lib/dev_system/sub/command/commands/simple_command.rb +143 -0
  107. data/lib/dev_system/sub/command/commands/simple_command_test.rb +11 -0
  108. data/lib/dev_system/sub/command/generators/command_generator.rb +90 -0
  109. data/lib/dev_system/sub/command/generators/command_generator_test.rb +11 -0
  110. data/lib/dev_system/sub/command/input_commands/highline_input_command.rb +17 -0
  111. data/lib/dev_system/sub/command/input_commands/highline_input_command_test.rb +19 -0
  112. data/lib/dev_system/sub/command/input_commands/input_command.rb +20 -0
  113. data/lib/dev_system/sub/command/input_commands/input_command_test.rb +19 -0
  114. data/lib/dev_system/sub/command/input_commands/tty_input_command.rb +55 -0
  115. data/lib/dev_system/sub/command/input_commands/tty_input_command_test.rb +19 -0
  116. data/lib/dev_system/sub/generator/commands/generate_command.rb +9 -0
  117. data/lib/dev_system/sub/generator/commands/generate_command_test.rb +11 -0
  118. data/lib/dev_system/sub/generator/commands/new_command.rb +10 -0
  119. data/lib/dev_system/{dev/controllers/command → sub/generator/commands}/new_command_test.rb +1 -1
  120. data/lib/dev_system/sub/generator/generator.rb +19 -0
  121. data/lib/dev_system/sub/generator/generator_panel.rb +98 -0
  122. data/lib/dev_system/sub/generator/generator_panel_test.rb +79 -0
  123. data/lib/dev_system/{dev/controllers → sub/generator}/generator_test.rb +6 -2
  124. data/lib/dev_system/sub/generator/generators/base_generator.rb +64 -0
  125. data/lib/dev_system/sub/generator/generators/base_generator_test.rb +11 -0
  126. data/lib/dev_system/sub/generator/generators/generator_generator.rb +71 -0
  127. data/lib/dev_system/sub/generator/generators/generator_generator_test.rb +11 -0
  128. data/lib/dev_system/sub/generator/generators/new_generator.rb +74 -0
  129. data/lib/dev_system/sub/generator/generators/new_generator_test.rb +11 -0
  130. data/lib/dev_system/sub/generator/generators/not_found_generator.rb +155 -0
  131. data/lib/dev_system/sub/generator/generators/not_found_generator_test.rb +11 -0
  132. data/lib/dev_system/sub/generator/generators/simple_generator.rb +257 -0
  133. data/lib/dev_system/sub/generator/generators/simple_generator_test.rb +38 -0
  134. data/lib/dev_system/sub/log/commands/log_command.rb +11 -0
  135. data/lib/dev_system/sub/log/commands/log_command_test.rb +11 -0
  136. data/lib/dev_system/sub/log/generators/log_generator.rb +54 -0
  137. data/lib/dev_system/sub/log/generators/log_generator_test.rb +10 -0
  138. data/lib/dev_system/sub/log/log_panel.rb +47 -0
  139. data/lib/dev_system/sub/log/log_panel_test.rb +50 -0
  140. data/lib/dev_system/{dev/controllers → sub/log}/log_test.rb +6 -2
  141. data/lib/dev_system/sub/log/logs/output_log.rb +74 -0
  142. data/lib/dev_system/sub/log/logs/output_log_test.rb +47 -0
  143. data/lib/dev_system/sub/log/logs/stick_log.rb +79 -0
  144. data/lib/dev_system/sub/log/logs/stick_log_test.rb +88 -0
  145. data/lib/dev_system/sub/shell/commands/convert_command.rb +27 -0
  146. data/lib/dev_system/sub/shell/commands/convert_command_test.rb +10 -0
  147. data/lib/dev_system/sub/shell/commands/format_command.rb +25 -0
  148. data/lib/dev_system/sub/shell/commands/format_command_test.rb +10 -0
  149. data/lib/dev_system/sub/shell/commands/loc_command.rb +211 -0
  150. data/lib/dev_system/sub/shell/commands/loc_command_test.rb +10 -0
  151. data/lib/dev_system/sub/shell/commands/shell_command.rb +45 -0
  152. data/lib/dev_system/sub/shell/commands/shell_command_test.rb +11 -0
  153. data/lib/dev_system/sub/shell/converter_shells/coffee_converter_shell.rb +21 -0
  154. data/lib/dev_system/sub/shell/converter_shells/coffee_converter_shell_test.rb +41 -0
  155. data/lib/dev_system/sub/shell/converter_shells/converter_shell.rb +13 -0
  156. data/lib/dev_system/sub/shell/converter_shells/converter_shell_test.rb +19 -0
  157. data/lib/dev_system/sub/shell/converter_shells/haml_converter_shell.rb +30 -0
  158. data/lib/dev_system/sub/shell/converter_shells/haml_converter_shell_test.rb +34 -0
  159. data/lib/dev_system/sub/shell/converter_shells/md_converter_shell.rb +21 -0
  160. data/lib/dev_system/sub/shell/converter_shells/md_converter_shell_test.rb +38 -0
  161. data/lib/dev_system/sub/shell/converter_shells/scss_converter_shell.rb +59 -0
  162. data/lib/dev_system/sub/shell/converter_shells/scss_converter_shell_test.rb +59 -0
  163. data/lib/dev_system/sub/shell/formatter_shells/formatter_shell.rb +13 -0
  164. data/lib/dev_system/sub/shell/formatter_shells/formatter_shell_test.rb +19 -0
  165. data/lib/dev_system/sub/shell/formatter_shells/html_formatter_shell.rb +20 -0
  166. data/lib/dev_system/sub/shell/formatter_shells/html_formatter_shell_test.rb +51 -0
  167. data/lib/dev_system/sub/shell/generators/shell_generator.rb +68 -0
  168. data/lib/dev_system/sub/shell/generators/shell_generator_test.rb +10 -0
  169. data/lib/dev_system/{dev/controllers → sub/shell}/shell.rb +2 -2
  170. data/lib/dev_system/sub/shell/shell_panel.rb +98 -0
  171. data/lib/dev_system/sub/shell/shell_panel_test.rb +18 -0
  172. data/lib/dev_system/{dev/controllers → sub/shell}/shell_test.rb +9 -5
  173. data/lib/dev_system/sub/shell/shells/app_shell.rb +185 -0
  174. data/lib/dev_system/sub/shell/shells/app_shell_test.rb +26 -0
  175. data/lib/dev_system/{dev/controllers/shell → sub/shell/shells}/bin_shell_test.rb +1 -2
  176. data/lib/dev_system/sub/shell/shells/color_shell.rb +389 -0
  177. data/lib/dev_system/sub/shell/shells/color_shell_test.rb +27 -0
  178. data/lib/dev_system/sub/shell/shells/controller_shell.rb +20 -0
  179. data/lib/dev_system/sub/shell/shells/controller_shell_test.rb +16 -0
  180. data/lib/dev_system/sub/shell/shells/dir_shell.rb +27 -0
  181. data/lib/dev_system/{dev/controllers/shell → sub/shell/shells}/dir_shell_test.rb +1 -5
  182. data/lib/dev_system/{dev/controllers/shell → sub/shell/shells}/file_shell.rb +4 -4
  183. data/lib/dev_system/{dev/controllers/shell → sub/shell/shells}/file_shell_test.rb +1 -2
  184. data/lib/dev_system/sub/shell/shells/gem_shell.rb +21 -0
  185. data/lib/dev_system/sub/shell/shells/gem_shell_test.rb +28 -0
  186. data/lib/dev_system/sub/shell/shells/kernel_shell.rb +22 -0
  187. data/lib/dev_system/sub/shell/shells/kernel_shell_test.rb +10 -0
  188. data/lib/dev_system/sub/shell/shells/line_diff_shell.rb +26 -0
  189. data/lib/dev_system/sub/shell/shells/line_diff_shell_test.rb +11 -0
  190. data/lib/dev_system/sub/shell/shells/line_shell.rb +56 -0
  191. data/lib/dev_system/sub/shell/shells/line_shell_test.rb +70 -0
  192. data/lib/dev_system/sub/shell/shells/method_shell.rb +52 -0
  193. data/lib/dev_system/sub/shell/shells/method_shell_test.rb +34 -0
  194. data/lib/dev_system/sub/shell/shells/text_file_shell.rb +14 -0
  195. data/lib/dev_system/sub/shell/shells/text_file_shell_test.rb +11 -0
  196. data/lib/dev_system/sub/shell/shells/text_shell.rb +65 -0
  197. data/lib/dev_system/{dev/controllers/shell → sub/shell/shells}/text_shell_test.rb +1 -2
  198. data/lib/dev_system.rb +8 -2
  199. data/lib/happy_system/happy_box.rb +9 -0
  200. data/lib/happy_system/happy_box_test.rb +24 -0
  201. data/lib/happy_system/sub/axo/axo.rb +10 -0
  202. data/lib/happy_system/sub/axo/axo_panel.rb +9 -0
  203. data/lib/happy_system/sub/axo/axo_panel_test.rb +16 -0
  204. data/lib/happy_system/sub/axo/axo_test.rb +16 -0
  205. data/lib/happy_system/sub/axo/commands/axo_command.rb +40 -0
  206. data/lib/happy_system/sub/axo/commands/axo_command_test.rb +8 -0
  207. data/lib/happy_system/sub/axo/generators/axo_generator.rb +79 -0
  208. data/lib/happy_system/sub/axo/generators/axo_generator_test.rb +11 -0
  209. data/lib/happy_system.rb +4 -2
  210. data/lib/lab_system/clients/kroki_client.rb +134 -0
  211. data/lib/lab_system/clients/kroki_client_test.rb +32 -0
  212. data/lib/lab_system/clients/liza_kroki_client.rb +176 -0
  213. data/lib/lab_system/clients/liza_kroki_client_test.rb +32 -0
  214. data/lib/lab_system/commands/docker_command.rb +61 -0
  215. data/lib/lab_system/commands/docker_command_test.rb +11 -0
  216. data/lib/lab_system/lab_box.rb +5 -0
  217. data/lib/lab_system/lab_box_test.rb +8 -0
  218. data/lib/lab_system/requests/kroki_request.rb +182 -0
  219. data/lib/lab_system/requests/kroki_request_test.rb +11 -0
  220. data/lib/lab_system/shells/docker_shell.rb +60 -0
  221. data/lib/lab_system/shells/docker_shell_test.rb +61 -0
  222. data/lib/lab_system/shells/kroki_docker_shell.rb +20 -0
  223. data/lib/lab_system/shells/kroki_docker_shell_test.rb +11 -0
  224. data/lib/lab_system.rb +8 -0
  225. data/lib/liza/base/controller.rb +14 -15
  226. data/lib/liza/base/controller_test.rb +28 -2
  227. data/lib/liza/base/panel.rb +48 -6
  228. data/lib/liza/base/panel_test.rb +141 -2
  229. data/lib/liza/base_parts/controller_subsystem_part.rb +93 -0
  230. data/lib/liza/base_parts/panel_rescuer_part.rb +129 -0
  231. data/lib/liza/meta/box.rb +24 -0
  232. data/lib/liza/meta/box_test.rb +20 -0
  233. data/lib/liza/meta/part_test.rb +6 -1
  234. data/lib/liza/meta/system.rb +50 -7
  235. data/lib/liza/meta/system_test.rb +6 -2
  236. data/lib/liza/ruby_tests/app_test.rb +39 -0
  237. data/lib/liza/ruby_tests/class_test.rb +20 -0
  238. data/lib/liza/ruby_tests/module_test.rb +4 -4
  239. data/lib/liza/{ruby_test.rb → ruby_tests/object_test.rb} +1 -1
  240. data/lib/liza/ruby_tests/string_test.rb +3 -1
  241. data/lib/liza/{test → safety}/test.rb +9 -0
  242. data/lib/liza/{test → safety}/test_test.rb +40 -7
  243. data/lib/liza/{test_parts → safety_parts}/test_assertions_advanced_part.rb +1 -1
  244. data/lib/liza/{test_parts → safety_parts}/test_log_part.rb +20 -0
  245. data/lib/liza/{test_parts → safety_parts}/test_subject_part.rb +10 -0
  246. data/lib/liza/safety_parts/test_tree_part.rb +87 -0
  247. data/lib/liza/unit.rb +50 -100
  248. data/lib/liza/unit_parts/unit_classes_part.rb +37 -0
  249. data/lib/liza/unit_parts/unit_classes_part_test.rb +3 -0
  250. data/lib/liza/unit_parts/unit_logging_part.rb +139 -0
  251. data/lib/liza/unit_parts/unit_logging_part_test.rb +3 -0
  252. data/lib/liza/unit_parts/unit_methods_part.rb +35 -0
  253. data/lib/liza/unit_parts/unit_methods_part_test.rb +3 -0
  254. data/lib/liza/unit_parts/unit_procedure_part.rb +2 -2
  255. data/lib/liza/unit_parts/unit_renderer_part.rb +171 -0
  256. data/lib/liza/unit_parts/unit_renderer_part_test.rb +15 -0
  257. data/lib/liza/unit_parts/unit_settings_part.rb +8 -0
  258. data/lib/liza/unit_test.rb +114 -16
  259. data/lib/liza.rb +2 -2
  260. data/lib/lizarb/ruby/class.rb +9 -1
  261. data/lib/lizarb/ruby/string.rb +3 -1
  262. data/lib/lizarb/version.rb +1 -1
  263. data/lib/lizarb.rb +215 -64
  264. data/lib/micro_system/micro_box.rb +5 -0
  265. data/lib/micro_system/micro_box_test.rb +8 -0
  266. data/lib/micro_system.rb +8 -0
  267. data/lib/net_system/net_box.rb +21 -0
  268. data/lib/net_system/{net/net_box_test.rb → net_box_test.rb} +1 -2
  269. data/lib/net_system/{net/panels → sub/client}/client_panel_test.rb +1 -2
  270. data/lib/net_system/{net/controllers → sub/client}/client_test.rb +1 -2
  271. data/lib/net_system/sub/client/generators/client_generator.rb +88 -0
  272. data/lib/net_system/sub/client/generators/client_generator_test.rb +10 -0
  273. data/lib/net_system/sub/database/clients/mongo_client.rb +33 -0
  274. data/lib/net_system/sub/database/clients/mongo_client_test.rb +20 -0
  275. data/lib/net_system/sub/database/clients/mysql_client.rb +29 -0
  276. data/lib/net_system/sub/database/clients/mysql_client_test.rb +23 -0
  277. data/lib/net_system/sub/database/clients/pgsql_client.rb +29 -0
  278. data/lib/net_system/sub/database/clients/pgsql_client_test.rb +25 -0
  279. data/lib/net_system/{net/controllers/client → sub/database/clients}/redis_client.rb +4 -1
  280. data/lib/net_system/{net/controllers/client → sub/database/clients}/redis_client_test.rb +2 -2
  281. data/lib/net_system/{net/controllers/client → sub/database/clients}/sqlite_client.rb +4 -1
  282. data/lib/net_system/{net/controllers/client → sub/database/clients}/sqlite_client_test.rb +2 -2
  283. data/lib/net_system/sub/database/commands/database_command.rb +32 -0
  284. data/lib/net_system/sub/database/commands/database_command_test.rb +11 -0
  285. data/lib/net_system/{net/panels → sub/database}/database_panel_test.rb +1 -2
  286. data/lib/net_system/{net/controllers → sub/database}/database_test.rb +1 -2
  287. data/lib/net_system/sub/database/databases/mongo_db.rb +8 -0
  288. data/lib/net_system/sub/database/databases/mongo_db_test.rb +21 -0
  289. data/lib/net_system/sub/database/databases/mysql_db.rb +8 -0
  290. data/lib/net_system/sub/database/databases/mysql_db_test.rb +21 -0
  291. data/lib/net_system/sub/database/databases/pgsql_db.rb +8 -0
  292. data/lib/net_system/sub/database/databases/pgsql_db_test.rb +21 -0
  293. data/lib/net_system/{net/controllers/database → sub/database/databases}/redis_db_test.rb +1 -1
  294. data/lib/net_system/{net/controllers/database → sub/database/databases}/sqlite_db_test.rb +1 -1
  295. data/lib/net_system/sub/record/generators/record_generator.rb +33 -0
  296. data/lib/net_system/sub/record/generators/record_generator_test.rb +11 -0
  297. data/lib/net_system/sub/record/record_panel.rb +3 -0
  298. data/lib/net_system/sub/record/record_panel_test.rb +11 -0
  299. data/lib/net_system/{net/controllers → sub/record}/record_test.rb +1 -2
  300. data/lib/net_system.rb +8 -1
  301. data/lib/web_system/{dev → sub/rack/commands}/rack_command.rb +7 -5
  302. data/lib/web_system/sub/rack/commands/rack_command_test.rb +11 -0
  303. data/lib/web_system/sub/rack/middle_racks/first_middle_rack.rb +8 -0
  304. data/lib/web_system/sub/rack/middle_racks/first_middle_rack_test.rb +11 -0
  305. data/lib/web_system/sub/rack/middle_racks/last_middle_rack.rb +3 -0
  306. data/lib/web_system/sub/rack/middle_racks/last_middle_rack_test.rb +11 -0
  307. data/lib/web_system/sub/rack/middle_racks/middle_rack.rb +18 -0
  308. data/lib/web_system/sub/rack/middle_racks/middle_rack_test.rb +11 -0
  309. data/lib/web_system/sub/rack/middle_racks/zeitwerk_middle_rack.rb +11 -0
  310. data/lib/web_system/sub/rack/middle_racks/zeitwerk_middle_rack_test.rb +11 -0
  311. data/lib/web_system/sub/rack/rack_panel.rb +52 -0
  312. data/lib/web_system/{web/panels → sub/rack}/rack_panel_test.rb +1 -2
  313. data/lib/web_system/{web/controllers → sub/rack}/rack_test.rb +1 -2
  314. data/lib/web_system/sub/rack/server_racks/agoo_server_rack.rb +53 -0
  315. data/lib/web_system/sub/rack/server_racks/agoo_server_rack_test.rb +11 -0
  316. data/lib/web_system/sub/rack/server_racks/falcon_server_rack.rb +46 -0
  317. data/lib/web_system/sub/rack/server_racks/falcon_server_rack_test.rb +11 -0
  318. data/lib/web_system/sub/rack/server_racks/iodine_server_rack.rb +47 -0
  319. data/lib/web_system/sub/rack/server_racks/iodine_server_rack_test.rb +11 -0
  320. data/lib/web_system/sub/rack/server_racks/puma_server_rack.rb +48 -0
  321. data/lib/web_system/sub/rack/server_racks/puma_server_rack_test.rb +11 -0
  322. data/lib/web_system/sub/rack/server_racks/server_rack.rb +12 -0
  323. data/lib/web_system/sub/rack/server_racks/server_rack_test.rb +11 -0
  324. data/lib/web_system/sub/rack/server_racks/thin_server_rack.rb +85 -0
  325. data/lib/web_system/sub/rack/server_racks/thin_server_rack_test.rb +11 -0
  326. data/lib/web_system/sub/request/commands/request_command.rb +125 -0
  327. data/lib/web_system/sub/request/commands/request_command_test.rb +11 -0
  328. data/lib/web_system/sub/request/generators/request_generator.rb +96 -0
  329. data/lib/web_system/sub/request/generators/request_generator_test.rb +11 -0
  330. data/lib/web_system/sub/request/request_panel.rb +69 -0
  331. data/lib/web_system/sub/request/request_panel_test.rb +54 -0
  332. data/lib/web_system/{web/controllers → sub/request}/request_test.rb +1 -2
  333. data/lib/web_system/sub/request/requests/simple_request.rb +95 -0
  334. data/lib/web_system/sub/request/requests/simple_request_test.rb +11 -0
  335. data/lib/web_system/sub/request/router_requests/router_request.rb +7 -0
  336. data/lib/web_system/sub/request/router_requests/router_request_test.rb +11 -0
  337. data/lib/web_system/sub/request/router_requests/simple_router_request.rb +24 -0
  338. data/lib/web_system/sub/request/router_requests/simple_router_request_test.rb +11 -0
  339. data/lib/web_system/web_box.rb +17 -0
  340. data/lib/web_system/{web/web_box_test.rb → web_box_test.rb} +1 -2
  341. data/lib/web_system.rb +9 -3
  342. data/lib/work_system/work_box.rb +5 -0
  343. data/lib/work_system/work_box_test.rb +8 -0
  344. data/lib/work_system.rb +8 -0
  345. data/lizarb.gemspec +13 -7
  346. metadata +369 -167
  347. data/app/happy/axos/axo.rb +0 -50
  348. data/app_new/dev/benches/objects_bench.rb +0 -83
  349. data/app_new/dev/benches/sorted_bench_test.rb +0 -12
  350. data/app_new/dev_box.rb +0 -14
  351. data/app_new.rb +0 -15
  352. data/exe/lrb +0 -3
  353. data/lib/dev_system/dev/controllers/bench_test.rb +0 -12
  354. data/lib/dev_system/dev/controllers/command/generate_command.rb +0 -9
  355. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +0 -12
  356. data/lib/dev_system/dev/controllers/command/new_command.rb +0 -9
  357. data/lib/dev_system/dev/controllers/command/not_found_command.rb +0 -48
  358. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +0 -12
  359. data/lib/dev_system/dev/controllers/command/terminal_command.rb +0 -22
  360. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +0 -12
  361. data/lib/dev_system/dev/controllers/command.rb +0 -13
  362. data/lib/dev_system/dev/controllers/generator.rb +0 -9
  363. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +0 -50
  364. data/lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb +0 -23
  365. data/lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb +0 -12
  366. data/lib/dev_system/dev/controllers/generators/bench_generator.rb +0 -12
  367. data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +0 -12
  368. data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +0 -41
  369. data/lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb +0 -12
  370. data/lib/dev_system/dev/controllers/generators/command_generator.rb +0 -19
  371. data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +0 -12
  372. data/lib/dev_system/dev/controllers/generators/controller_generator.rb +0 -97
  373. data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +0 -12
  374. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +0 -18
  375. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +0 -12
  376. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +0 -9
  377. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +0 -12
  378. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +0 -30
  379. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +0 -12
  380. data/lib/dev_system/dev/controllers/generators/new_generator.rb +0 -117
  381. data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +0 -12
  382. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +0 -39
  383. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +0 -12
  384. data/lib/dev_system/dev/controllers/generators/record_generator.rb +0 -46
  385. data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +0 -12
  386. data/lib/dev_system/dev/controllers/generators/request_generator.rb +0 -63
  387. data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +0 -12
  388. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +0 -27
  389. data/lib/dev_system/dev/controllers/shell/text_shell.rb +0 -23
  390. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +0 -12
  391. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +0 -12
  392. data/lib/dev_system/dev/controllers/terminal.rb +0 -17
  393. data/lib/dev_system/dev/controllers/terminal_test.rb +0 -12
  394. data/lib/dev_system/dev/dev_box.rb +0 -33
  395. data/lib/dev_system/dev/dev_box_test.rb +0 -17
  396. data/lib/dev_system/dev/panels/command_panel.rb +0 -71
  397. data/lib/dev_system/dev/panels/command_panel_test.rb +0 -46
  398. data/lib/dev_system/dev/panels/generator_panel.rb +0 -73
  399. data/lib/dev_system/dev/panels/generator_panel_test.rb +0 -46
  400. data/lib/dev_system/dev/panels/log_panel.rb +0 -13
  401. data/lib/dev_system/dev/panels/log_panel_test.rb +0 -16
  402. data/lib/dev_system/dev/panels/shell_panel.rb +0 -3
  403. data/lib/dev_system/dev/panels/shell_panel_test.rb +0 -12
  404. data/lib/dev_system/dev/panels/terminal_panel.rb +0 -3
  405. data/lib/dev_system/dev/panels/terminal_panel_test.rb +0 -12
  406. data/lib/happy_system/dev/happy_command.rb +0 -11
  407. data/lib/happy_system/happy/controllers/axo.rb +0 -7
  408. data/lib/happy_system/happy/happy_box.rb +0 -8
  409. data/lib/happy_system/happy/happy_box_test.rb +0 -16
  410. data/lib/happy_system/happy/panels/axo_panel.rb +0 -3
  411. data/lib/liza/base/box.rb +0 -90
  412. data/lib/liza/base/box_test.rb +0 -10
  413. data/lib/liza/base_parts/controller_renderer_part.rb +0 -140
  414. data/lib/liza/base_parts/controller_renderer_part_test.rb +0 -16
  415. data/lib/liza/meta/part_extension.rb +0 -16
  416. data/lib/liza/test_parts/test_tree_part.rb +0 -92
  417. data/lib/net_system/dev/net_command.rb +0 -22
  418. data/lib/net_system/net/net_box.rb +0 -13
  419. data/lib/web_system/dev/request_command.rb +0 -129
  420. data/lib/web_system/dev/web_command.rb +0 -9
  421. data/lib/web_system/web/panels/rack_panel.rb +0 -42
  422. data/lib/web_system/web/panels/request_panel.rb +0 -70
  423. data/lib/web_system/web/panels/request_panel_test.rb +0 -33
  424. data/lib/web_system/web/web_box.rb +0 -18
  425. /data/lib/dev_system/{dev/panels → sub/bench}/bench_panel.rb +0 -0
  426. /data/lib/dev_system/{dev/controllers → sub/log}/log.rb +0 -0
  427. /data/lib/dev_system/{dev/controllers/shell → sub/shell/shells}/bin_shell.rb +0 -0
  428. /data/lib/liza/{test_parts → safety_parts}/test_assertions_part.rb +0 -0
  429. /data/lib/liza/{test_parts → safety_parts}/test_dsl_part.rb +0 -0
  430. /data/lib/net_system/{net/controllers → sub/client}/client.rb +0 -0
  431. /data/lib/net_system/{net/panels → sub/client}/client_panel.rb +0 -0
  432. /data/lib/net_system/{net/controllers → sub/database}/database.rb +0 -0
  433. /data/lib/net_system/{net/panels → sub/database}/database_panel.rb +0 -0
  434. /data/lib/net_system/{net/controllers/database → sub/database/databases}/redis_db.rb +0 -0
  435. /data/lib/net_system/{net/controllers/database → sub/database/databases}/sqlite_db.rb +0 -0
  436. /data/lib/net_system/{net/controllers → sub/record}/record.rb +0 -0
  437. /data/lib/web_system/{web/controllers → sub/rack}/rack.rb +0 -0
  438. /data/lib/web_system/{web/controllers → sub/request}/request.rb +0 -0
  439. /data/lib/web_system/{web/controllers/request → sub/request/requests}/client_error_request.rb +0 -0
  440. /data/lib/web_system/{web/controllers/request → sub/request/requests}/not_found_request.rb +0 -0
  441. /data/lib/web_system/{web/controllers/request → sub/request/requests}/server_error_request.rb +0 -0
@@ -0,0 +1,87 @@
1
+ class Liza::TestTreePart < Liza::Part
2
+
3
+ insertion do
4
+
5
+ @before_stack = []
6
+ @after_stack = []
7
+
8
+ def self.before_stack; @before_stack ||= superclass.before_stack.dup end
9
+ def self.after_stack; @after_stack ||= superclass.after_stack.dup end
10
+
11
+ def self.test_node; @test_node ||= test_tree end
12
+ def self.test_tree; @test_tree ||= Liza::TestTreePart.new nil, before_stack, after_stack end
13
+
14
+ #
15
+
16
+ def self.group *words, &block
17
+ raise ArgumentError, "No block given" unless block_given?
18
+ previous = test_node
19
+ @test_node = test_node.branch_out words
20
+ instance_exec(&block)
21
+ @test_node = previous
22
+ end
23
+
24
+ def self.test *words, &block
25
+ raise ArgumentError, "No block given" unless block_given?
26
+ test_node.add_test words, &block
27
+ end
28
+
29
+ def self.before &block
30
+ raise ArgumentError, "No block given" unless block_given?
31
+ test_node.add_before(&block)
32
+ end
33
+
34
+ def self.after &block
35
+ raise ArgumentError, "No block given" unless block_given?
36
+ test_node.add_after(&block)
37
+ end
38
+
39
+ end
40
+
41
+ #
42
+
43
+ def log_test_building?
44
+ Liza::Test.log_test_building?
45
+ end
46
+
47
+ attr_reader :tests, :parent, :children, :before_stack, :after_stack
48
+
49
+ def initialize parent, before_stack, after_stack
50
+ @tests = []
51
+ initialize_parenting parent
52
+ initialize_filters before_stack, after_stack
53
+ end
54
+
55
+ def initialize_parenting parent
56
+ @parent = parent || self
57
+ @children = []
58
+ @parent.children << self if @parent != self
59
+ end
60
+
61
+ def initialize_filters before_stack, after_stack
62
+ @before_top, @after_top = [], []
63
+ @before_stack = before_stack.push @before_top
64
+ @after_stack = after_stack.unshift @after_top
65
+ end
66
+
67
+ def add_before &block
68
+ log "add_before to ##{object_id} #{block}" if log_test_building?
69
+ @before_top.push block
70
+ end
71
+
72
+ def add_test words, &block
73
+ log "add_test to ##{object_id} #{words} #{block}" if log_test_building?
74
+ tests << [words, block]
75
+ end
76
+
77
+ def add_after &block
78
+ log "add_after to ##{object_id} #{block}" if log_test_building?
79
+ @after_top.push block
80
+ end
81
+
82
+ def branch_out words, &block
83
+ self.class.new self, before_stack.dup, after_stack.dup
84
+ end
85
+
86
+
87
+ end
data/lib/liza/unit.rb CHANGED
@@ -1,9 +1,13 @@
1
1
  class Liza::Unit
2
2
 
3
- # PARTS
3
+ # ERROR
4
+
5
+ class Error < Liza::Error; end
6
+
7
+ # PART
4
8
 
5
- def self.part key, system: nil
6
- App.connect_part self, key, system
9
+ def self.part key, klass = nil, system: nil
10
+ Lizarb.connect_part self, key, klass, system
7
11
  end
8
12
 
9
13
  # CONST MISSING
@@ -26,124 +30,70 @@ class Liza::Unit
26
30
 
27
31
  end
28
32
 
29
- part :unit_procedure
30
- part :unit_settings
31
-
32
- # LOG
33
-
34
- LOG_LEVELS = {
35
- :higher => 2,
36
- :high => 1,
37
- :normal => 0,
38
- :low => -1,
39
- :lower => -2,
40
- }
41
-
42
- set :log_level, :normal
43
- set :log_color, :white
33
+ # PARTS
44
34
 
45
- # NOTE: improve logs performance and readability
35
+ part :unit_classes
46
36
 
47
- LOG_JUST = 60
37
+ part :unit_logging
48
38
 
49
- def self.build_log_sidebar_for source, method_key, method_sep, panel_key: nil
50
- source = (source.is_a? Class) ? source : source.class
51
- source_color = source.log_color
52
- source = source.to_s
39
+ part :unit_methods
53
40
 
54
- s = source.bold.colorize(source_color)
55
- s << "[:#{panel_key}]" if panel_key
56
- s << "#{method_sep}#{method_key}"
57
- s.ljust(LOG_JUST)
58
- end
41
+ part :unit_procedure
42
+
43
+ class RenderError < Error; end
44
+ class RendererNotFound < RenderError; end
45
+ class RenderStackIsFull < RenderError; end
46
+ class RenderStackIsEmpty < RenderError; end
47
+ part :unit_renderer
59
48
 
60
- # NOTE: This code needs to be optimized.
61
- def self._log_extract_method_name kaller
62
- kaller.each do |s|
63
- t = s.match(/`(.*)'/)[1]
64
-
65
- next if t.include? " in <class:"
66
- return t.split(" ").last if t.include? " in "
67
-
68
- next if t == "log"
69
- next if t == "each"
70
- next if t == "map"
71
- next if t == "with_index"
72
- next if t == "instance_exec"
73
- next if t.start_with? "_"
74
- return t
75
- end
49
+ part :unit_settings
76
50
 
77
- raise "there's something wrong with kaller"
78
- end
51
+ # TEST
79
52
 
80
- def _log_extract_method_name kaller
81
- self.class._log_extract_method_name kaller
53
+ def self.test_class
54
+ @test_class ||=
55
+ if first_namespace == "Liza"
56
+ Liza.const_get "#{last_namespace}Test"
57
+ else
58
+ Object.const_get "#{name}Test"
59
+ end
82
60
  end
83
61
 
84
- def self.log log_level = :normal, string, kaller: caller
85
- raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
86
- return unless log_level? log_level
62
+ # CONTROLLER
87
63
 
88
- method_key = _log_extract_method_name kaller
89
- source = Liza::Unit.build_log_sidebar_for self, method_key, ":"
90
-
91
- DevBox[:log].call "#{source} #{string}"
64
+ def self.division
65
+ Liza::Controller
92
66
  end
93
67
 
94
- def log log_level = :normal, string, kaller: caller
95
- raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
96
- return unless log_level? log_level
97
-
98
- method_key = _log_extract_method_name kaller
68
+ # SYSTEM
99
69
 
100
- case self
101
- when Liza::Panel
102
- source = Liza::Unit.build_log_sidebar_for box, method_key, ".", panel_key: @key
103
- when Liza::UnitTest
104
- source = Liza::Unit.build_log_sidebar_for self, " ", " "
70
+ def self.system
71
+ if name&.include? "::"
72
+ return System if first_namespace == "Liza"
73
+ Object.const_get first_namespace
105
74
  else
106
- source = Liza::Unit.build_log_sidebar_for self, method_key, "#"
75
+ superclass.system
107
76
  end
108
-
109
- DevBox[:log].call "#{source} #{string}"
110
77
  end
111
78
 
112
- #
113
-
114
- def self.log_level
115
- get(:log_level) || :normal
116
- end
117
-
118
- def self.log_level? log_level = :normal
119
- # TODO
120
- true
121
- end
79
+ singleton_class.send :public, :system
122
80
 
123
- def self.log_color
124
- (get(:system) || self).get :log_color
81
+ def system
82
+ self.class.system
125
83
  end
126
84
 
127
- def self.log?(log_level = :normal)= log_level? log_level
128
- def log_level(...)= self.class.log_level(...)
129
- def log?(...)= self.class.log?(...)
130
- def log_level?(...)= self.class.log_level?(...)
131
- def log_color(...)= self.class.log_color(...)
132
-
133
- # SYSTEM
134
-
135
- def self.inherited_explicitly_sets_system
85
+ public :system
136
86
 
137
- def self.inherited sub
138
- super
139
-
140
- return unless sub.name.to_s.include? "::"
141
-
142
- system = Object.const_get sub.first_namespace
143
-
144
- sub.set :system, system
145
- end
87
+ #
146
88
 
89
+ App.settings.each do |k, v|
90
+ set k, v
147
91
  end
148
-
92
+ set :division, Liza::Controller
93
+
149
94
  end
95
+
96
+ __END__
97
+
98
+ # view render.txt.erb
99
+ <%= render if render_stack.any? -%>
@@ -0,0 +1,37 @@
1
+ class Liza::UnitClassesPart < Liza::Part
2
+
3
+ insertion do
4
+
5
+ def self.subclasses_select system:
6
+ subclasses.select { _1.system? system }
7
+ end
8
+
9
+ def self.descendants_select system:
10
+ descendants.select { _1.system? system }
11
+ end
12
+
13
+ def self.namespace
14
+ return @namespace if defined? @namespace
15
+
16
+ @namespace ||= Object unless to_s.include? "::"
17
+ @namespace ||= Liza if to_s.start_with? "Liza::"
18
+ @namespace ||= system
19
+ @namespace
20
+ end
21
+
22
+ def self.system? system
23
+ system = Liza.const "#{system}_system" if system.is_a? Symbol
24
+ system == get(:system)
25
+ end
26
+
27
+ def self.reload!
28
+ Lizarb.reload
29
+ end
30
+
31
+ def reload!
32
+ Lizarb.reload
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,3 @@
1
+ class Liza::UnitClassesPartTest < Liza::UnitTest
2
+
3
+ end
@@ -0,0 +1,139 @@
1
+ class Liza::UnitLoggingPart < Liza::Part
2
+
3
+ insertion do
4
+
5
+ # LOG
6
+
7
+ def self.log_levels()=App::LOG_LEVELS
8
+ def log_levels()= App::LOG_LEVELS
9
+
10
+ def self.log log_level = App::DEFAULT_LOG_LEVEL, object, kaller: caller
11
+ log_level = log_levels[log_level] if log_level.is_a? Symbol
12
+ raise "invalid log_level `#{log_level}`" unless log_levels.values.include? log_level
13
+ return unless log_level? log_level
14
+
15
+ env = {}
16
+ env[:type] = :log
17
+ env[:unit] = self
18
+ env[:unit_class] = self
19
+ env[:message_log_level] = log_level
20
+ env[:unit_log_level] = self.log_level
21
+ env[:caller] = kaller
22
+ env[:object] = object
23
+
24
+ DevBox[:log].call env
25
+ end
26
+
27
+ def log log_level = App::DEFAULT_LOG_LEVEL, object, kaller: caller
28
+ log_level = log_levels[log_level] if log_level.is_a? Symbol
29
+ raise "invalid log_level `#{log_level}`" unless log_levels.values.include? log_level
30
+ return unless log_level? log_level
31
+
32
+ env = {}
33
+ env[:type] = :log
34
+ env[:unit] = self
35
+ env[:unit_class] = self.class
36
+ env[:message_log_level] = log_level
37
+ env[:unit_log_level] = self.log_level
38
+ env[:caller] = kaller
39
+ env[:object] = object
40
+
41
+ DevBox[:log].call env
42
+ end
43
+
44
+ def self.stick *args
45
+ StickLog.new *args
46
+ end
47
+
48
+ def stick *args
49
+ StickLog.new *args
50
+ end
51
+
52
+ def self.sticks *args
53
+ StickLog.bundle *args
54
+ end
55
+
56
+ def sticks *args
57
+ StickLog.bundle *args
58
+ end
59
+
60
+ #
61
+
62
+ def self.log_level new_value = nil
63
+ if new_value
64
+ new_value = log_levels[new_value] if new_value.is_a? Symbol
65
+ raise "invalid log_level `#{new_value}`" unless log_levels.values.include? new_value
66
+ set :log_level, new_value
67
+ else
68
+ get :log_level
69
+ end
70
+ end
71
+
72
+ def log_level new_value = nil
73
+ if new_value
74
+ new_value = log_levels[new_value] if new_value.is_a? Symbol
75
+ raise "invalid log_level `#{new_value}`" unless log_levels.values.include? new_value
76
+ set :log_level, new_value
77
+ else
78
+ get :log_level
79
+ end
80
+ end
81
+
82
+ #
83
+
84
+ def self.log_hash log_level = :normal, hash, prefix: "", kaller: caller[1..-1]
85
+ prefix = prefix.to_s
86
+ size = hash.keys.map(&:to_s).map(&:size).max
87
+
88
+ hash.each do |k,v|
89
+ log log_level, "#{prefix}#{k.to_s.ljust size} = #{v.to_s.inspect}", kaller: kaller
90
+ end
91
+ end
92
+
93
+ def log_hash log_level = :normal, hash, prefix: "", kaller: caller[1..-1]
94
+ prefix = prefix.to_s
95
+ size = hash.keys.map(&:to_s).map(&:size).max
96
+
97
+ hash.each do |k,v|
98
+ log log_level, "#{prefix}#{k.to_s.ljust size} = #{v.to_s.inspect}", kaller: kaller
99
+ end
100
+ end
101
+
102
+ #
103
+
104
+ def self.log_array log_level = :normal, array, prefix: "", kaller: caller[1..-1]
105
+ prefix = prefix.to_s
106
+ size = array.size.to_s.size+1
107
+
108
+ array.each.with_index do |v, i|
109
+ log log_level, "#{prefix}#{i.to_s.ljust size} = #{v.inspect}", kaller: kaller
110
+ end
111
+ end
112
+
113
+ def log_array log_level = :normal, array, prefix: "", kaller: caller[1..-1]
114
+ prefix = prefix.to_s
115
+ size = array.size.to_s.size+1
116
+
117
+ array.each.with_index do |v, i|
118
+ log log_level, "#{prefix}#{i.to_s.ljust size} = #{v.inspect}", kaller: kaller
119
+ end
120
+ end
121
+
122
+ #
123
+
124
+ def self.log?(log_level = App::DEFAULT_LOG_LEVEL)= log_level? log_level
125
+ def log?(...)= log_level? log_level
126
+
127
+ def self.log_level? log_level = App::DEFAULT_LOG_LEVEL
128
+ log_level = log_levels[log_level] if log_level.is_a? Symbol
129
+ log_level >= self.log_level
130
+ end
131
+
132
+ def log_level? log_level = App::DEFAULT_LOG_LEVEL
133
+ log_level = log_levels[log_level] if log_level.is_a? Symbol
134
+ log_level >= self.log_level
135
+ end
136
+
137
+ end
138
+
139
+ end
@@ -0,0 +1,3 @@
1
+ class Liza::UnitLoggingPartTest < Liza::UnitTest
2
+
3
+ end
@@ -0,0 +1,35 @@
1
+ class Liza::UnitMethodsPart < Liza::Part
2
+
3
+ insertion do
4
+ def self.methods_defined
5
+ a = methods - superclass.methods
6
+ a.reject! { _1.to_s[0] == "_" }
7
+ a.sort!
8
+ end
9
+
10
+ def self.instance_methods_defined
11
+ a = instance_methods - superclass.instance_methods
12
+ a.reject! { _1.to_s[0] == "_" }
13
+ a.sort!
14
+ end
15
+
16
+ def self.methods_for_rendering
17
+ methods_defined.select { _1[0..5] == "render" || _1[0..2] == "erb" }.sort
18
+ end
19
+
20
+ def self.instance_methods_for_rendering
21
+ instance_methods_defined.select { _1[0..5] == "render" || _1[0..2] == "erb" }.sort
22
+ end
23
+
24
+ def self.methods_for_logging
25
+ array = methods_defined.select { _1[0..2] == "log" }.sort
26
+ [*array, :stick, :sticks]
27
+ end
28
+
29
+ def self.instance_methods_for_logging
30
+ array = instance_methods_defined.select { _1[0..2] == "log" }.sort
31
+ [*array, :stick, :sticks]
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ class Liza::UnitMethodsPartTest < Liza::UnitTest
2
+
3
+ end
@@ -1,7 +1,7 @@
1
1
  class Liza::UnitProcedurePart < Liza::Part
2
2
 
3
3
  insertion do
4
- def self.procedure _label, &block
4
+ def self.procedure _label = nil, &block
5
5
  catch :procedure, &block
6
6
  end
7
7
 
@@ -10,7 +10,7 @@ class Liza::UnitProcedurePart < Liza::Part
10
10
  throw :procedure, val
11
11
  end
12
12
 
13
- def procedure(_label, &block)= self.class.procedure _label, &block
13
+ def procedure(_label = nil, &block)= self.class.procedure _label, &block
14
14
  def proceed(...)= self.class.proceed(...)
15
15
  end
16
16
 
@@ -0,0 +1,171 @@
1
+ class Liza::UnitRendererPart < Liza::Part
2
+
3
+ RENDER_STACK_IS_EMPTY_MESSAGE = <<~STRING
4
+ You called render without ERB keys,
5
+ but the render stack is empty.
6
+ Did you forget to add ERB keys?
7
+ STRING
8
+
9
+ RENDER_STACK_IS_FULL_MESSAGE = <<~STRING
10
+ You called render with too many ERB keys.
11
+ Did you accidentally fall into an infinite loop?
12
+ STRING
13
+
14
+ insertion do
15
+ def render! *keys, format: nil
16
+ render *keys, format: format, allow_missing: false
17
+ end
18
+
19
+ def render *keys, format: nil, allow_missing: true
20
+ format = @render_format ||= @format if format.nil?
21
+ raise "@render_format or @format must be set, or format keyword-argument must be given" if format.nil?
22
+ @render_format = format = format.to_sym
23
+
24
+ log_rendering = log_level? :low
25
+
26
+ if keys.any?
27
+ log_render_in keys, kaller: caller if log_rendering
28
+
29
+ erbs = self.class.erbs_for format, keys, allow_missing: allow_missing
30
+ erbs.to_a.reverse.each do |key, erb|
31
+ if true
32
+ t = Time.now
33
+ s = erb.result binding, self
34
+ log_render_out "#{erb.name}.#{erb.format}", s.length, t.diff, kaller: caller if log_rendering
35
+ end
36
+
37
+ if DevBox.convert? erb.format
38
+ t = Time.now
39
+ s = DevBox.convert erb.format, s
40
+ log_render_convert "#{erb.name}.#{format}", s.length, t.diff, kaller: caller if log_rendering
41
+ end
42
+
43
+ render_stack.push s
44
+
45
+ raise RenderStackIsFull RENDER_STACK_IS_FULL_MESSAGE, caller if render_stack.size > 10
46
+ end
47
+
48
+ render_stack.pop
49
+ elsif render_stack.any?
50
+ render_stack.pop
51
+ else
52
+ raise RenderStackIsEmpty, RENDER_STACK_IS_EMPTY_MESSAGE, caller
53
+ end
54
+ end
55
+
56
+ def render_stack
57
+ @render_stack ||= []
58
+ end
59
+
60
+ def log_render_in keys, kaller:
61
+ if render_stack.any?
62
+ log "render → #{keys.join " "}", kaller: kaller
63
+ else
64
+ log "render #{"→ " * keys.size}#{keys.join " "}", kaller: kaller
65
+ end
66
+ end
67
+
68
+ def log_render_out key, length, t, kaller:
69
+ if render_stack.any?
70
+ log "render #{"← #{key}".ljust_blanks 25} #{length.to_s.rjust_blanks 4} characters in #{t}s", kaller: kaller
71
+ else
72
+ log "render #{"← #{key}".ljust_blanks 25} #{length.to_s.rjust_blanks 4} characters in #{t}s", kaller: kaller
73
+ end
74
+ end
75
+
76
+ def log_render_convert key, length, t, kaller:
77
+ log "convert #{"#{key}".ljust_blanks 23} #{length.to_s.rjust_blanks 4} characters in #{t}s", kaller: kaller
78
+ end
79
+
80
+ # class level methods
81
+
82
+ def self.erbs_defined
83
+ @erbs_defined ||= LERB.load(self.source_location_radical)
84
+ end
85
+
86
+ def self.erbs_available ref = Liza::Unit
87
+ @erbs_available ||= begin
88
+ h = {}
89
+
90
+ ancestors.take_while do |ancestor|
91
+ ancestor != ref
92
+ end.reverse.each do |ancestor|
93
+ ancestor.erbs_defined.each do |erb|
94
+ h[erb.key] = erb
95
+ end
96
+ end
97
+
98
+ h.values
99
+ end
100
+ end
101
+
102
+ def self.renderable_names
103
+ erbs_available.map(&:name).uniq
104
+ end
105
+
106
+ def self.renderable_formats_for name_string
107
+ erbs_available.select { _1.name == name_string }
108
+ end
109
+
110
+ def self.erbs_for format, names, allow_missing:
111
+ @erbs_for ||= {}
112
+ k = "#{format}-#{names.join("-")}"
113
+ @erbs_for[k] ||= _erbs_for format, names, allow_missing:
114
+ end
115
+
116
+ def self._erbs_for format, names, allow_missing:
117
+ ret = {}
118
+
119
+ log_erb = log_level? :lower
120
+
121
+ converters = DevBox.converters_to[format] || []
122
+ converters_from = converters.map { _1[:from] }
123
+ format_with_converters_from = [format, *converters_from]
124
+ log "names #{names.join(" ").green} | formats #{format_with_converters_from.join(" ").green}" if log_erb
125
+
126
+ names.each do |name|
127
+ name_string = name.to_s
128
+ log " #{name_string}#{".*.erb # filtering name "} #{renderable_names.join(" ")}".light_black if log_erb
129
+
130
+ name_candidates = renderable_formats_for name_string
131
+ if name_candidates.none?
132
+
133
+ if allow_missing
134
+ log " #{name_string}.#{format}.erb not found, but allow_missing: true".light_yellow if log_erb
135
+ found = Liza::Unit.erbs_defined.first
136
+ else
137
+ log " #{name}.#{format}.erb not found, and allow_missing: false".red
138
+ raise RendererNotFound, "ERB #{name}.#{format}.erb not found"
139
+ end
140
+
141
+ else
142
+
143
+ log " #{name_string}#{".*.erb # filtering format "}#{name_candidates.map(&:format).join(" ")}".light_black if log_erb
144
+
145
+ found = name_candidates.find do |erb|
146
+ erb_format_sym = erb.format.to_sym
147
+ format_with_converters_from.include? erb_format_sym
148
+ end
149
+
150
+ if found
151
+ log " #{found.key} found".green if log_erb
152
+ else
153
+ if allow_missing
154
+ log " #{name}.#{format}.erb not found, but allow_missing: true".light_yellow if log_erb
155
+ found = Liza::Unit.erbs_defined.first
156
+ else
157
+ log " #{name}.#{format}.erb not found, and allow_missing: false".red
158
+ raise RendererNotFound, "ERB #{name}.#{format}.erb not found"
159
+ end
160
+ end
161
+
162
+ end
163
+
164
+ ret[name] = found
165
+ end
166
+
167
+ ret
168
+ end
169
+ end
170
+
171
+ end
@@ -0,0 +1,15 @@
1
+ class Liza::UnitRendererPartTest < Liza::UnitTest
2
+
3
+ test :erbs_defined do
4
+ erbs_defined = Unit.erbs_defined.map(&:key)
5
+ expected = ["render.txt.erb"]
6
+ assert_equality erbs_defined, expected
7
+ end
8
+
9
+ test :erbs_available do
10
+ erbs_available = Unit.erbs_available.map(&:key)
11
+ expected = []
12
+ assert_equality erbs_available, expected
13
+ end
14
+
15
+ end