lizarb 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -13
  3. data/Rakefile +38 -0
  4. data/app/dev_box.rb +26 -4
  5. data/app/happy_box.rb +2 -2
  6. data/app/net/databases/sqlite_db_test.rb +5 -5
  7. data/app/net/records/app_record_test.rb +1 -1
  8. data/app/net/records/post_record_test.rb +1 -1
  9. data/app/net/records/user_record_test.rb +1 -1
  10. data/app/net_box.rb +9 -9
  11. data/app/web_box.rb +4 -4
  12. data/app.rb +6 -7
  13. data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
  14. data/app_global.gemfile.rb.lock +19 -0
  15. data/app_global.rb +4 -0
  16. data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
  17. data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
  18. data/app_new/dev/benches/objects_bench.rb +83 -0
  19. data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
  20. data/app_new/dev/benches/sorted_bench.rb +54 -0
  21. data/app_new/dev/benches/sorted_bench_test.rb +12 -0
  22. data/app_new/dev/benches/variables_bench.rb +55 -0
  23. data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
  24. data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
  25. data/{app → app_new}/dev/commands/circle_command.rb +1 -1
  26. data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
  27. data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
  28. data/app_new/dev_box.rb +14 -0
  29. data/app_new.rb +15 -0
  30. data/exe/lizarb +9 -1
  31. data/lib/app.rb +27 -95
  32. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +23 -18
  33. data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
  34. data/lib/dev_system/dev/controllers/bench.rb +1 -9
  35. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  36. data/lib/dev_system/dev/controllers/command/bench_command.rb +19 -22
  37. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  38. data/lib/dev_system/dev/controllers/command/generate_command.rb +5 -31
  39. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  40. data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
  41. data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
  42. data/lib/dev_system/dev/controllers/command/not_found_command.rb +37 -18
  43. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
  44. data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
  45. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
  46. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
  47. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command.rb +9 -15
  49. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  51. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +33 -37
  52. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  53. data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
  54. data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
  55. data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
  56. data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
  57. data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
  58. data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
  59. data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
  60. data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
  61. data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
  62. data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
  63. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
  64. data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
  65. data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
  66. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -17
  67. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
  68. data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
  69. data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
  70. data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
  71. data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
  72. data/lib/dev_system/dev/controllers/log.rb +3 -0
  73. data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
  74. data/lib/dev_system/dev/controllers/shell.rb +22 -0
  75. data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
  76. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +15 -11
  77. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  78. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  79. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  80. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  81. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  82. data/lib/dev_system/dev/dev_box.rb +27 -16
  83. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  84. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  85. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  86. data/lib/dev_system/dev/panels/command_panel.rb +59 -18
  87. data/lib/dev_system/dev/panels/command_panel_test.rb +43 -20
  88. data/lib/dev_system/dev/panels/generator_panel.rb +73 -0
  89. data/lib/dev_system/dev/panels/generator_panel_test.rb +46 -0
  90. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  91. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  92. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  93. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  94. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  95. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  96. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  97. data/lib/happy_system/happy/happy_box.rb +5 -9
  98. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  99. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  100. data/lib/lerb.rb +95 -49
  101. data/lib/liza/base/box.rb +76 -26
  102. data/lib/liza/base/box_test.rb +7 -9
  103. data/lib/liza/base/controller.rb +19 -21
  104. data/lib/liza/base/controller_test.rb +7 -9
  105. data/lib/liza/base/panel.rb +40 -27
  106. data/lib/liza/base/panel_test.rb +36 -12
  107. data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
  108. data/lib/liza/meta/part.rb +12 -14
  109. data/lib/liza/meta/part_extension.rb +14 -16
  110. data/lib/liza/meta/part_test.rb +4 -6
  111. data/lib/liza/meta/system.rb +12 -14
  112. data/lib/liza/meta/system_test.rb +8 -10
  113. data/lib/liza/ruby_test.rb +4 -6
  114. data/lib/liza/ruby_tests/module_test.rb +3 -3
  115. data/lib/liza/test/test.rb +7 -10
  116. data/lib/liza/test/test_test.rb +160 -157
  117. data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
  118. data/lib/liza/test_parts/test_assertions_part.rb +81 -83
  119. data/lib/liza/test_parts/test_dsl_part.rb +47 -49
  120. data/lib/liza/test_parts/test_log_part.rb +88 -90
  121. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  122. data/lib/liza/test_parts/test_tree_part.rb +73 -120
  123. data/lib/liza/unit.rb +105 -107
  124. data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
  125. data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
  126. data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
  127. data/lib/liza/unit_test.rb +80 -71
  128. data/lib/liza.rb +10 -1
  129. data/lib/lizarb/ruby/module.rb +1 -1
  130. data/lib/lizarb/version.rb +1 -1
  131. data/lib/lizarb.rb +247 -23
  132. data/lib/net_system/dev/net_command.rb +15 -17
  133. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  134. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  135. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  136. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  137. data/lib/net_system/net/controllers/client.rb +1 -3
  138. data/lib/net_system/net/controllers/client_test.rb +8 -10
  139. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  140. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  141. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  142. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  143. data/lib/net_system/net/controllers/database.rb +21 -23
  144. data/lib/net_system/net/controllers/database_test.rb +8 -10
  145. data/lib/net_system/net/controllers/record.rb +21 -23
  146. data/lib/net_system/net/controllers/record_test.rb +8 -10
  147. data/lib/net_system/net/net_box.rb +9 -16
  148. data/lib/net_system/net/net_box_test.rb +12 -14
  149. data/lib/net_system/net/panels/client_panel.rb +1 -3
  150. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  151. data/lib/net_system/net/panels/database_panel.rb +6 -8
  152. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  153. data/lib/web_system/dev/rack_command.rb +20 -18
  154. data/lib/web_system/dev/request_command.rb +8 -22
  155. data/lib/web_system/dev/web_command.rb +6 -8
  156. data/lib/web_system/web/controllers/rack.rb +4 -6
  157. data/lib/web_system/web/controllers/rack_test.rb +11 -13
  158. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
  159. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
  160. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
  161. data/lib/web_system/web/controllers/request.rb +1 -3
  162. data/lib/web_system/web/controllers/request_test.rb +11 -13
  163. data/lib/web_system/web/panels/rack_panel.rb +37 -39
  164. data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
  165. data/lib/web_system/web/panels/request_panel.rb +53 -57
  166. data/lib/web_system/web/panels/request_panel_test.rb +1 -1
  167. data/lib/web_system/web/web_box.rb +12 -18
  168. data/lib/web_system/web/web_box_test.rb +11 -13
  169. data/lizarb.gemspec +1 -1
  170. metadata +54 -44
  171. data/.ruby-version +0 -1
  172. data/app/dev/benches/app_bench.rb +0 -5
  173. data/app/dev/benches/app_bench_test.rb +0 -7
  174. data/app/dev/benches/loops_bench_test.rb +0 -11
  175. data/app/dev/commands/app_command.rb +0 -5
  176. data/app/dev/commands/app_command_test.rb +0 -7
  177. data/app/dev/commands/new_command.rb +0 -9
  178. data/app/dev/commands/new_command_test.rb +0 -7
  179. data/app/dev/generators/bench_generator.rb +0 -18
  180. data/app/dev/generators/command_generator/command.rb.erb +0 -26
  181. data/app/dev/generators/command_generator.rb +0 -18
  182. data/app_new/.gitignore +0 -4
  183. data/app_new/Gemfile +0 -31
  184. data/app_new/Procfile +0 -3
  185. data/exe/Gemfile.lock +0 -13
  186. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -60
  187. data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -11
  188. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -14
  189. data/lib/dev_system/dev/controllers/command/version_command.rb +0 -9
  190. data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -14
  191. data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -96
  192. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -14
  193. /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
  194. /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
  195. /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
  196. /data/{app → app_new}/dev/commands/quadratic_command_test.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebe2ac1c0a6d2e86f70577662d985ea755707a6855e67bcc0fc1e3d8f89ac563
