lizarb 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.tool-versions +1 -0
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +7 -4
  6. data/README.md +23 -64
  7. data/README_SYSTEMS.md +80 -0
  8. data/Rakefile +3 -1
  9. data/app/dev/benches/loops_bench.rb +35 -0
  10. data/app/dev/commands/calculator_command.rb +69 -0
  11. data/app/dev/commands/calculator_command_test.rb +58 -0
  12. data/app/dev/commands/circle_command.rb +70 -0
  13. data/app/dev/commands/circle_command_test.rb +76 -0
  14. data/app/dev/commands/narrative_method_command.rb +60 -0
  15. data/app/dev/commands/narrative_method_command_test.rb +36 -0
  16. data/app/dev/commands/quadratic_command.rb +66 -0
  17. data/app/dev/commands/quadratic_command_test.rb +47 -0
  18. data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
  19. data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
  20. data/app/dev/generators/bench_generator.rb +2 -51
  21. data/app/dev/generators/command_generator/command.rb.erb +26 -0
  22. data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
  23. data/app/dev/generators/command_generator.rb +2 -35
  24. data/app/dev/generators/record_generator.rb +46 -0
  25. data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
  26. data/app/dev_box.rb +24 -4
  27. data/app/happy_box.rb +1 -1
  28. data/app/net/databases/sqlite_db_test.rb +5 -5
  29. data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
  30. data/app/net/records/app_record_test.rb +8 -0
  31. data/app/net/records/post_record.rb +4 -0
  32. data/app/net/records/post_record_test.rb +8 -0
  33. data/app/net/records/user_record.rb +4 -0
  34. data/app/net/records/user_record_test.rb +8 -0
  35. data/app/net_box.rb +7 -7
  36. data/app/web/requests/api_request.rb +8 -7
  37. data/app/web/requests/assets_request.rb +12 -13
  38. data/app/web/requests/root_request.rb +6 -7
  39. data/app/web/requests/root_request_test.rb +1 -1
  40. data/app/web_box.rb +9 -1
  41. data/exe/lrb +3 -0
  42. data/lib/app.rb +19 -15
  43. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
  44. data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
  45. data/lib/dev_system/dev/controllers/bench.rb +5 -7
  46. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
  47. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
  49. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
  51. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
  52. data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
  53. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  54. data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
  55. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
  56. data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
  57. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
  58. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
  59. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  60. data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
  61. data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
  62. data/lib/dev_system/dev/controllers/command.rb +11 -13
  63. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  64. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  65. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
  66. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  67. data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
  68. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
  69. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
  70. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
  71. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
  72. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
  73. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
  74. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
  75. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -0
  76. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -0
  77. data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
  78. data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
  79. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
  80. data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
  81. data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
  82. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
  83. data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
  84. data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
  85. data/lib/dev_system/dev/controllers/shell.rb +26 -14
  86. data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
  87. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
  88. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  89. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  90. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  91. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  92. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  93. data/lib/dev_system/dev/dev_box.rb +33 -16
  94. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  95. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  96. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  97. data/lib/dev_system/dev/panels/command_panel.rb +24 -6
  98. data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
  99. data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
  100. data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
  101. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  102. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  103. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  104. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  105. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  106. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  107. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  108. data/lib/happy_system/happy/happy_box.rb +6 -9
  109. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  110. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  111. data/lib/lerb.rb +106 -0
  112. data/lib/liza/base/box.rb +71 -26
  113. data/lib/liza/base/box_test.rb +7 -9
  114. data/lib/liza/base/controller.rb +19 -19
  115. data/lib/liza/base/controller_test.rb +7 -9
  116. data/lib/liza/base/panel.rb +40 -24
  117. data/lib/liza/base/panel_test.rb +10 -12
  118. data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
  119. data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
  120. data/lib/liza/meta/part.rb +12 -14
  121. data/lib/liza/meta/part_extension.rb +14 -11
  122. data/lib/liza/meta/part_test.rb +4 -6
  123. data/lib/liza/meta/system.rb +12 -14
  124. data/lib/liza/meta/system_test.rb +8 -10
  125. data/lib/liza/ruby_test.rb +7 -0
  126. data/lib/liza/ruby_tests/module_test.rb +21 -0
  127. data/lib/liza/ruby_tests/string_test.rb +59 -0
  128. data/lib/liza/test/test.rb +7 -8
  129. data/lib/liza/test/test_test.rb +168 -76
  130. data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
  131. data/lib/liza/test_parts/test_assertions_part.rb +81 -82
  132. data/lib/liza/test_parts/test_dsl_part.rb +44 -98
  133. data/lib/liza/test_parts/test_log_part.rb +122 -0
  134. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  135. data/lib/liza/test_parts/test_tree_part.rb +137 -0
  136. data/lib/liza/unit.rb +108 -102
  137. data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
  138. data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
  139. data/lib/liza/unit_test.rb +69 -71
  140. data/lib/liza.rb +5 -0
  141. data/lib/lizarb/ruby/module.rb +17 -0
  142. data/lib/lizarb/ruby/string.rb +10 -2
  143. data/lib/lizarb/version.rb +1 -1
  144. data/lib/lizarb.rb +24 -2
  145. data/lib/net_system/dev/net_command.rb +10 -12
  146. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  147. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  148. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  149. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  150. data/lib/net_system/net/controllers/client.rb +1 -3
  151. data/lib/net_system/net/controllers/client_test.rb +8 -10
  152. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  153. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  154. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  155. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  156. data/lib/net_system/net/controllers/database.rb +21 -23
  157. data/lib/net_system/net/controllers/database_test.rb +8 -10
  158. data/lib/net_system/net/controllers/record.rb +29 -0
  159. data/lib/net_system/net/controllers/record_test.rb +12 -0
  160. data/lib/net_system/net/net_box.rb +11 -16
  161. data/lib/net_system/net/net_box_test.rb +12 -14
  162. data/lib/net_system/net/panels/client_panel.rb +1 -3
  163. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  164. data/lib/net_system/net/panels/database_panel.rb +6 -8
  165. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  166. data/lib/web_system/dev/rack_command.rb +35 -0
  167. data/lib/web_system/dev/request_command.rb +143 -0
  168. data/lib/web_system/dev/web_command.rb +6 -39
  169. data/lib/web_system/web/controllers/rack.rb +6 -0
  170. data/lib/web_system/web/controllers/rack_test.rb +16 -0
  171. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
  172. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
  173. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
  174. data/lib/web_system/web/controllers/request.rb +1 -3
  175. data/lib/web_system/web/controllers/request_test.rb +11 -13
  176. data/lib/web_system/web/panels/rack_panel.rb +42 -0
  177. data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
  178. data/lib/web_system/web/panels/request_panel.rb +54 -37
  179. data/lib/web_system/web/panels/request_panel_test.rb +28 -9
  180. data/lib/web_system/web/web_box.rb +16 -8
  181. data/lib/web_system/web/web_box_test.rb +11 -13
  182. data/lizarb.gemspec +2 -2
  183. metadata +76 -28
  184. data/app/dev/commands/example_command.rb +0 -57
  185. data/app/dev/commands/example_command_test.rb +0 -43
  186. data/app/dev/commands/macro_child_command.rb +0 -32
  187. data/app/dev/commands/macro_child_command_test.rb +0 -7
  188. data/app/dev/commands/macro_parent_command.rb +0 -70
  189. data/app/dev/commands/macro_parent_command_test.rb +0 -7
  190. data/app/dev/commands/my_command.rb +0 -7
  191. data/app/dev/commands/my_command_test.rb +0 -7
  192. data/app/dev/generators/model_generator.rb +0 -46
  193. data/app/net/models/app_model_test.rb +0 -8
  194. data/app/net/models/post_model.rb +0 -4
  195. data/app/net/models/post_model_test.rb +0 -8
  196. data/app/net/models/user_model.rb +0 -4
  197. data/app/net/models/user_model_test.rb +0 -8
  198. data/app_new/.gitignore +0 -4
  199. data/app_new/Gemfile +0 -31
  200. data/app_new/Procfile +0 -3
  201. data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
  202. data/lib/liza/test_parts/test_context_part.rb +0 -81
  203. data/lib/net_system/net/controllers/model.rb +0 -31
  204. data/lib/net_system/net/controllers/model_test.rb +0 -14
