lizarb 1.0.0 → 1.0.2
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 +2 -0
- data/Gemfile.lock +14 -3
- data/README.md +23 -64
- data/README_SYSTEMS.md +80 -0
- data/Rakefile +3 -1
- data/app/dev/benches/app_bench.rb +5 -0
- data/app/dev/benches/app_bench_test.rb +7 -0
- data/app/dev/benches/loops_bench.rb +183 -0
- data/app/dev/benches/loops_bench_test.rb +11 -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/new_command.rb +1 -61
- 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 +18 -0
- data/app/dev/generators/bench_generator_test.rb +12 -0
- 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 +18 -0
- data/app/dev/generators/command_generator_test.rb +12 -0
- data/app/dev/generators/record_generator.rb +46 -0
- data/app/dev/generators/record_generator_test.rb +12 -0
- data/app/dev/generators/request_generator.rb +63 -0
- data/app/dev/generators/request_generator_test.rb +12 -0
- data/app/net/databases/redis_db_test.rb +2 -2
- data/app/net/databases/sqlite_db_test.rb +2 -2
- data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/{models/post_model_test.rb → records/app_record_test.rb} +2 -2
- data/app/net/records/post_record.rb +4 -0
- data/app/net/{models/app_model_test.rb → records/post_record_test.rb} +2 -2
- data/app/net/records/user_record.rb +4 -0
- data/app/net/{models/user_model_test.rb → records/user_record_test.rb} +2 -2
- data/app/net_box.rb +2 -2
- 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 +8 -0
- data/app_new/Procfile +1 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +18 -14
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +29 -0
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +14 -0
- data/lib/dev_system/dev/controllers/bench.rb +11 -0
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +60 -0
- data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench_test.rb} +2 -2
- data/lib/dev_system/dev/controllers/command/bench_command.rb +34 -0
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/generate_command.rb +35 -0
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +29 -0
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +24 -0
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +6 -2
- data/lib/dev_system/dev/controllers/generator.rb +11 -0
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +54 -0
- data/lib/dev_system/dev/controllers/generator_test.rb +14 -0
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +96 -0
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +14 -0
- 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 +29 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +14 -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 +59 -0
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +150 -0
- 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 +31 -0
- data/lib/dev_system/dev/controllers/shell_test.rb +46 -0
- data/lib/dev_system/dev/controllers/{command/dev_command.rb → terminal/irb_terminal.rb} +2 -2
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +14 -0
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +12 -0
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +14 -0
- data/lib/dev_system/dev/controllers/terminal.rb +19 -0
- data/lib/dev_system/dev/controllers/terminal_test.rb +14 -0
- data/lib/dev_system/dev/dev_box.rb +3 -0
- data/lib/dev_system/dev/panels/command_panel.rb +21 -1
- data/lib/dev_system/dev/panels/log_panel.rb +1 -1
- data/lib/lerb.rb +106 -0
- data/lib/liza/base/controller.rb +2 -0
- data/lib/liza/base/panel.rb +6 -5
- 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_extension.rb +6 -1
- data/lib/liza/ruby_test.rb +9 -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 +3 -1
- data/lib/liza/test/test_test.rb +108 -15
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +127 -0
- data/lib/liza/test_parts/test_assertions_part.rb +7 -6
- data/lib/liza/test_parts/test_dsl_part.rb +37 -89
- data/lib/liza/test_parts/test_log_part.rb +124 -0
- data/lib/liza/test_parts/test_subject_part.rb +6 -1
- data/lib/liza/test_parts/test_tree_part.rb +139 -0
- data/lib/liza/unit.rb +2 -0
- 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.rb +40 -7
- data/lib/lizarb/ruby/class.rb +2 -0
- data/lib/lizarb/ruby/module.rb +17 -0
- data/lib/lizarb/ruby/proc.rb +12 -0
- data/lib/lizarb/ruby/string.rb +26 -2
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +24 -2
- data/lib/net_system/net/controllers/{adapter/redis_adapter.rb → client/redis_client.rb} +2 -2
- data/lib/net_system/net/controllers/{adapter/redis_adapter_test.rb → client/redis_client_test.rb} +2 -2
- data/lib/net_system/net/controllers/{adapter/sqlite_adapter.rb → client/sqlite_client.rb} +2 -2
- data/lib/net_system/net/controllers/{adapter/sqlite_adapter_test.rb → client/sqlite_client_test.rb} +2 -2
- data/lib/net_system/net/controllers/client.rb +5 -0
- data/lib/net_system/net/controllers/{model_test.rb → client_test.rb} +2 -2
- data/lib/net_system/net/controllers/database/redis_db.rb +2 -2
- data/lib/net_system/net/controllers/database/redis_db_test.rb +1 -1
- data/lib/net_system/net/controllers/database/sqlite_db.rb +2 -2
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +1 -1
- data/lib/net_system/net/controllers/database.rb +6 -6
- data/lib/net_system/net/controllers/record.rb +31 -0
- data/lib/net_system/net/controllers/{adapter_test.rb → record_test.rb} +2 -2
- data/lib/net_system/net/net_box.rb +5 -5
- data/lib/net_system/net/net_box_test.rb +1 -1
- data/lib/net_system/net/panels/client_panel.rb +5 -0
- data/lib/net_system/net/panels/{adapter_panel_test.rb → client_panel_test.rb} +2 -2
- data/lib/web_system/dev/rack_command.rb +26 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +3 -34
- data/lib/web_system/web/controllers/rack.rb +8 -0
- data/lib/web_system/web/controllers/rack_test.rb +18 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +0 -1
- data/lib/web_system/web/controllers/request/not_found_request.rb +0 -1
- data/lib/web_system/web/controllers/request/server_error_request.rb +0 -1
- data/lib/web_system/web/panels/rack_panel.rb +44 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +14 -0
- data/lib/web_system/web/panels/request_panel.rb +51 -32
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +12 -0
- data/lizarb.gemspec +2 -2
- data/tmp/.gitkeep +0 -0
- metadata +110 -31
- 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/net/models/post_model.rb +0 -4
- data/app/net/models/user_model.rb +0 -4
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/adapter.rb +0 -5
- data/lib/net_system/net/controllers/model.rb +0 -31
- data/lib/net_system/net/panels/adapter_panel.rb +0 -5
data/app/net_box.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class NetBox < Liza::NetBox
|
2
2
|
|
3
|
-
|
4
|
-
# Set up your
|
3
|
+
clients do
|
4
|
+
# Set up 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
7
|
set :sqlite, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
|
@@ -31,31 +31,32 @@ class ApiRequest < AppRequest
|
|
31
31
|
body = render_route_not_found env["LIZA_PATH"]
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
body = body.to_json
|
35
|
+
|
35
36
|
[status, headers, [body]]
|
36
37
|
end
|
37
38
|
|
38
39
|
def self.render_route_api_auth_sign_up
|
39
|
-
|
40
|
+
{route: "render_route_api_auth_sign_up"}
|
40
41
|
end
|
41
42
|
|
42
43
|
def self.render_route_api_auth_sign_in
|
43
|
-
|
44
|
+
{route: "render_route_api_auth_sign_in"}
|
44
45
|
end
|
45
46
|
|
46
47
|
def self.render_route_api_auth_account
|
47
|
-
|
48
|
+
{route: "render_route_api_auth_account"}
|
48
49
|
end
|
49
50
|
|
50
51
|
def self.render_route_api_auth_sign_out
|
51
|
-
|
52
|
+
{route: "render_route_api_auth_sign_out"}
|
52
53
|
end
|
53
54
|
|
54
55
|
def self.render_route_api_users
|
55
|
-
|
56
|
+
{route: "render_route_api_users"}
|
56
57
|
end
|
57
58
|
|
58
59
|
def self.render_route_not_found path
|
59
|
-
|
60
|
+
{route: "render_route_not_found #{path}"}
|
60
61
|
end
|
61
62
|
end
|
@@ -10,33 +10,32 @@ class AssetsRequest < AppRequest
|
|
10
10
|
|
11
11
|
#
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
status = 200
|
14
|
+
headers = {
|
15
15
|
"Framework" => "Liza #{Lizarb::VERSION}"
|
16
16
|
}
|
17
|
-
|
17
|
+
body = ""
|
18
18
|
|
19
|
-
render_action_admin_format_js if action == :admin && format == :js
|
20
|
-
render_action_admin_format_css if action == :admin && format == :css
|
21
|
-
render_action_app_format_js if action == :app && format == :js
|
22
|
-
render_action_app_format_css if action == :app && format == :css
|
19
|
+
body = render_action_admin_format_js if action == :admin && format == :js
|
20
|
+
body = render_action_admin_format_css if action == :admin && format == :css
|
21
|
+
body = render_action_app_format_js if action == :app && format == :js
|
22
|
+
body = render_action_app_format_css if action == :app && format == :css
|
23
23
|
|
24
|
-
|
25
|
-
[@status, @headers, [@body]]
|
24
|
+
[status, headers, [body]]
|
26
25
|
end
|
27
26
|
|
28
27
|
# helper methods
|
29
28
|
|
30
29
|
def render_action_admin_format_js
|
31
|
-
|
30
|
+
"alert('it works')"
|
32
31
|
end
|
33
32
|
|
34
33
|
def render_action_admin_format_css
|
35
|
-
|
34
|
+
"body { background: gray }"
|
36
35
|
end
|
37
36
|
|
38
37
|
def render_action_app_format_js
|
39
|
-
|
38
|
+
<<-CODE
|
40
39
|
window.onload = () => {
|
41
40
|
var h1 = document.createElement("h1");
|
42
41
|
h1.setAttribute("style", "color: white");
|
@@ -47,7 +46,7 @@ window.onload = () => {
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def render_action_app_format_css
|
50
|
-
|
49
|
+
<<-CODE
|
51
50
|
body {
|
52
51
|
background: ##{random_color};
|
53
52
|
font-family: Roboto;
|
@@ -14,14 +14,13 @@ class RootRequest < AppRequest
|
|
14
14
|
|
15
15
|
@body = ""
|
16
16
|
|
17
|
-
if action == "
|
18
|
-
|
17
|
+
if action == "index"
|
18
|
+
render_action_index
|
19
19
|
else
|
20
20
|
@status = 404
|
21
|
-
render_action_not_found
|
21
|
+
render_action_not_found action
|
22
22
|
end
|
23
23
|
|
24
|
-
log @status
|
25
24
|
[@status, @headers, [@body]]
|
26
25
|
rescue => e
|
27
26
|
@status = 500
|
@@ -31,7 +30,7 @@ class RootRequest < AppRequest
|
|
31
30
|
[@status, @headers, [@body]]
|
32
31
|
end
|
33
32
|
|
34
|
-
def self.
|
33
|
+
def self.render_action_index
|
35
34
|
h1 = "Ruby Works!"
|
36
35
|
|
37
36
|
@body = <<~CODE
|
@@ -48,8 +47,8 @@ class RootRequest < AppRequest
|
|
48
47
|
CODE
|
49
48
|
end
|
50
49
|
|
51
|
-
def self.render_action_not_found
|
52
|
-
@body = "Ruby couldn't find your page!"
|
50
|
+
def self.render_action_not_found action
|
51
|
+
@body = "Ruby couldn't find your page! action: #{action}"
|
53
52
|
end
|
54
53
|
|
55
54
|
end
|
data/app/web_box.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
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
|
5
|
+
|
6
|
+
# set :files, App.root.join("web_files")
|
7
|
+
# set :host, "localhost"
|
8
|
+
# set :port, 3000
|
9
|
+
end
|
10
|
+
|
3
11
|
requests do
|
4
12
|
# Set up your request panel per the DSL in http://guides.lizarb.org/panels/request.html
|
5
13
|
|
data/app_new/Procfile
CHANGED
data/exe/lrb
ADDED
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
|
@@ -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}"
|
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,29 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class NotFoundBench < Bench
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
# 1. LOG
|
6
|
+
|
7
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
8
|
+
puts
|
9
|
+
|
10
|
+
# 2. FIND generators
|
11
|
+
|
12
|
+
App.eager_load_all
|
13
|
+
benches = Liza::Bench.descendants
|
14
|
+
|
15
|
+
log "Liza comes with #{benches.count} benches you can use."
|
16
|
+
puts
|
17
|
+
|
18
|
+
log "Here they are:"
|
19
|
+
puts
|
20
|
+
|
21
|
+
# 3. LIST benches
|
22
|
+
|
23
|
+
keys = benches.map { |k| k.last_namespace.snakecase[0..-7] }.sort
|
24
|
+
keys.reject! { |s| s == "not_found" }
|
25
|
+
keys.each { |s| log "liza bench #{s}" }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class NotFoundBenchTest < BenchTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::NotFoundBench
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class BenchDslMainPart < Liza::Part
|
3
|
+
|
4
|
+
insertion do
|
5
|
+
|
6
|
+
def self.call args
|
7
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
8
|
+
|
9
|
+
# https://rubyapi.org/3.1/o/benchmark
|
10
|
+
require "benchmark"
|
11
|
+
|
12
|
+
if @setup_bl
|
13
|
+
log "Setting up..."
|
14
|
+
instance_exec &@setup_bl
|
15
|
+
log "Set up"
|
16
|
+
end
|
17
|
+
|
18
|
+
log "Benchmarking #{marks.count} Ruby Blocks"
|
19
|
+
puts
|
20
|
+
|
21
|
+
length = marks.keys.map(&:length).max
|
22
|
+
|
23
|
+
marks.each do |label, bl|
|
24
|
+
log "Benchmarking #{label}"
|
25
|
+
marks[label] = Benchmark.measure label, &bl
|
26
|
+
end
|
27
|
+
|
28
|
+
puts
|
29
|
+
|
30
|
+
log "#{"Reporting".ljust_blanks(length + 17)} App CPU Time Kernel CPU Time Total CPU Time"
|
31
|
+
puts
|
32
|
+
|
33
|
+
sorted = marks.sort_by { |_k, tms| tms.total }.to_h
|
34
|
+
|
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}"
|
38
|
+
|
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"
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
|
49
|
+
def self.marks()= @marks ||= {}
|
50
|
+
|
51
|
+
def self.mark(label, &block)= marks[label] = block
|
52
|
+
|
53
|
+
def self.setup &block
|
54
|
+
@setup_bl = block if block_given?
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class BenchCommand < Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
# 1. LOG
|
6
|
+
|
7
|
+
log :higher, "args: #{args}"
|
8
|
+
puts
|
9
|
+
|
10
|
+
# 2. FIND bench
|
11
|
+
|
12
|
+
return call_not_found args if args.none?
|
13
|
+
|
14
|
+
bench = args[0]
|
15
|
+
|
16
|
+
log({bench:})
|
17
|
+
|
18
|
+
begin
|
19
|
+
bench_klass = Liza.const "#{bench}_bench"
|
20
|
+
rescue Liza::ConstNotFound
|
21
|
+
bench_klass = NotFoundBench
|
22
|
+
end
|
23
|
+
|
24
|
+
# 3. CALL
|
25
|
+
|
26
|
+
bench_klass.call args[1..-1]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.call_not_found args
|
30
|
+
Liza::NotFoundBench.call args
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class BenchCommandTest < CommandTest
|
3
|
+
|
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
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class GenerateCommand < Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
# 1. LOG
|
6
|
+
|
7
|
+
log :higher, "args: #{args}"
|
8
|
+
puts
|
9
|
+
|
10
|
+
# 2. FIND generator
|
11
|
+
|
12
|
+
return call_not_found args if args.none?
|
13
|
+
|
14
|
+
generator = args[0]
|
15
|
+
|
16
|
+
log({generator:})
|
17
|
+
|
18
|
+
#
|
19
|
+
|
20
|
+
begin
|
21
|
+
generator_class = Liza.const "#{generator}_generator"
|
22
|
+
rescue Liza::ConstNotFound
|
23
|
+
generator_class = NotFoundGenerator
|
24
|
+
end
|
25
|
+
|
26
|
+
# 3. CALL
|
27
|
+
|
28
|
+
generator_class.call args[1..-1]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.call_not_found args
|
32
|
+
Liza::NotFoundGenerator.call args
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class GenerateCommandTest < CommandTest
|
3
|
+
|
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
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class NotFoundCommand < Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
# 1. LOG
|
6
|
+
|
7
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
8
|
+
puts
|
9
|
+
|
10
|
+
# 2. FIND commands
|
11
|
+
|
12
|
+
App.eager_load_all
|
13
|
+
commands = Liza::Command.descendants
|
14
|
+
|
15
|
+
log "Liza comes with #{commands.count} commands you can use."
|
16
|
+
puts
|
17
|
+
|
18
|
+
log "Here they are:"
|
19
|
+
puts
|
20
|
+
|
21
|
+
# 3. LIST commands
|
22
|
+
|
23
|
+
keys = commands.map { |k| k.last_namespace.snakecase[0..-9] }.sort
|
24
|
+
keys.reject! { |s| s == "not_found" }
|
25
|
+
keys.each { |s| log "liza #{s}" }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class NotFoundCommandTest < CommandTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::NotFoundCommand
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class TerminalCommand < Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
# 1. LOG
|
6
|
+
|
7
|
+
log :higher, "args: #{args}"
|
8
|
+
puts
|
9
|
+
|
10
|
+
# 2. FIND terminal
|
11
|
+
|
12
|
+
terminal = args[0] || "irb"
|
13
|
+
|
14
|
+
log({terminal:})
|
15
|
+
|
16
|
+
terminal_klass = Liza.const "#{terminal}_terminal"
|
17
|
+
|
18
|
+
# 3. CALL
|
19
|
+
|
20
|
+
terminal_klass.call Array(args[1..-1])
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class TerminalCommandTest < CommandTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::TerminalCommand
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -8,6 +8,10 @@ class DevSystem
|
|
8
8
|
|
9
9
|
now = Time.now
|
10
10
|
test_classes = Liza::Test.descendants
|
11
|
+
|
12
|
+
if Lizarb::IS_APP_DIR
|
13
|
+
test_classes = test_classes.select { |tc| tc.source_location[0].include? Lizarb::APP_DIR }
|
14
|
+
end
|
11
15
|
|
12
16
|
test_classes = _call_sort test_classes
|
13
17
|
|
@@ -34,8 +38,8 @@ class DevSystem
|
|
34
38
|
tc_liza = tc_namespaced.select &proc_liza
|
35
39
|
tc_system = tc_namespaced.reject &proc_liza
|
36
40
|
|
37
|
-
tc_app.sort_by!
|
38
|
-
tc_liza.sort_by!
|
41
|
+
tc_app.sort_by! &:source_location
|
42
|
+
tc_liza.sort_by! &:source_location
|
39
43
|
|
40
44
|
[tc_liza, tc_system, tc_app].flatten
|
41
45
|
end
|