4
- data.tar.gz: 47544f75a230d272e38bd50adacd388d4cb8a8710da689ae24ca0fe187e7d3f6
3
+ metadata.gz: d65d5afa1b18cd8fa2dee6e92af9e1dff3f29d17c34ccc1d76f5ac5137d4b4d8
4
+ data.tar.gz: 5c38cb0eaa603cba1050fa4ecc38ecf2004a5155ba47a68e65af24a199d7005c
5
5
  SHA512:
6
- metadata.gz: 8427b2e5710ccff4f9031adc64b9ad9e3fcdc4dea4565f933dc34b91f72378230b7946e020074832c8e7f44c7c5085bc0c3dc503b98d9852a2fb207b685f41b1
7
- data.tar.gz: a8fa9c03c1cfa03947e3be6a35b610192cb2a50f5111f175b3211ee1ca35fcafbc371583c53e3b006735873fd5c07897c8dd3edcf6fb0235fac49353e19a460d
6
+ metadata.gz: fe4544def7e3a7a085427efb77707d78071e50848fdf8941ab9490fb8a131cf60594439ce5c46f556c0ae2b20ecaa5dadadd81a224bb98e082513355e25ef1ed
7
+ data.tar.gz: 50e1451cfcd9f5b6981b343a1e400fdb77c1db761c1581e1ad0c49e062225a8e45a82229ae55dbca7b69f8bb50e6791f0f5e10d4147d69aaee543253e1e08179
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lizarb (1.0.2)
4
+ lizarb (1.0.4)
5
5
  colorize (~> 0.8)