data/lib/app.rb CHANGED
@@ -11,6 +11,10 @@ module App
11
11
  puts s.bold
12
12
  end
13
13
 
14
+ def logv s
15
+ log s if $VERBOSE
16
+ end
17
+
14
18
  # called from "#{APP_DIR}/app"
15
19
  def call argv, &block
16
20
  instance_exec &block
@@ -23,7 +27,7 @@ module App
23
27
  check_mode!
24
28
 
25
29
  puts
26
- ::DevBox.commands.call argv
30
+ DevBox[:command].call argv
27
31
  puts
28
32
  end
29
33
 
@@ -48,8 +52,8 @@ module App
48
52
  loader.tag = Liza.to_s
49
53
 
50
54
  # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
51
- loader.collapse "#{fname_for Liza}/**/*"
52
- loader.push_dir "#{fname_for Liza}", namespace: Liza
55
+ loader.collapse "#{Liza.source_location_radical}/**/*"
56
+ loader.push_dir "#{Liza.source_location_radical}", namespace: Liza
53
57
 
54
58
  loader.enable_reloading
55
59
  loader.setup
@@ -69,8 +73,8 @@ module App
69
73
 
70
74
  @systems.each do |k, klass|
71
75
  # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
72
- loader.collapse "#{fname_for klass}/**/*"
73
- loader.push_dir "#{fname_for klass}", namespace: klass
76
+ loader.collapse "#{klass.source_location_radical}/**/*"
77
+ loader.push_dir "#{klass.source_location_radical}", namespace: klass
74
78
  end
