lizarb 0 → 1.0.1
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 -0
- data/CHANGELOG.md +13 -2
- data/Gemfile +22 -2
- data/Gemfile.lock +52 -0
- data/README.md +88 -12
- 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 +148 -0
- data/app/dev/benches/loops_bench_test.rb +11 -0
- data/app/dev/commands/app_command.rb +5 -0
- data/app/dev/commands/app_command_test.rb +7 -0
- data/app/dev/commands/example_command.rb +57 -0
- data/app/dev/commands/example_command_test.rb +43 -0
- data/app/dev/commands/macro_child_command.rb +32 -0
- data/app/dev/commands/macro_child_command_test.rb +7 -0
- data/app/dev/commands/macro_parent_command.rb +70 -0
- data/app/dev/commands/macro_parent_command_test.rb +7 -0
- data/app/dev/commands/my_command.rb +7 -0
- data/app/dev/commands/my_command_test.rb +7 -0
- data/app/dev/commands/new_command.rb +9 -0
- data/app/dev/commands/new_command_test.rb +7 -0
- data/app/dev/generators/bench_generator.rb +67 -0
- data/app/dev/generators/bench_generator_test.rb +12 -0
- data/app/dev/generators/command_generator.rb +51 -0
- data/app/dev/generators/command_generator_test.rb +12 -0
- data/app/dev/generators/model_generator.rb +46 -0
- data/app/dev/generators/model_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/dev_box.rb +13 -0
- data/app/happy/axos/axo.rb +50 -0
- data/app/happy_box.rb +8 -0
- data/app/net/databases/redis_db.rb +5 -0
- data/app/net/databases/redis_db_test.rb +12 -0
- data/app/net/databases/sqlite_db.rb +11 -0
- data/app/net/databases/sqlite_db_test.rb +12 -0
- data/app/net/models/app_model.rb +20 -0
- data/app/net/models/app_model_test.rb +8 -0
- data/app/net/models/post_model.rb +4 -0
- data/app/net/models/post_model_test.rb +8 -0
- data/app/net/models/user_model.rb +4 -0
- data/app/net/models/user_model_test.rb +8 -0
- data/app/net_box.rb +21 -0
- data/app/web/requests/api_request.rb +61 -0
- data/app/web/requests/api_request_test.rb +31 -0
- data/app/web/requests/app_request.rb +5 -0
- data/app/web/requests/app_request_test.rb +7 -0
- data/app/web/requests/assets_request.rb +71 -0
- data/app/web/requests/assets_request_test.rb +33 -0
- data/app/web/requests/root_request.rb +55 -0
- data/app/web/requests/root_request_test.rb +31 -0
- data/app/web_box.rb +8 -0
- data/app.code.env +11 -0
- data/app.env +11 -0
- data/app.rb +17 -0
- data/app_new/.gitignore +4 -0
- data/app_new/Gemfile +31 -0
- data/app_new/Procfile +3 -0
- data/exe/Gemfile +3 -0
- data/exe/Gemfile.lock +13 -0
- data/exe/liza +3 -0
- data/exe/lizarb +11 -0
- data/lib/app.rb +200 -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/bench_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/bench_command.rb +24 -0
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/dev_command.rb +24 -0
- data/lib/dev_system/dev/controllers/command/dev_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/echo_command.rb +11 -0
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/generate_command.rb +23 -0
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +70 -0
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/version_command.rb +9 -0
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command.rb +19 -0
- data/lib/dev_system/dev/controllers/command_test.rb +14 -0
- 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 +71 -0
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +14 -0
- data/lib/dev_system/dev/controllers/shell/file_shell.rb +29 -0
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +14 -0
- data/lib/dev_system/dev/controllers/shell.rb +19 -0
- data/lib/dev_system/dev/controllers/shell_test.rb +13 -0
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +19 -0
- 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 +22 -0
- data/lib/dev_system/dev/dev_box_test.rb +19 -0
- data/lib/dev_system/dev/panels/command_panel.rb +10 -0
- data/lib/dev_system/dev/panels/command_panel_test.rb +23 -0
- data/lib/dev_system/dev/panels/log_panel.rb +10 -0
- data/lib/dev_system/dev/panels/log_panel_test.rb +18 -0
- data/lib/dev_system.rb +8 -0
- data/lib/happy_system/dev/happy_command.rb +11 -0
- data/lib/happy_system/happy/controllers/axo.rb +8 -0
- data/lib/happy_system/happy/happy_box.rb +12 -0
- data/lib/happy_system/happy/happy_box_test.rb +18 -0
- data/lib/happy_system/happy/panels/axo_panel.rb +5 -0
- data/lib/{viral.rb → happy_system.rb} +7 -3
- data/lib/liza/base/box.rb +40 -0
- data/lib/liza/base/box_test.rb +12 -0
- data/lib/liza/base/controller.rb +27 -0
- data/lib/liza/base/controller_test.rb +12 -0
- data/lib/liza/base/panel.rb +38 -0
- data/lib/liza/base/panel_test.rb +16 -0
- data/lib/liza/meta/part.rb +19 -0
- data/lib/liza/meta/part_extension.rb +13 -0
- data/lib/liza/meta/part_test.rb +8 -0
- data/lib/liza/meta/system.rb +20 -0
- data/lib/liza/meta/system_test.rb +13 -0
- data/lib/liza/test/test.rb +11 -0
- data/lib/liza/test/test_test.rb +108 -0
- data/lib/liza/test_parts/test_assertions_part.rb +110 -0
- data/lib/liza/test_parts/test_context_part.rb +81 -0
- data/lib/liza/test_parts/test_dsl_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +24 -0
- data/lib/liza/unit.rb +149 -0
- data/lib/liza/unit_test.rb +79 -0
- data/lib/liza.rb +62 -0
- data/lib/lizarb/ruby/class.rb +17 -0
- data/lib/lizarb/ruby/proc.rb +12 -0
- data/lib/lizarb/ruby/string.rb +25 -0
- data/lib/lizarb/ruby/time.rb +9 -0
- data/lib/{viral → lizarb}/version.rb +2 -2
- data/lib/lizarb.rb +68 -0
- data/lib/net_system/dev/net_command.rb +24 -0
- data/lib/net_system/net/controllers/client/redis_client.rb +28 -0
- data/lib/net_system/net/controllers/client/redis_client_test.rb +29 -0
- data/lib/net_system/net/controllers/client/sqlite_client.rb +28 -0
- data/lib/net_system/net/controllers/client/sqlite_client_test.rb +29 -0
- data/lib/net_system/net/controllers/client.rb +5 -0
- data/lib/net_system/net/controllers/client_test.rb +14 -0
- data/lib/net_system/net/controllers/database/redis_db.rb +11 -0
- data/lib/net_system/net/controllers/database/redis_db_test.rb +23 -0
- data/lib/net_system/net/controllers/database/sqlite_db.rb +11 -0
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +23 -0
- data/lib/net_system/net/controllers/database.rb +33 -0
- data/lib/net_system/net/controllers/database_test.rb +14 -0
- data/lib/net_system/net/controllers/model.rb +31 -0
- data/lib/net_system/net/controllers/model_test.rb +14 -0
- data/lib/net_system/net/net_box.rb +20 -0
- data/lib/net_system/net/net_box_test.rb +19 -0
- data/lib/net_system/net/panels/client_panel.rb +5 -0
- data/lib/net_system/net/panels/client_panel_test.rb +18 -0
- data/lib/net_system/net/panels/database_panel.rb +12 -0
- data/lib/net_system/net/panels/database_panel_test.rb +18 -0
- data/lib/net_system.rb +3 -0
- data/lib/web_system/dev/web_command.rb +42 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +18 -0
- data/lib/web_system/web/controllers/request/not_found_request.rb +18 -0
- data/lib/web_system/web/controllers/request/server_error_request.rb +20 -0
- data/lib/web_system/web/controllers/request.rb +5 -0
- data/lib/web_system/web/controllers/request_test.rb +18 -0
- data/lib/web_system/web/panels/request_panel.rb +55 -0
- data/lib/web_system/web/panels/request_panel_test.rb +14 -0
- data/lib/web_system/web/web_box.rb +12 -0
- data/lib/web_system/web/web_box_test.rb +18 -0
- data/lib/web_system.rb +5 -0
- data/lizarb.gemspec +44 -0
- data/sig/{viral.rbs → lizarb.rbs} +1 -1
- data/tmp/.gitkeep +0 -0
- data/web_files/favicon.ico +0 -0
- data/web_files/favicon.svg +948 -0
- metadata +226 -13
- data/viral.gemspec +0 -45
@@ -0,0 +1,33 @@
|
|
1
|
+
class AssetsRequestTest < AppRequestTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == AssetsRequest
|
5
|
+
end
|
6
|
+
|
7
|
+
test :actions, :app, :js do
|
8
|
+
env = {
|
9
|
+
"LIZA_ACTION" => "app",
|
10
|
+
"LIZA_FORMAT" => "js",
|
11
|
+
}
|
12
|
+
|
13
|
+
status, headers, body = subject_class.call env
|
14
|
+
|
15
|
+
assert status == 200
|
16
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
17
|
+
assert body.first.include? "JS file has been loaded"
|
18
|
+
end
|
19
|
+
|
20
|
+
test :actions, :app, :css do
|
21
|
+
env = {
|
22
|
+
"LIZA_ACTION" => "app",
|
23
|
+
"LIZA_FORMAT" => "css",
|
24
|
+
}
|
25
|
+
|
26
|
+
status, headers, body = subject_class.call env
|
27
|
+
|
28
|
+
assert status == 200
|
29
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
30
|
+
assert body.first.include? "body {"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class RootRequest < AppRequest
|
2
|
+
|
3
|
+
# NOTE: There's a bug in this file. Can you find it?
|
4
|
+
def self.call env
|
5
|
+
action = env["LIZA_ACTION"]
|
6
|
+
|
7
|
+
#
|
8
|
+
|
9
|
+
@status = 200
|
10
|
+
|
11
|
+
@headers = {
|
12
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
13
|
+
}
|
14
|
+
|
15
|
+
@body = ""
|
16
|
+
|
17
|
+
if action == "root"
|
18
|
+
render_action_root
|
19
|
+
else
|
20
|
+
@status = 404
|
21
|
+
render_action_not_found
|
22
|
+
end
|
23
|
+
|
24
|
+
log @status
|
25
|
+
[@status, @headers, [@body]]
|
26
|
+
rescue => e
|
27
|
+
@status = 500
|
28
|
+
@body = "#{e.class} - #{e.message}"
|
29
|
+
|
30
|
+
log @status
|
31
|
+
[@status, @headers, [@body]]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.render_action_root
|
35
|
+
h1 = "Ruby Works!"
|
36
|
+
|
37
|
+
@body = <<~CODE
|
38
|
+
<html>
|
39
|
+
<head>
|
40
|
+
<title>Ruby</title>
|
41
|
+
<link rel="stylesheet" href="/assets/app.css" />
|
42
|
+
<script type="application/javascript" src="/assets/app.js"></script>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<h1>#{h1}</h1>
|
46
|
+
</body>
|
47
|
+
</html>
|
48
|
+
CODE
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.render_action_not_found
|
52
|
+
@body = "Ruby couldn't find your page!"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class RootRequestTest < AppRequestTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == RootRequest
|
5
|
+
end
|
6
|
+
|
7
|
+
test :actions, :root do
|
8
|
+
env = {
|
9
|
+
"LIZA_ACTION" => "root",
|
10
|
+
}
|
11
|
+
|
12
|
+
status, headers, body = subject_class.call env
|
13
|
+
|
14
|
+
assert status == 200
|
15
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
16
|
+
assert body.first.include? "<h1>Ruby Works"
|
17
|
+
end
|
18
|
+
|
19
|
+
test :actions, :other do
|
20
|
+
env = {
|
21
|
+
"LIZA_ACTION" => "other",
|
22
|
+
}
|
23
|
+
|
24
|
+
status, headers, body = subject_class.call env
|
25
|
+
|
26
|
+
assert status == 404
|
27
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
28
|
+
assert body.first.include? "couldn't find your page"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/app/web_box.rb
ADDED
data/app.code.env
ADDED
data/app.env
ADDED
data/app.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
App.call ARGV do
|
2
|
+
|
3
|
+
# Systems help you organize your application's dependencies and RAM memory usage.
|
4
|
+
# Learn more: http://guides.lizarb.org/systems.html
|
5
|
+
|
6
|
+
system :dev
|
7
|
+
system :happy
|
8
|
+
system :net
|
9
|
+
system :web
|
10
|
+
|
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
|
+
|
17
|
+
end
|
data/app_new/.gitignore
ADDED
data/app_new/Gemfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
ruby File.read(".ruby-version").strip
|
6
|
+
|
7
|
+
group :default do
|
8
|
+
gem "lizarb", "~> 1.0"
|
9
|
+
# gem "lizarb", github: "rubyonrails-brasil/lizarb"
|
10
|
+
end
|
11
|
+
|
12
|
+
group :dev do
|
13
|
+
# gems you only want to load if DevSystem is loaded
|
14
|
+
end
|
15
|
+
|
16
|
+
group :happy do
|
17
|
+
# gems you only want to load if HappySystem is loaded
|
18
|
+
end
|
19
|
+
|
20
|
+
group :net do
|
21
|
+
# gems you only want to load if NetSystem is loaded
|
22
|
+
gem "redis", "~> 5.0"
|
23
|
+
gem "sqlite3", "~> 1.5"
|
24
|
+
end
|
25
|
+
|
26
|
+
group :web do
|
27
|
+
# gems you only want to load if WebSystem is loaded
|
28
|
+
gem "rack", "~> 3.0"
|
29
|
+
gem "rackup", "~> 0.2.2"
|
30
|
+
gem "puma", "~> 5.6"
|
31
|
+
end
|
data/app_new/Procfile
ADDED
data/exe/Gemfile
ADDED
data/exe/Gemfile.lock
ADDED
data/exe/liza
ADDED
data/exe/lizarb
ADDED
data/lib/app.rb
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
module App
|
2
|
+
class Error < StandardError; end
|
3
|
+
class ModeNotFound < Error; end
|
4
|
+
class SystemNotFound < Error; end
|
5
|
+
|
6
|
+
#
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def log s
|
11
|
+
puts s.bold
|
12
|
+
end
|
13
|
+
|
14
|
+
# called from "#{APP_DIR}/app"
|
15
|
+
def call argv, &block
|
16
|
+
instance_exec &block
|
17
|
+
|
18
|
+
setup_env
|
19
|
+
setup_bundle
|
20
|
+
setup_liza
|
21
|
+
bundle_systems_app Lizarb::APP_DIR
|
22
|
+
|
23
|
+
check_mode!
|
24
|
+
|
25
|
+
puts
|
26
|
+
::DevBox.commands.call argv
|
27
|
+
puts
|
28
|
+
end
|
29
|
+
|
30
|
+
def root
|
31
|
+
Pathname Dir.pwd
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_env
|
35
|
+
require "dotenv"
|
36
|
+
Dotenv.load "app.#{mode}.env", "app.env"
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_bundle
|
40
|
+
require "bundler/setup"
|
41
|
+
Bundler.require :default, *@systems.keys
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_liza
|
45
|
+
require "liza"
|
46
|
+
|
47
|
+
@loaders << loader = Zeitwerk::Loader.new
|
48
|
+
loader.tag = Liza.to_s
|
49
|
+
|
50
|
+
# ORDER MATTERS: IGNORE, COLLAPSE, PUSH
|
51
|
+
loader.collapse "#{fname_for Liza}/**/*"
|
52
|
+
loader.push_dir "#{fname_for Liza}", namespace: Liza
|
53
|
+
|
54
|
+
loader.enable_reloading
|
55
|
+
loader.setup
|
56
|
+
end
|
57
|
+
|
58
|
+
def bundle_systems_app app_dir
|
59
|
+
@systems.keys.each do |k|
|
60
|
+
key = "#{k}_system"
|
61
|
+
|
62
|
+
require_system key
|
63
|
+
klass = Object.const_get key.camelize
|
64
|
+
|
65
|
+
@systems[k] = klass
|
66
|
+
end
|
67
|
+
|
68
|
+
@loaders << loader = Zeitwerk::Loader.new
|
69
|
+
|
70
|
+
@systems.each do |k, klass|
|
71
|
+
# ORDER MATTERS: IGNORE, COLLAPSE, PUSH
|
72
|
+
loader.collapse "#{fname_for klass}/**/*"
|
73
|
+
loader.push_dir "#{fname_for klass}", namespace: klass
|
74
|
+
end
|
75
|
+
|
76
|
+
# ORDER MATTERS: IGNORE, COLLAPSE, PUSH
|
77
|
+
loader.collapse "#{app_dir}/app/**/*"
|
78
|
+
loader.push_dir "#{app_dir}/app" if Dir.exist? "#{app_dir}/app"
|
79
|
+
|
80
|
+
loader.enable_reloading
|
81
|
+
loader.setup
|
82
|
+
|
83
|
+
@systems.each do |k, klass|
|
84
|
+
connect_system k, klass
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# loaders
|
89
|
+
|
90
|
+
@loaders = []
|
91
|
+
@mutex = Mutex.new
|
92
|
+
|
93
|
+
def reload &block
|
94
|
+
@mutex.synchronize do
|
95
|
+
@loaders.map &:reload
|
96
|
+
yield if block_given?
|
97
|
+
end
|
98
|
+
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
def eager_load_all
|
103
|
+
Zeitwerk::Loader.eager_load_all
|
104
|
+
end
|
105
|
+
|
106
|
+
# mode
|
107
|
+
|
108
|
+
@modes = [:code]
|
109
|
+
ENV["LIZA_MODE"] ||= @modes.first.to_s
|
110
|
+
@mode = ENV["LIZA_MODE"].to_sym
|
111
|
+
|
112
|
+
def mode mode = nil
|
113
|
+
return @mode if mode.nil?
|
114
|
+
@modes << mode.to_sym
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_mode!
|
118
|
+
return if @modes.include? @mode
|
119
|
+
raise ModeNotFound, "LIZA_MODE `#{@mode}` not found in #{@modes}", []
|
120
|
+
end
|
121
|
+
|
122
|
+
# systems
|
123
|
+
|
124
|
+
@systems = {}
|
125
|
+
|
126
|
+
def system key
|
127
|
+
raise "locked" if @locked
|
128
|
+
@systems[key] = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def systems
|
132
|
+
@systems
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.require_system key
|
136
|
+
require key
|
137
|
+
rescue LoadError => e
|
138
|
+
def e.backtrace; []; end
|
139
|
+
raise SystemNotFound, "FILE #{key}.rb not found on $LOAD_PATH", []
|
140
|
+
end
|
141
|
+
|
142
|
+
# parts
|
143
|
+
|
144
|
+
def connect_part part_klass, key, system
|
145
|
+
klass = if system.nil?
|
146
|
+
Liza.const "#{key}_part"
|
147
|
+
else
|
148
|
+
Liza.const("#{system}_system")
|
149
|
+
.const "#{key}_part"
|
150
|
+
end
|
151
|
+
|
152
|
+
log "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}" if $VERBOSE
|
153
|
+
|
154
|
+
if klass.insertion
|
155
|
+
part_klass.class_exec &klass.insertion
|
156
|
+
end
|
157
|
+
|
158
|
+
if klass.extension
|
159
|
+
klass.const_set :Extension, Class.new(Liza::PartExtension)
|
160
|
+
klass::Extension.class_exec &klass.extension
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# systems
|
165
|
+
|
166
|
+
def connect_system key, system_klass
|
167
|
+
t = Time.now
|
168
|
+
|
169
|
+
color_system_klass = system_klass.to_s.colorize system_klass.log_color
|
170
|
+
color_key = key.to_s.colorize system_klass.log_color
|
171
|
+
|
172
|
+
registrar_index = 0
|
173
|
+
system_klass.registrar.each do |string, target_block|
|
174
|
+
reg_type, _sep, reg_target = string.to_s.lpartition "_"
|
175
|
+
|
176
|
+
registrar_index += 1
|
177
|
+
|
178
|
+
target_klass = Liza.const reg_target
|
179
|
+
|
180
|
+
if reg_type == "insertion"
|
181
|
+
target_klass.class_exec &target_block
|
182
|
+
else
|
183
|
+
raise "TODO: decide and implement system extension"
|
184
|
+
end
|
185
|
+
|
186
|
+
log "CONNECTING SYSTEM PART #{color_system_klass}.#{reg_type} #{target_klass}"
|
187
|
+
|
188
|
+
end
|
189
|
+
log "CONNECTING SYSTEM - #{t.diff}s for #{color_system_klass} to connect to #{registrar_index} system parts"
|
190
|
+
end
|
191
|
+
|
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
|
+
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,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class BenchTest < Liza::ControllerTest
|
3
|
+
|
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
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
bench = args[0]
|
13
|
+
|
14
|
+
log({bench:})
|
15
|
+
|
16
|
+
bench_klass = Liza.const "#{bench}_bench"
|
17
|
+
|
18
|
+
# 3. CALL
|
19
|
+
|
20
|
+
bench_klass.call args[1..-1]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
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,24 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class DevCommand < 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 DevCommandTest < CommandTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::DevCommand
|
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,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class EchoCommandTest < CommandTest
|
3
|
+
|
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
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
generator = args[0]
|
13
|
+
|
14
|
+
log({generator:})
|
15
|
+
|
16
|
+
generator_klass = Liza.const "#{generator}_generator"
|
17
|
+
|
18
|
+
# 3. CALL
|
19
|
+
|
20
|
+
generator_klass.call args[1..-1]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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
|