6
6
  dotenv (~> 2.8)
7
7
  zeitwerk (~> 2.6)
@@ -11,30 +11,29 @@ GEM
11
11
  specs:
12
12
  coderay (1.1.3)
13
13
  colorize (0.8.1)
14
- connection_pool (2.3.0)
14
+ connection_pool (2.4.0)
15
15
  dotenv (2.8.1)
16
16
  htmlbeautifier (1.4.2)
17
17
  method_source (1.0.0)
18
- mini_portile2 (2.8.1)
19
- nio4r (2.5.8)
20
- pry (0.14.1)
18
+ nio4r (2.5.9)
19
+ pry (0.14.2)
21
20
  coderay (~> 1.1)
22
21
  method_source (~> 1.0)
23
22
  puma (5.6.5)
24
23
  nio4r (~> 2.0)
25
- rack (3.0.0)
26
- rackup (0.2.2)
24
+ rack (3.0.7)
25
+ rackup (0.2.3)
27
26
  rack (>= 3.0.0.beta1)
28
27
  webrick
29
28
  rake (13.0.6)
30
- redis (5.0.5)
29
+ redis (5.0.6)
31
30
  redis-client (>= 0.9.0)
32
- redis-client (0.10.0)
31
+ redis-client (0.14.1)
33
32
  connection_pool
34
- sqlite3 (1.5.4)
35
- mini_portile2 (~> 2.8.0)
36
- webrick (1.7.0)
37
- zeitwerk (2.6.7)
33
+ sqlite3 (1.6.3-arm64-darwin)
34
+ sqlite3 (1.6.3-x86_64-linux)
35
+ webrick (1.8.1)
36
+ zeitwerk (2.6.8)
38
37
 
39
38
  PLATFORMS
40
39
  arm64-darwin-21
data/Rakefile CHANGED
@@ -1,6 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+
5
+ # Replaced tasks
6
+
4
7
  task default: %i[] do
5
8
  system "lizarb test"
6
9
  end
10
+
11
+ # Custom tasks
12
+
13
+
14
+
15
+ # Custom prerequisite tasks
16
+
17
+ task :custom_gemfiles do
18
+ puts "... Bundling app_global.gemfile.rb"
19
+ system "VERBOSE=1 BUNDLE_GEMFILE=app_global.gemfile.rb bundle update"
20
+
21
+ puts "... Bundling Gemfile"
22
+ system "VERBOSE=1 BUNDLE_GEMFILE=Gemfile bundle"
23
+
24
+ puts "... Installing lizarb"
25
+ end
26
+
27
+ # Custom post-requisite tasks
28
+
29
+ task :custom_post_task do
30
+ puts "! Done"
31
+ # Add your custom behavior here
32
+ end
33
+
34
+ # Enhance
35
+
36
+ # Enhance the existing `build` task with the prerequisite
37
+
38
+ Rake::Task["build"].enhance [:custom_gemfiles]
39
+
40
+ # Enhance the existing `install` task with the post-requisite
41
+
42
+ Rake::Task["install"].enhance do
43
+ Rake.application.invoke_task :custom_post_task
44
+ end
data/app/dev_box.rb CHANGED
@@ -1,13 +1,35 @@
1
1
  class DevBox < Liza::DevBox