75
79
 
76
80
  # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
@@ -83,6 +87,8 @@ module App
83
87
  @systems.each do |k, klass|
84
88
  connect_system k, klass
85
89
  end
90
+
91
+ @systems.freeze
86
92
  end
87
93
 
88
94
  # loaders
@@ -133,7 +139,10 @@ module App
133
139
  end
134
140
 
135
141
  def self.require_system key
142
+ t = Time.now
143
+ logv "App.system :#{key}"
136
144
  require key
145
+ logv "App.system :#{key} takes #{t.diff}s"
137
146
  rescue LoadError => e
138
147
  def e.backtrace; []; end
139
148
  raise SystemNotFound, "FILE #{key}.rb not found on $LOAD_PATH", []
@@ -142,6 +151,10 @@ module App
142
151
  # parts
143
152
 
144
153
  def connect_part part_klass, key, system
154
+ t = Time.now
155
+ string = "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}"
156
+ logv string
157
+
145
158
  klass = if system.nil?
146
159
  Liza.const "#{key}_part"
147
160
  else
@@ -149,8 +162,6 @@ module App
149
162
  .const "#{key}_part"
150
163
  end
151
164
 
152
- log "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}" if $VERBOSE
153
-
154
165
  if klass.insertion
155
166
  part_klass.class_exec &klass.insertion
156
167
  end
@@ -159,6 +170,7 @@ module App
159
170
  klass.const_set :Extension, Class.new(Liza::PartExtension)
160
171
  klass::Extension.class_exec &klass.extension
161
172
  end
173
+ logv "#{string} takes #{t.diff}s"
162
174
  end
163
175
 
164
176
  # systems
@@ -189,12 +201,4 @@ module App
189
201
  log "CONNECTING SYSTEM - #{t.diff}s for #{color_system_klass} to connect to #{registrar_index} system parts"
190
202
  end
