lizarb 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -4
- data/README.md +23 -64
- data/README_SYSTEMS.md +80 -0
- data/Rakefile +3 -1
- data/app/dev/benches/loops_bench.rb +35 -0
- data/app/dev/commands/calculator_command.rb +69 -0
- data/app/dev/commands/calculator_command_test.rb +58 -0
- data/app/dev/commands/circle_command.rb +70 -0
- data/app/dev/commands/circle_command_test.rb +76 -0
- data/app/dev/commands/narrative_method_command.rb +60 -0
- data/app/dev/commands/narrative_method_command_test.rb +36 -0
- data/app/dev/commands/quadratic_command.rb +66 -0
- data/app/dev/commands/quadratic_command_test.rb +47 -0
- data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
- data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
- data/app/dev/generators/bench_generator.rb +2 -51
- data/app/dev/generators/command_generator/command.rb.erb +26 -0
- data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
- data/app/dev/generators/command_generator.rb +2 -35
- data/app/dev/generators/record_generator.rb +46 -0
- data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
- data/app/dev_box.rb +24 -4
- data/app/happy_box.rb +1 -1
- data/app/net/databases/sqlite_db_test.rb +5 -5
- data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/records/app_record_test.rb +8 -0
- data/app/net/records/post_record.rb +4 -0
- data/app/net/records/post_record_test.rb +8 -0
- data/app/net/records/user_record.rb +4 -0
- data/app/net/records/user_record_test.rb +8 -0
- data/app/net_box.rb +7 -7
- data/app/web/requests/api_request.rb +8 -7
- data/app/web/requests/assets_request.rb +12 -13
- data/app/web/requests/root_request.rb +6 -7
- data/app/web/requests/root_request_test.rb +1 -1
- data/app/web_box.rb +9 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +19 -15
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
- data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
- data/lib/dev_system/dev/controllers/bench.rb +5 -7
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command.rb +11 -13
- data/lib/dev_system/dev/controllers/command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generator.rb +5 -7
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
- data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
- data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
- data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
- data/lib/dev_system/dev/controllers/shell.rb +26 -14
- data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
- data/lib/dev_system/dev/dev_box.rb +33 -16
- data/lib/dev_system/dev/dev_box_test.rb +12 -14
- data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
- data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/command_panel.rb +24 -6
- data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
- data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/log_panel.rb +9 -6
- data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
- data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
- data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
- data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
- data/lib/happy_system/happy/controllers/axo.rb +4 -5
- data/lib/happy_system/happy/happy_box.rb +6 -9
- data/lib/happy_system/happy/happy_box_test.rb +11 -13
- data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
- data/lib/lerb.rb +106 -0
- data/lib/liza/base/box.rb +71 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -19
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +40 -24
- data/lib/liza/base/panel_test.rb +10 -12
- data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
- data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
- data/lib/liza/meta/part.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -11
- data/lib/liza/meta/part_test.rb +4 -6
- data/lib/liza/meta/system.rb +12 -14
- data/lib/liza/meta/system_test.rb +8 -10
- data/lib/liza/ruby_test.rb +7 -0
- data/lib/liza/ruby_tests/module_test.rb +21 -0
- data/lib/liza/ruby_tests/string_test.rb +59 -0
- data/lib/liza/test/test.rb +7 -8
- data/lib/liza/test/test_test.rb +168 -76
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
- data/lib/liza/test_parts/test_assertions_part.rb +81 -82
- data/lib/liza/test_parts/test_dsl_part.rb +44 -98
- data/lib/liza/test_parts/test_log_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +137 -0
- data/lib/liza/unit.rb +108 -102
- data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
- data/lib/liza/unit_test.rb +69 -71
- data/lib/liza.rb +5 -0
- data/lib/lizarb/ruby/module.rb +17 -0
- data/lib/lizarb/ruby/string.rb +10 -2
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +24 -2
- data/lib/net_system/dev/net_command.rb +10 -12
- data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
- data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
- data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client.rb +1 -3
- data/lib/net_system/net/controllers/client_test.rb +8 -10
- data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
- data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database.rb +21 -23
- data/lib/net_system/net/controllers/database_test.rb +8 -10
- data/lib/net_system/net/controllers/record.rb +29 -0
- data/lib/net_system/net/controllers/record_test.rb +12 -0
- data/lib/net_system/net/net_box.rb +11 -16
- data/lib/net_system/net/net_box_test.rb +12 -14
- data/lib/net_system/net/panels/client_panel.rb +1 -3
- data/lib/net_system/net/panels/client_panel_test.rb +11 -13
- data/lib/net_system/net/panels/database_panel.rb +6 -8
- data/lib/net_system/net/panels/database_panel_test.rb +11 -13
- data/lib/web_system/dev/rack_command.rb +35 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +6 -39
- data/lib/web_system/web/controllers/rack.rb +6 -0
- data/lib/web_system/web/controllers/rack_test.rb +16 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
- data/lib/web_system/web/controllers/request.rb +1 -3
- data/lib/web_system/web/controllers/request_test.rb +11 -13
- data/lib/web_system/web/panels/rack_panel.rb +42 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
- data/lib/web_system/web/panels/request_panel.rb +54 -37
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +16 -8
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +2 -2
- metadata +76 -28
- data/app/dev/commands/example_command.rb +0 -57
- data/app/dev/commands/example_command_test.rb +0 -43
- data/app/dev/commands/macro_child_command.rb +0 -32
- data/app/dev/commands/macro_child_command_test.rb +0 -7
- data/app/dev/commands/macro_parent_command.rb +0 -70
- data/app/dev/commands/macro_parent_command_test.rb +0 -7
- data/app/dev/commands/my_command.rb +0 -7
- data/app/dev/commands/my_command_test.rb +0 -7
- data/app/dev/generators/model_generator.rb +0 -46
- data/app/net/models/app_model_test.rb +0 -8
- data/app/net/models/post_model.rb +0 -4
- data/app/net/models/post_model_test.rb +0 -8
- data/app/net/models/user_model.rb +0 -4
- data/app/net/models/user_model_test.rb +0 -8
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/model.rb +0 -31
- 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
|
-
|
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 "#{
|
52
|
-
loader.push_dir "#{
|
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 "#{
|
73
|
-
loader.push_dir "#{
|
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
|
data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb}
RENAMED
@@ -1,8 +1,7 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class DevCommandTest < CommandTest
|
1
|
+
class DevSystem::NotFoundBenchTest < DevSystem::BenchTest
|
3
2
|
|
4
|
-
|
5
|
-
assert subject_class == DevSystem::
|
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
|
-
|
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
|
-
|
3
|
+
insertion do
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
def self.call args
|
6
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
# https://rubyapi.org/3.1/o/benchmark
|
9
|
+
require "benchmark"
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
if @setup_bl
|
12
|
+
log "Setting up..."
|
13
|
+
instance_exec &@setup_bl
|
14
|
+
log "Set up"
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
log "Benchmarking #{marks.count} Ruby Blocks"
|
18
|
+
puts
|
20
19
|
|
21
|
-
|
20
|
+
length = marks.keys.map(&:length).max
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
marks.each do |label, bl|
|
23
|
+
log "Benchmarking #{label}"
|
24
|
+
marks[label] = Benchmark.measure label, &bl
|
25
|
+
end
|
27
26
|
|
28
|
-
|
27
|
+
puts
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
log "#{"Reporting".ljust_blanks(length + 17)} App CPU Time Kernel CPU Time Total CPU Time"
|
30
|
+
puts
|
32
31
|
|
33
|
-
|
32
|
+
sorted = marks.sort_by { |_k, tms| tms.total }.to_h
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
48
|
+
def self.marks()= @marks ||= {}
|
52
49
|
|
53
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
log :higher, "args: #{args}"
|
7
|
+
puts
|
9
8
|
|
10
|
-
|
9
|
+
# 2. FIND bench
|
11
10
|
|
12
|
-
|
11
|
+
return call_not_found args if args.none?
|
13
12
|
|
14
|
-
|
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
|
-
|
23
|
+
# 3. CALL
|
19
24
|
|
20
|
-
|
21
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
log :higher, "args: #{args}"
|
7
|
+
puts
|
9
8
|
|
10
|
-
|
9
|
+
# 2. FIND generator
|
11
10
|
|
12
|
-
|
11
|
+
return call_not_found args if args.none?
|
13
12
|
|
14
|
-
|
13
|
+
generator = args[0]
|
15
14
|
|
16
|
-
|
15
|
+
log({generator:})
|
17
16
|
|
18
|
-
|
17
|
+
#
|
19
18
|
|
20
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
log :higher, "Called #{self} with args #{args}"
|
6
5
|
|
7
|
-
|
6
|
+
App.eager_load_all
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
now = Time.now
|
9
|
+
test_classes = Liza::Test.descendants
|
11
10
|
|
12
|
-
|
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
|
-
|
15
|
-
_call_testing test_classes
|
16
|
-
log "Done Testing (#{now.diff}s)"
|
23
|
+
puts
|
17
24
|
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
26
|
-
|
41
|
+
def self._call_sort test_classes
|
42
|
+
test_classes.sort_by! &:name
|
27
43
|
|
28
|
-
|
29
|
-
|
44
|
+
proc_namespaced = proc { |tc| tc.name.include? "::" }
|
45
|
+
proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
|
30
46
|
|
31
|
-
|
32
|
-
|
47
|
+
tc_app = test_classes.reject &proc_namespaced
|
48
|
+
tc_namespaced = test_classes.select &proc_namespaced
|
33
49
|
|
34
|
-
|
35
|
-
|
50
|
+
tc_liza = tc_namespaced.select &proc_liza
|
51
|
+
tc_system = tc_namespaced.reject &proc_liza
|
36
52
|
|
37
|
-
|
38
|
-
|
53
|
+
tc_app.sort_by! &:source_location
|
54
|
+
tc_liza.sort_by! &:source_location
|
39
55
|
|
40
|
-
|
41
|
-
|
56
|
+
[tc_liza, tc_system, tc_app].flatten
|
57
|
+
end
|
42
58
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
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
|