2
2
 
3
- commands do
4
- # Set up your command panel per the DSL in http://guides.lizarb.com/panels/command.html
3
+ # Configure your bench panel per the DSL in http://guides.lizarb.org/panels/bench.html
4
+ configure :bench do
5
+ # set :log_level, ENV["dev.bench.log_level"]
6
+ end
7
+
8
+ # Configure your command panel per the DSL in http://guides.lizarb.org/panels/command.html
9
+ configure :command do
10
+ # set :log_level, ENV["dev.command.log_level"]
11
+ set :log_details, false
12
+ end
5
13
 
14
+ # Configure your generator panel per the DSL in http://guides.lizarb.org/panels/generator.html
15
+ configure :generator do
16
+ # set :log_level, ENV["dev.generator.log_level"]
17
+ set :log_details, false
6
18
  end
7
19
 
8
- logs do
9
- # Set up your log panel per the DSL in http://guides.lizarb.com/panels/log.html
20
+ # Configure your command panel per the DSL in http://guides.lizarb.org/panels/log.html
21
+ configure :log do
22
+ # set :log_level, ENV["dev.log.log_level"]
23
+ end
24
+
25
+ # Configure your shell panel per the DSL in http://guides.lizarb.org/panels/shell.html
26
+ configure :shell do
27
+ # set :log_level, ENV["dev.shell.log_level"]
28
+ end
10
29
 
30
+ # Configure your terminal panel per the DSL in http://guides.lizarb.org/panels/terminal.html
31
+ configure :terminal do
32
+ # set :log_level, ENV["dev.terminal.log_level"]
11
33
  end
12
34
 
13
35
  end
data/app/happy_box.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class HappyBox < Liza::HappyBox
2
2
 
3
- axo do
4
- # Set up your axo panel per the DSL in http://guides.lizarb.com/panels/axo.html
3
+ configure :axo do
4
+ # Configure your axo panel per the DSL in http://guides.lizarb.com/panels/axo.html
5
5
 
6
6
  end
7
7
 
@@ -2,11 +2,11 @@ class SqliteDbTest < Liza::SqliteDbTest
2
2
 
3
3
  test :subject_class do
4
4
  assert subject_class == SqliteDb
5
- assert SqliteDb.current.class == SqliteDb
6
- assert Liza::SqliteDb.current.class == SqliteDb
7
- assert SqliteDb.current == Liza::SqliteDb.current
8
- assert SqliteDb.current.client == Liza::SqliteDb.current.client
9
- assert SqliteDb.current.client.conn == Liza::SqliteDb.current.client.conn
5
+ # assert SqliteDb.current.class == SqliteDb
6
+ # assert Liza::SqliteDb.current.class == SqliteDb
7
+ # assert SqliteDb.current == Liza::SqliteDb.current
8
+ # assert SqliteDb.current.client == Liza::SqliteDb.current.client
9
+ # assert SqliteDb.current.client.conn == Liza::SqliteDb.current.client.conn
10
10
  end
11
11
 
12
12
  end
@@ -2,7 +2,7 @@ class AppRecordTest < Liza::RecordTest
2
2
 
3
3
  test :subject_class do
4
4
  assert subject_class == AppRecord
5
- assert subject_class.db == SqliteDb.current
5
+ assert subject_class.db == SqliteDb
6
6
  end
7
7
 
8
8
  end
@@ -2,7 +2,7 @@ class PostRecordTest < Liza::RecordTest
2
2
 
3
3
  test :subject_class do
4
4
  assert subject_class == PostRecord
5
- assert subject_class.db == SqliteDb.current
5
+ assert subject_class.db == SqliteDb
6
6
  end
7
7
 
8
8
  end
@@ -2,7 +2,7 @@ class UserRecordTest < Liza::RecordTest
2
2
 
3
3
  test :subject_class do
4
4
  assert subject_class == UserRecord
5
- assert subject_class.db == SqliteDb.current
5
+ assert subject_class.db == SqliteDb
6
6
  end
7
7
 
8
8
  end
data/app/net_box.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  class NetBox < Liza::NetBox
2
2
 
3
- clients do
4
- # Set up your client panel per the DSL in http://guides.lizarb.org/panels/client.html
3
+ configure :client do
4
+ # Configure your client panel per the DSL in http://guides.lizarb.org/panels/client.html
5
5
 