191
203
 
192
- #
193
-
194
- def fname_for klass
195
- # /path/to/liza.rb
196
- # /path/to/liza
197
- Object.const_source_location(klass.name)[0][0..-4]
198
- end
199
-
200
204
  end
@@ -0,0 +1,27 @@
1
+ class DevSystem::NotFoundBench < DevSystem::Bench
2
+
3
+ def self.call args
4
+ # 1. LOG
5
+
6
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
7
+ puts
8
+
9
+ # 2. FIND generators
10
+
11
+ App.eager_load_all
12
+ benches = Liza::Bench.descendants
13
+
14
+ log "Liza comes with #{benches.count} benches you can use."
15
+ puts
16
+
17
+ log "Here they are:"
18
+ puts
19
+
20
+ # 3. LIST benches
21
+
22
+ keys = benches.map { |k| k.last_namespace.snakecase[0..-7] }.sort
23
+ keys.reject! { |s| s == "not_found" }
24
+ keys.each { |s| log "liza bench #{s}" }
25
+ end
26
+
27
+ end
@@ -1,8 +1,7 @@
1
- class DevSystem
2
- class DevCommandTest < CommandTest
1
+ class DevSystem::NotFoundBenchTest < DevSystem::BenchTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::DevCommand
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::NotFoundBench
6
5
  end
7
6
 
8
7
  test :settings do
@@ -10,5 +9,4 @@ class DevSystem
10
9
  assert subject_class.log_color == :green
11
10
  end
12
11
 
13
- end
14
12
  end
@@ -1,11 +1,9 @@
1
- class DevSystem
2
- class Bench < Liza::Controller
1
+ class DevSystem::Bench < Liza::Controller
3
2
 
4
- # DSLS
5
-
6
- def self.main_dsl
7
- part :"bench_dsl_main", system: :dev
8
- end
3
+ # DSLS
9
4
 
5
+ def self.main_dsl
6
+ part :"bench_dsl_main", system: :dev
10
7
  end
8
+
11
9
  end
@@ -1,60 +1,58 @@
1
- class DevSystem
2
- class BenchDslMainPart < Liza::Part
1
+ class DevSystem::BenchDslMainPart < Liza::Part
3
2
 
4
- insertion do
3
+ insertion do
5
4
 
6
- def self.call args
7
- log :higher, "Called #{self}.#{__method__} with args #{args}"
5
+ def self.call args
6
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
8
7
 
9
- # https://rubyapi.org/3.1/o/benchmark
10
- require "benchmark"
8
+ # https://rubyapi.org/3.1/o/benchmark
9
+ require "benchmark"
11
10
 
12
- if @setup_bl
13
- log "Setting up..."
14
- instance_exec &@setup_bl
15
- log "Set up"
16
- end
11
+ if @setup_bl
12
+ log "Setting up..."
13
+ instance_exec &@setup_bl
14
+ log "Set up"
15
+ end
17
16
 
18
- log "Benchmarking #{marks.count} Ruby Blocks"
19
- puts
17
+ log "Benchmarking #{marks.count} Ruby Blocks"
18
+ puts
20
19
 
21
- length = marks.keys.map(&:length).max
20
+ length = marks.keys.map(&:length).max
22
21
 
23
- marks.each do |label, bl|
24
- log "Benchmarking #{label}"
25
- marks[label] = Benchmark.measure label, &bl
26
- end
22
+ marks.each do |label, bl|
23
+ log "Benchmarking #{label}"
24
+ marks[label] = Benchmark.measure label, &bl
25
+ end
27
26
 
28
- puts
27
+ puts
29
28
 
30
- log "#{"Reporting".ljust_blanks(length + 17)} App CPU Time Kernel CPU Time Total CPU Time"
31
- puts
29
+ log "#{"Reporting".ljust_blanks(length + 17)} App CPU Time Kernel CPU Time Total CPU Time"
30
+ puts
32
31
 
33
- sorted = marks.sort_by { |_k, tms| tms.total }.to_h
32
+ sorted = marks.sort_by { |_k, tms| tms.total }.to_h
34
33
 
35
- sorted.each.with_index do |(label, tms), i|
36
- tms = tms.format "%10.6u %10.6y %10.6t"
37
- s = "[#{i.next.to_s.rjust_zeroes 2}/#{marks.count.to_s.rjust_zeroes 2}] #{label.rjust_blanks length} #{tms}"
34
+ sorted.each.with_index do |(label, tms), i|
35
+ tms = tms.format "%10.6u %10.6y %10.6t"
36
+ s = "[#{i.next.to_s.rjust_zeroes 2}/#{marks.count.to_s.rjust_zeroes 2}] #{label.rjust_blanks length} #{tms}"
38
37
 
39
- s = s.green if i == 0
40
- s = s.red if i == marks.count-1
41
- log s
42
- end
43
- puts
44
- log "Done"
38
+ s = s.green if i == 0
39
+ s = s.red if i == marks.count-1
40
+ log s
45
41
  end
42
+ puts
43
+ log "Done"
44
+ end
46
45
 
47
- #
48
-
49
- def self.marks()= @marks ||= {}
46
+ #
50
47
 
51
- def self.mark(label, &block)= marks[label] = block
48
+ def self.marks()= @marks ||= {}
52
49
 
53
- def self.setup &block
54
- @setup_bl = block if block_given?
55
- end
50
+ def self.mark(label, &block)= marks[label] = block
56
51
 
52
+ def self.setup &block
53
+ @setup_bl = block if block_given?
57
54
  end
58
55
 
59
56
  end
57
+
60
58
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class BenchTest < Liza::ControllerTest
1
+ class DevSystem::BenchTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::Bench
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::Bench
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -1,24 +1,32 @@
1
- class DevSystem
2
- class BenchCommand < Command
1
+ class DevSystem::BenchCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def self.call args
4
+ # 1. LOG
6
5
 
7
- log :higher, "args: #{args}"
8
- puts
6
+ log :higher, "args: #{args}"
7
+ puts
9
8
 
10
- # 2. FIND bench
9
+ # 2. FIND bench
11
10
 
12
- bench = args[0]
11
+ return call_not_found args if args.none?
13
12
 
14
- log({bench:})
13
+ bench = args[0]
15
14
 
15
+ log({bench:})
16
+
17
+ begin
16
18
  bench_klass = Liza.const "#{bench}_bench"
19
+ rescue Liza::ConstNotFound
20
+ bench_klass = NotFoundBench
21
+ end
17
22
 
18
- # 3. CALL
23
+ # 3. CALL
19
24
 
20
- bench_klass.call args[1..-1]
21
- end
25
+ bench_klass.call args[1..-1]
26
+ end
22
27
 
28
+ def self.call_not_found args
29
+ Liza::NotFoundBench.call args
23
30
  end
31
+
24
32
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class BenchCommandTest < CommandTest
1
+ class DevSystem::BenchCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::BenchCommand
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::BenchCommand
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -1,11 +1,9 @@
1
- class DevSystem
2
- class EchoCommand < Command
1
+ class DevSystem::EchoCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- log :higher, "Called #{self} with args #{args}"
6
-
7
- raise RuntimeError, args.to_s
8
- end
3
+ def self.call args
4
+ log :higher, "Called #{self} with args #{args}"
9
5
 
6
+ raise RuntimeError, args.to_s
10
7
  end
8
+
11
9
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class EchoCommandTest < CommandTest
1
+ class DevSystem::EchoCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::EchoCommand
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::EchoCommand
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -1,23 +1,33 @@
1
- class DevSystem
2
- class GenerateCommand < Command
1
+ class DevSystem::GenerateCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def self.call args
4
+ # 1. LOG
6
5
 
7
- log :higher, "args: #{args}"
8
- puts
6
+ log :higher, "args: #{args}"
7
+ puts
9
8
 