6
6
  set :redis_url, "redis://localhost:6379/15"
7
- set :sqlite, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
8
- set :sqlite, "app.#{App.mode}.sqlite"
7
+ set :sqlite_path, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
8
+ set :sqlite_path, "app.#{App.mode}.sqlite"
9
9
 
10
10
  end
11
11
 
12
- databases do
13
- # Set up your database panel per the DSL in http://guides.lizarb.org/panels/database.html
12
+ configure :database do
13
+ # Configure your database panel per the DSL in http://guides.lizarb.org/panels/database.html
14
14
 
15
- define :redis, RedisDb.current
16
- define :sql, SqliteDb.current
17
- define :sqlite, SqliteDb.current
15
+ define :redis, RedisDb
16
+ define :sql, SqliteDb
17
+ define :sqlite, SqliteDb
18
18
 
19
19
  end
20
20
 
data/app/web_box.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  class WebBox < Liza::WebBox
2
2
 
3
- rack do
4
- # Set up your rack panel per the DSL in http://guides.lizarb.org/panels/rack.html
3
+ configure :rack do
4
+ # Configure your rack panel per the DSL in http://guides.lizarb.org/panels/rack.html
5
5
 
6
6
  # set :files, App.root.join("web_files")
7
7
  # set :host, "localhost"
8
8
  # set :port, 3000
9
9
  end
10
10
 
11
- requests do
12
- # Set up your request panel per the DSL in http://guides.lizarb.org/panels/request.html
11
+ configure :request do
12
+ # Configure your request panel per the DSL in http://guides.lizarb.org/panels/request.html
13
13
 
14
14
  end
15
15
 
data/app.rb CHANGED
@@ -1,17 +1,16 @@
1
- App.call ARGV do
1
+ class App
2
2
 
3
+ # Modes help you organize your application's behavior and settings.
4
+
5
+ mode :code
6
+ mode :demo
7
+
3
8
  # Systems help you organize your application's dependencies and RAM memory usage.
4
- # Learn more: http://guides.lizarb.org/systems.html
5
9
 
6
10
  system :dev
7
11
  system :happy
8
12
  system :net
9
13
  system :web
10
14
 
11
- # Modes help you organize your application's behavior and settings.
12
- # Learn more: http://guides.lizarb.org/modes.html
13
-
14
- mode :code
15
- mode :demo
16
15
 
17
16
  end
@@ -1,3 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source "https://rubygems.org"
4
+
5
+ gem "lizarb", "~> 1.0"
@@ -0,0 +1,19 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ colorize (0.8.1)
5
+ dotenv (2.8.1)
6
+ lizarb (1.0.4)
7
+ colorize (~> 0.8)
8
+ dotenv (~> 2.8)
9
+ zeitwerk (~> 2.6)
10
+ zeitwerk (2.6.8)
11
+
12
+ PLATFORMS
13
+ x86_64-linux
14
+
15
+ DEPENDENCIES
16
+ lizarb (~> 1.0)
17
+
18
+ BUNDLED WITH
19
+ 2.4.1
data/app_global.rb ADDED
@@ -0,0 +1,4 @@
1
+ class App
2
+ mode :code
3
+ system :dev
4
+ end
@@ -1,5 +1,4 @@
1
- class LoopsBench < AppBench
2
- main_dsl
1
+ class LoopsBench < SortedBench
3
2
 
4
3
  setup do
5
4
  N = 1_000_000
@@ -8,6 +7,8 @@ class LoopsBench < AppBench
8
7
  HASH_INT = RANGE.map { |i| [i, i] }.to_h
9
8
  HASH_STR = RANGE.map { |i| ["a#{i}", i] }.to_h
10
9
  HASH_SYM = RANGE.map { |i| [:"a#{i}", i] }.to_h
10
+
11
+ log "setup N = #{N}"
11
12
  end
12
13
 
13
14
  mark "for i in RANGE" do
@@ -1,7 +1,7 @@
1
- class BenchGeneratorTest < Liza::GeneratorTest
1
+ class LoopsBenchTest < SortedBenchTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == BenchGenerator
4
+ assert subject_class == LoopsBench
5
5
  end
6
6
 
7
7
  test :settings do