10
- # 2. FIND generator
9
+ # 2. FIND generator
11
10
 
12
- generator = args[0]
11
+ return call_not_found args if args.none?
13
12
 
14
- log({generator:})
13
+ generator = args[0]
15
14
 
16
- generator_klass = Liza.const "#{generator}_generator"
15
+ log({generator:})
17
16
 
18
- # 3. CALL
17
+ #
19
18
 
20
- generator_klass.call args[1..-1]
19
+ begin
20
+ generator_class = Liza.const "#{generator}_generator"
21
+ rescue Liza::ConstNotFound
22
+ generator_class = NotFoundGenerator
21
23
  end
24
+
25
+ # 3. CALL
26
+
27
+ generator_class.call args[1..-1]
28
+ end
29
+
30
+ def self.call_not_found args
31
+ Liza::NotFoundGenerator.call args
22
32
  end
23
33
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class GenerateCommandTest < CommandTest
1
+ class DevSystem::GenerateCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::GenerateCommand
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::GenerateCommand
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -0,0 +1,27 @@
1
+ class DevSystem::NotFoundCommand < DevSystem::Command
2
+
3
+ def self.call args
4
+ # 1. LOG
5
+
6
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
7
+ puts
8
+
9
+ # 2. FIND commands
10
+
11
+ App.eager_load_all
12
+ commands = Liza::Command.descendants
13
+
14
+ log "Liza comes with #{commands.count} commands you can use."
15
+ puts
16
+
17
+ log "Here they are:"
18
+ puts
19
+
20
+ # 3. LIST commands
21
+
22
+ keys = commands.map { |k| k.last_namespace.snakecase[0..-9] }.sort
23
+ keys.reject! { |s| s == "not_found" }
24
+ keys.each { |s| log "liza #{s}" }
25
+ end
26
+
27
+ end
@@ -0,0 +1,12 @@
1
+ class DevSystem::NotFoundCommandTest < DevSystem::CommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::NotFoundCommand
5
+ end
6
+
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
10
+ end
11
+
12
+ end
@@ -0,0 +1,22 @@
1
+ class DevSystem::TerminalCommand < DevSystem::Command
2
+
3
+ def self.call args
4
+ # 1. LOG
5
+
6
+ log :higher, "args: #{args}"
7
+ puts
8
+
9
+ # 2. FIND terminal
10
+
11
+ terminal = args[0] || "irb"
12
+
13
+ log({terminal:})
14
+
15
+ terminal_klass = Liza.const "#{terminal}_terminal"
16
+
17
+ # 3. CALL
18
+
19
+ terminal_klass.call Array(args[1..-1])
20
+ end
21
+
22
+ end
@@ -0,0 +1,12 @@
1
+ class DevSystem::TerminalCommandTest < DevSystem::CommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::TerminalCommand
5
+ end
6
+
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
10
+ end
11
+
12
+ end
@@ -1,70 +1,85 @@
1
- class DevSystem
2
- class TestCommand < Command
1
+ class DevSystem::TestCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- log :higher, "Called #{self} with args #{args}"
3
+ def self.call args
4
+ log :higher, "Called #{self} with args #{args}"
6
5
 
7
- App.eager_load_all
6
+ App.eager_load_all
8
7
 
9
- now = Time.now
10
- test_classes = Liza::Test.descendants
8
+ now = Time.now
9
+ test_classes = Liza::Test.descendants
11
10
 
12
- test_classes = _call_sort test_classes
11
+ _call_silence_base_units
12
+
13
+ if Lizarb::IS_APP_DIR
14
+ test_classes = test_classes.select { |tc| tc.source_location[0].include? Lizarb::APP_DIR }
15
+ end
16
+
17
+ test_classes = _call_sort test_classes
18
+
19
+ log "Testing #{test_classes}"
20
+ _call_testing test_classes
21
+ log "Done Testing (#{now.diff}s)"
13
22
 