@@ -0,0 +1,83 @@
1
+ class ObjectsBench < SortedBench
2
+
3
+ setup do
4
+ N = 1_000_000
5
+ # N = 10_000_000
6
+ # N = 100_000_000
7
+
8
+ log "setup N = #{N}"
9
+ end
10
+
11
+ mark "BasicObject.new" do
12
+ i = 0
13
+
14
+ while (i += 1) <= N
15
+ BasicObject.new
16
+ end
17
+ end
18
+
19
+ mark "Object.new" do
20
+ i = 0
21
+
22
+ while (i += 1) <= N
23
+ Object.new
24
+ end
25
+ end
26
+
27
+ mark "String.new" do
28
+ i = 0
29
+
30
+ while (i += 1) <= N
31
+ String.new
32
+ end
33
+ end
34
+
35
+ mark "Numeric.new" do
36
+ i = 0
37
+
38
+ while (i += 1) <= N
39
+ Numeric.new
40
+ end
41
+ end
42
+
43
+ mark "Time.new" do
44
+ i = 0
45
+
46
+ while (i += 1) <= N
47
+ Time.new
48
+ end
49
+ end
50
+
51
+ mark "Proc.new {}" do
52
+ i = 0
53
+
54
+ while (i += 1) <= N
55
+ Proc.new {}
56
+ end
57
+ end
58
+
59
+ mark "Set.new" do
60
+ i = 0
61
+
62
+ while (i += 1) <= N
63
+ Set.new
64
+ end
65
+ end
66
+
67
+ mark "Array.new" do
68
+ i = 0
69
+
70
+ while (i += 1) <= N
71
+ Array.new
72
+ end
73
+ end
74
+
75
+ mark "Hash.new" do
76
+ i = 0
77
+
78
+ while (i += 1) <= N
79
+ Hash.new
80
+ end
81
+ end
82
+
83
+ end
@@ -1,7 +1,7 @@
1
- class RecordGeneratorTest < Liza::GeneratorTest
1
+ class ObjectsBenchTest < SortedBenchTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == RecordGenerator
4
+ assert subject_class == ObjectsBench
5
5
  end
6
6
 
7
7
  test :settings do
@@ -0,0 +1,54 @@
1
+ class SortedBench < Liza::Bench
2
+
3
+ def self.call args
4
+ log "args = #{args.inspect}"
5
+
6
+ # https://rubyapi.org/3.1/o/benchmark
7
+ require "benchmark"
8
+
9
+ if @setup_bl
10
+ log "Setting up..."
11
+ instance_exec &@setup_bl
12
+ log "Set up"
13
+ end
14
+
15
+ log "Benchmarking #{marks.count} Ruby Blocks"
16
+ puts
17
+
18
+ length = marks.keys.map(&:length).max
19
+
20
+ marks.each do |label, bl|
21
+ log "Benchmarking #{label}"
22
+ marks[label] = Benchmark.measure label, &bl
23
+ end
24
+
25
+ puts
26
+
27
+ log "#{"Reporting".ljust_blanks(length + 17)} App CPU Time Kernel CPU Time Total CPU Time"
28
+ puts
29
+
30
+ sorted = marks.sort_by { |_k, tms| tms.total }.to_h
31
+
32
+ sorted.each.with_index do |(label, tms), i|
33
+ tms = tms.format "%10.6u %10.6y %10.6t"
34
+ s = "[#{i.next.to_s.rjust_zeroes 2}/#{marks.count.to_s.rjust_zeroes 2}] #{label.rjust_blanks length} #{tms}"
35
+
36
+ s = s.green if i == 0
37
+ s = s.red if i == marks.count-1
38
+ log s
39
+ end
40
+ puts
41
+ log "Done"
42
+ end
43
+
44
+ #
45
+
46
+ def self.marks()= @marks ||= {}
47
+
48
+ def self.mark(label, &block)= marks[label] = block
49
+
50
+ def self.setup &block
51
+ @setup_bl = block if block_given?
52
+ end
53
+
54
+ end
@@ -0,0 +1,12 @@
1
+ class SortedBenchTest < Liza::BenchTest
2
+
3
+ test :subject_class do
4
+ assert_equality subject_class, SortedBench
5
+ end
6
+
7
+ test :settings do
8
+ assert_equality subject_class.log_level, :normal
9
+ assert_equality subject_class.log_color, :green
10
+ end
11
+
12
+ end
@@ -0,0 +1,55 @@
1
+ class VariablesBench < SortedBench
2
+
3
+ setup do
4
+ LETTERS = (Array("a".."z")+Array("A".."Z"))
5
+ N = 1_000
6
+ # N = 10_000
7
+ # N = 100_000
8
+
9
+ log "setup N = #{N}"
10
+ end
11
+
12
+ mark "local variable" do
13
+ i = 0
14
+ a = nil
15
+
16
+ while (i += 1) <= N
17
+ eval "v_#{random_name} = sample"
18
+ end
19
+ end
20
+
21
+ mark "instance variable" do
22
+ i = 0
23
+
24
+ while (i += 1) <= N
25
+ eval "@v_#{random_name} = sample"
26
+ end
27
+ end
28
+
29
+ mark "class variable" do
30
+ i = 0
31
+
32
+ while (i += 1) <= N
33
+ eval "@@v_#{random_name} = sample"
34
+ end
35
+ end
36
+
37
+ mark "global variable" do
38
+ i = 0
39
+
40
+ while (i += 1) <= N
41
+ eval "$v_#{random_name} = sample"
42
+ end
43
+ end
44
+
45
+ # helper methods
46
+
47
+ def self.random_name
48
+ LETTERS.shuffle.join("")
49
+ end
50
+
51
+ def self.sample
52
+ LETTERS.sample
53
+ end
54
+
55
+ end
@@ -1,7 +1,7 @@
1
- class CommandGeneratorTest < Liza::GeneratorTest
1
+ class VariablesBenchTest < SortedBenchTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == CommandGenerator
4
+ assert subject_class == VariablesBench
5
5
  end