14
- log "Testing #{test_classes}"
15
- _call_testing test_classes
16
- log "Done Testing (#{now.diff}s)"
23
+ puts
17
24
 
18
- puts
25
+ log "Counting #{test_classes.count} Test Classes"
26
+ _call_counting test_classes
27
+ log "Done Counting (#{now.diff}s)"
28
+ end
19
29
 
20
- log "Counting #{test_classes.count} Test Classes"
21
- _call_counting test_classes
22
- log "Done Counting (#{now.diff}s)"
30
+ def self._call_silence_base_units
31
+ [
32
+ Liza::Box,
33
+ Liza::Panel,
34
+ Liza::Controller,
35
+ ].each do |x|
36
+ def x.log(...) end
37
+ def x.puts(...) end
23
38
  end
39
+ end
24
40
 
25
- def self._call_sort test_classes
26
- test_classes.sort_by! &:name
41
+ def self._call_sort test_classes
42
+ test_classes.sort_by! &:name
27
43
 
28
- proc_namespaced = proc { |tc| tc.name.include? "::" }
29
- proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
44
+ proc_namespaced = proc { |tc| tc.name.include? "::" }
45
+ proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
30
46
 
31
- tc_app = test_classes.reject &proc_namespaced
32
- tc_namespaced = test_classes.select &proc_namespaced
47
+ tc_app = test_classes.reject &proc_namespaced
48
+ tc_namespaced = test_classes.select &proc_namespaced
33
49
 
34
- tc_liza = tc_namespaced.select &proc_liza
35
- tc_system = tc_namespaced.reject &proc_liza
50
+ tc_liza = tc_namespaced.select &proc_liza
51
+ tc_system = tc_namespaced.reject &proc_liza
36
52
 
37
- tc_app.sort_by! { |tc| Object.const_source_location(tc.name)[0] }
38
- tc_liza.sort_by! { |tc| Object.const_source_location(tc.name)[0] }
53
+ tc_app.sort_by! &:source_location
54
+ tc_liza.sort_by! &:source_location
39
55
 
40
- [tc_liza, tc_system, tc_app].flatten
41
- end
56
+ [tc_liza, tc_system, tc_app].flatten
57
+ end
42
58
 
43
- def self._call_testing test_classes
44
- i, count = 0, test_classes.count
45
- for test_class in test_classes
46
- test_class.call i+=1, count
47
- end
59
+ def self._call_testing test_classes
60
+ i, count = 0, test_classes.count
61
+ for test_class in test_classes
62
+ test_class.call i+=1, count
48
63
  end
64
+ end
49
65
 
50
- def self._call_counting test_classes
51
- puts
52
- totals = Hash.new { 0 }
53
- last_namespace = nil
54
- test_classes.each do |test_class|
55
- namespace = test_class.first_namespace
56
- puts if last_namespace != namespace
57
- last_namespace = namespace
58
-
59
- test_class.totals.each do |k, v|
60
- totals[k] += v.size
61
- end
62
- Liza.log " #{"#{test_class}.totals".ljust 60} #{test_class.totals.map { |k, v| [k, v.size] }.to_h}"
66
+ def self._call_counting test_classes
67
+ puts
68
+ totals = Hash.new { 0 }
69
+ last_namespace = nil
70
+ test_classes.each do |test_class|
71
+ namespace = test_class.first_namespace
72
+ puts if last_namespace != namespace
73
+ last_namespace = namespace
74
+
75
+ test_class.totals.each do |k, v|
76
+ totals[k] += v.size
63
77
  end
64
- puts
65
- Liza.log " #{"Total".ljust 60} #{totals}"
66
- puts
78
+ Liza.log " #{"#{test_class}.totals".ljust 60} #{test_class.totals.map { |k, v| [k, v.size] }.to_h}"
67
79
  end
68
-
80
+ puts
81
+ Liza.log " #{"Total".ljust 60} #{totals}"
82
+ puts
69
83
  end
84
+
70
85
  end