6
6
 
7
7
  test :settings do
@@ -40,7 +40,7 @@ end
40
40
 
41
41
  __END__
42
42
 
43
- # help.txt.erb
43
+ # view help.txt.erb
44
44
 
45
45
  NAME:
46
46
 
@@ -45,7 +45,7 @@ end
45
45
 
46
46
  __END__
47
47
 
48
- # help.txt.erb
48
+ # view help.txt.erb
49
49
 
50
50
  NAME:
51
51
 
@@ -3,17 +3,17 @@ class NarrativeMethodCommand < Liza::Command
3
3
  class Invalid < Error; end
4
4
 
5
5
  def self.call(args)
6
- log "Called #{self}.#{__method__} with args #{args}"
6
+ log "args = #{args.inspect}"
7
7
  new.call(args)
8
8
  end
9
9
 
10
10
  # instance methods
11
11
 
12
12
  def call(args)
13
- log "Called #{self}.#{__method__} with args #{args}"
13
+ @args = args
14
+ log "@args = #{args.inspect}"
14
15
  return help if args.empty?
15
16
 
16
- @args = args
17
17
  validate
18
18
  perform
19
19
  rescue StandardError => error
@@ -32,26 +32,24 @@ class NarrativeMethodCommand < Liza::Command
32
32
  end
33
33
 
34
34
  def handle
35
- log "Called #{self}.#{__method__}"
36
35
  log render "error.txt"
37
36
  end
38
37
 
39
38
  def help
40
- log "Called #{self}.#{__method__}"
41
39
  log render "help.txt"
42
40
  end
43
41
  end
44
42
 
45
43
  __END__
46
44
 
47
- # success.txt.erb
45
+ # view success.txt.erb
48
46
 
49
47
  RESULT:
50
48
 
51
49
  class <%= @result.class %>
52
50
  value <%= @result %>
53
51
 
54
- # error.txt.erb
52
+ # view error.txt.erb
55
53
 
56
54
  ERROR:
57
55
 
@@ -42,7 +42,7 @@ end
42
42
 
43
43
  __END__
44
44
 
45
- # help.txt.erb
45
+ # view help.txt.erb
46
46
 
47
47
  NAME:
48
48
 
@@ -0,0 +1,14 @@
1
+ class DevBox < Liza::DevBox
2
+
3
+ configure :bench do
4
+ #
5
+ end
6
+
7
+ configure :command do
8
+ set :log_details, false
9
+
10
+ short :b, :bench
11
+ short :g, :generate
12
+ end
13
+
14
+ end