lizarb 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -13
- data/Rakefile +38 -0
- data/app/dev_box.rb +26 -4
- data/app/happy_box.rb +2 -2
- data/app/net/databases/sqlite_db_test.rb +5 -5
- data/app/net/records/app_record_test.rb +1 -1
- data/app/net/records/post_record_test.rb +1 -1
- data/app/net/records/user_record_test.rb +1 -1
- data/app/net_box.rb +9 -9
- data/app/web_box.rb +4 -4
- data/app.rb +6 -7
- data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
- data/app_global.gemfile.rb.lock +19 -0
- data/app_global.rb +4 -0
- data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
- data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
- data/app_new/dev/benches/objects_bench.rb +83 -0
- data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
- data/app_new/dev/benches/sorted_bench.rb +54 -0
- data/app_new/dev/benches/sorted_bench_test.rb +12 -0
- data/app_new/dev/benches/variables_bench.rb +55 -0
- data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
- data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
- data/{app → app_new}/dev/commands/circle_command.rb +1 -1
- data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
- data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
- data/app_new/dev_box.rb +14 -0
- data/app_new.rb +15 -0
- data/exe/lizarb +9 -1
- data/lib/app.rb +27 -95
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +23 -18
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
- data/lib/dev_system/dev/controllers/bench.rb +1 -9
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +19 -22
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +5 -31
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
- data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +37 -18
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command.rb +9 -15
- 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 +33 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
- data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
- data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
- data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
- data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
- data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
- data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
- data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
- data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -17
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
- data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
- data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
- data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
- data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/log.rb +3 -0
- data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
- data/lib/dev_system/dev/controllers/shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +15 -11
- 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 +27 -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 +59 -18
- data/lib/dev_system/dev/panels/command_panel_test.rb +43 -20
- data/lib/dev_system/dev/panels/generator_panel.rb +73 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +46 -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 +5 -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 +95 -49
- data/lib/liza/base/box.rb +76 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -21
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +40 -27
- data/lib/liza/base/panel_test.rb +36 -12
- data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
- data/lib/liza/meta/part.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -16
- 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 +4 -6
- data/lib/liza/ruby_tests/module_test.rb +3 -3
- data/lib/liza/test/test.rb +7 -10
- data/lib/liza/test/test_test.rb +160 -157
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
- data/lib/liza/test_parts/test_assertions_part.rb +81 -83
- data/lib/liza/test_parts/test_dsl_part.rb +47 -49
- data/lib/liza/test_parts/test_log_part.rb +88 -90
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +73 -120
- data/lib/liza/unit.rb +105 -107
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
- data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
- data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
- data/lib/liza/unit_test.rb +80 -71
- data/lib/liza.rb +10 -1
- data/lib/lizarb/ruby/module.rb +1 -1
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +247 -23
- data/lib/net_system/dev/net_command.rb +15 -17
- 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 +21 -23
- data/lib/net_system/net/controllers/record_test.rb +8 -10
- data/lib/net_system/net/net_box.rb +9 -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 +20 -18
- data/lib/web_system/dev/request_command.rb +8 -22
- data/lib/web_system/dev/web_command.rb +6 -8
- data/lib/web_system/web/controllers/rack.rb +4 -6
- data/lib/web_system/web/controllers/rack_test.rb +11 -13
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
- 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 +37 -39
- data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
- data/lib/web_system/web/panels/request_panel.rb +53 -57
- data/lib/web_system/web/panels/request_panel_test.rb +1 -1
- data/lib/web_system/web/web_box.rb +12 -18
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +1 -1
- metadata +54 -44
- data/.ruby-version +0 -1
- data/app/dev/benches/app_bench.rb +0 -5
- data/app/dev/benches/app_bench_test.rb +0 -7
- data/app/dev/benches/loops_bench_test.rb +0 -11
- data/app/dev/commands/app_command.rb +0 -5
- data/app/dev/commands/app_command_test.rb +0 -7
- data/app/dev/commands/new_command.rb +0 -9
- data/app/dev/commands/new_command_test.rb +0 -7
- data/app/dev/generators/bench_generator.rb +0 -18
- data/app/dev/generators/command_generator/command.rb.erb +0 -26
- data/app/dev/generators/command_generator.rb +0 -18
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/exe/Gemfile.lock +0 -13
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -60
- data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -11
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -14
- data/lib/dev_system/dev/controllers/command/version_command.rb +0 -9
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -14
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -96
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -14
- /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/quadratic_command_test.rb +0 -0
@@ -1,30 +1,71 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class
|
1
|
+
class DevSystem::CommandPanel < Liza::Panel
|
2
|
+
class Error < StandardError; end
|
3
|
+
class ParseError < Error; end
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
def call args
|
6
|
+
log "args = #{args.inspect}" if get :log_details
|
6
7
|
|
7
|
-
|
8
|
+
return call_not_found args if args.none?
|
8
9
|
|
9
|
-
|
10
|
+
struct = parse args[0]
|
11
|
+
struct.command = short struct.command
|
12
|
+
command = find struct.command
|
10
13
|
|
11
|
-
|
14
|
+
case
|
15
|
+
when struct.class_method
|
16
|
+
_call_log "#{command}.#{struct.class_method}(#{args[1..-1]})"
|
17
|
+
command.public_send struct.class_method, args[1..-1]
|
18
|
+
when struct.instance_method
|
19
|
+
_call_log "#{command}.new.#{struct.instance_method}(#{args[1..-1]})"
|
20
|
+
command.new.public_send struct.instance_method, args[1..-1]
|
21
|
+
when struct.method
|
22
|
+
if command.respond_to?(struct.method)
|
23
|
+
_call_log "#{command}.#{struct.method}(#{args[1..-1]})"
|
24
|
+
command.public_send struct.method, args[1..-1]
|
25
|
+
else
|
26
|
+
_call_log "#{command}.new.#{struct.method}(#{args[1..-1]})"
|
27
|
+
command.new.public_send struct.method, args[1..-1]
|
28
|
+
end
|
29
|
+
else
|
30
|
+
_call_log "#{command}.call(#{args[1..-1]})"
|
31
|
+
command.call args[1..-1]
|
32
|
+
end
|
33
|
+
rescue ParseError
|
34
|
+
call_not_found args
|
35
|
+
end
|
12
36
|
|
13
|
-
|
37
|
+
def _call_log string
|
38
|
+
log "#{string}" if get :log_details
|
39
|
+
end
|
14
40
|
|
15
|
-
|
41
|
+
#
|
16
42
|
|
17
|
-
|
43
|
+
PARSE_REGEX = /(?<command>[A-Za-z_]+)(?::(?<class_method>[a-z_]+))?(?:#(?<instance_method>[a-z_]+))?(?:\.(?<method>[a-z_]+))?/
|
18
44
|
|
19
|
-
|
45
|
+
# OpenStruct command class_method instance_method method
|
46
|
+
def parse string
|
47
|
+
md = string.to_s.match PARSE_REGEX
|
48
|
+
raise ParseError if md.nil?
|
49
|
+
hash = md.named_captures
|
50
|
+
log "{#{hash.map { ":#{_1}=>#{_2.to_s.inspect}" }.join(", ") }}" if get :log_details
|
51
|
+
OpenStruct.new hash
|
52
|
+
end
|
20
53
|
|
21
|
-
|
22
|
-
rescue Liza::ConstNotFound
|
23
|
-
call_not_found args
|
24
|
-
end
|
54
|
+
#
|
25
55
|
|
26
|
-
|
27
|
-
|
28
|
-
|
56
|
+
def find string
|
57
|
+
k = Liza.const "#{string}_command"
|
58
|
+
rescue Liza::ConstNotFound
|
59
|
+
k = Liza::NotFoundCommand
|
60
|
+
ensure
|
61
|
+
log k.to_s if get :log_details
|
62
|
+
k
|
29
63
|
end
|
64
|
+
|
65
|
+
#
|
66
|
+
|
67
|
+
def call_not_found args
|
68
|
+
Liza[:NotFoundCommand].call args
|
69
|
+
end
|
70
|
+
|
30
71
|
end
|
@@ -1,23 +1,46 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class CommandPanelTest < Liza::PanelTest
|
3
|
-
|
4
|
-
test :subject_class do
|
5
|
-
assert subject_class == DevSystem::CommandPanel
|
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
|
-
test :call do
|
14
|
-
begin
|
15
|
-
subject.call ["echo", 1, 2, 3]
|
16
|
-
assert false
|
17
|
-
rescue RuntimeError => e
|
18
|
-
assert e.message == "[1, 2, 3]"
|
19
|
-
end
|
20
|
-
end
|
1
|
+
class DevSystem::CommandPanelTest < Liza::PanelTest
|
21
2
|
|
3
|
+
test :subject_class do
|
4
|
+
assert_equality subject_class, DevSystem::CommandPanel
|
22
5
|
end
|
6
|
+
|
7
|
+
test :settings do
|
8
|
+
assert_equality subject_class.log_level, :normal
|
9
|
+
assert_equality subject_class.log_color, :green
|
10
|
+
end
|
11
|
+
|
12
|
+
test :parse do
|
13
|
+
struct = subject.parse "generate"
|
14
|
+
assert_equality struct.command, "generate"
|
15
|
+
assert_equality struct.class_method, nil
|
16
|
+
assert_equality struct.instance_method, nil
|
17
|
+
assert_equality struct.method, nil
|
18
|
+
|
19
|
+
struct = subject.parse "generate:install"
|
20
|
+
assert_equality struct.command, "generate"
|
21
|
+
assert_equality struct.class_method, "install"
|
22
|
+
assert_equality struct.instance_method, nil
|
23
|
+
assert_equality struct.method, nil
|
24
|
+
|
25
|
+
struct = subject.parse "generate#install"
|
26
|
+
assert_equality struct.command, "generate"
|
27
|
+
assert_equality struct.class_method, nil
|
28
|
+
assert_equality struct.instance_method, "install"
|
29
|
+
assert_equality struct.method, nil
|
30
|
+
|
31
|
+
struct = subject.parse "generate.install"
|
32
|
+
assert_equality struct.command, "generate"
|
33
|
+
assert_equality struct.class_method, nil
|
34
|
+
assert_equality struct.instance_method, nil
|
35
|
+
assert_equality struct.method, "install"
|
36
|
+
end
|
37
|
+
|
38
|
+
test :find do
|
39
|
+
klass = subject.find "generate"
|
40
|
+
assert_equality DevSystem::GenerateCommand, klass
|
41
|
+
|
42
|
+
klass = subject.find "g"
|
43
|
+
assert_equality DevSystem::NotFoundCommand, klass
|
44
|
+
end
|
45
|
+
|
23
46
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class DevSystem::GeneratorPanel < Liza::Panel
|
2
|
+
class Error < StandardError; end
|
3
|
+
class ParseError < Error; end
|
4
|
+
|
5
|
+
#
|
6
|
+
|
7
|
+
def call args
|
8
|
+
log "args = #{args}"
|
9
|
+
|
10
|
+
return call_not_found args if args.none?
|
11
|
+
|
12
|
+
struct = parse args[0]
|
13
|
+
struct.generator = short struct.generator
|
14
|
+
generator = find struct.generator
|
15
|
+
|
16
|
+
case
|
17
|
+
when struct.class_method
|
18
|
+
_call_log "#{generator}.#{struct.class_method}(#{args[1..-1]})"
|
19
|
+
generator.public_send struct.class_method, args[1..-1]
|
20
|
+
when struct.instance_method
|
21
|
+
_call_log "#{generator}.new.#{struct.instance_method}(#{args[1..-1]})"
|
22
|
+
generator.new.public_send struct.instance_method, args[1..-1]
|
23
|
+
when struct.method
|
24
|
+
if generator.respond_to?(struct.method)
|
25
|
+
_call_log "#{generator}.#{struct.method}(#{args[1..-1]})"
|
26
|
+
generator.public_send struct.method, args[1..-1]
|
27
|
+
else
|
28
|
+
_call_log "#{generator}.new.#{struct.method}(#{args[1..-1]})"
|
29
|
+
generator.new.public_send struct.method, args[1..-1]
|
30
|
+
end
|
31
|
+
else
|
32
|
+
_call_log "#{generator}.call(#{args[1..-1]})"
|
33
|
+
generator.call args[1..-1]
|
34
|
+
end
|
35
|
+
rescue ParseError
|
36
|
+
call_not_found args
|
37
|
+
end
|
38
|
+
|
39
|
+
def _call_log string
|
40
|
+
log "#{string}" if get :log_details
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
|
45
|
+
PARSE_REGEX = /(?<generator>[a-z_]+)(?::(?<class_method>[a-z_]+))?(?:#(?<instance_method>[a-z_]+))?(?:\.(?<method>[a-z_]+))?/
|
46
|
+
|
47
|
+
# OpenStruct generator class_method instance_method method
|
48
|
+
def parse string
|
49
|
+
md = string.to_s.match PARSE_REGEX
|
50
|
+
raise ParseError if md.nil?
|
51
|
+
hash = md.named_captures
|
52
|
+
log "{#{hash.map { ":#{_1} => #{_2.to_s.inspect}" }.join(", ") }}" if get :log_details
|
53
|
+
OpenStruct.new hash
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
|
58
|
+
def find string
|
59
|
+
k = Liza.const "#{string}_generator"
|
60
|
+
rescue Liza::ConstNotFound
|
61
|
+
k = Liza::NotFoundGenerator
|
62
|
+
ensure
|
63
|
+
log k.to_s if get :log_details
|
64
|
+
k
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
|
69
|
+
def call_not_found args
|
70
|
+
Liza[:NotFoundGenerator].call args
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class DevSystem::GeneratorPanelTest < Liza::PanelTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::GeneratorPanel
|
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
|
+
test :parse do
|
13
|
+
struct = subject.parse "system"
|
14
|
+
assert_equality struct.generator, "system"
|
15
|
+
assert_equality struct.class_method, nil
|
16
|
+
assert_equality struct.instance_method, nil
|
17
|
+
assert_equality struct.method, nil
|
18
|
+
|
19
|
+
struct = subject.parse "system:install"
|
20
|
+
assert_equality struct.generator, "system"
|
21
|
+
assert_equality struct.class_method, "install"
|
22
|
+
assert_equality struct.instance_method, nil
|
23
|
+
assert_equality struct.method, nil
|
24
|
+
|
25
|
+
struct = subject.parse "system#install"
|
26
|
+
assert_equality struct.generator, "system"
|
27
|
+
assert_equality struct.class_method, nil
|
28
|
+
assert_equality struct.instance_method, "install"
|
29
|
+
assert_equality struct.method, nil
|
30
|
+
|
31
|
+
struct = subject.parse "system.install"
|
32
|
+
assert_equality struct.generator, "system"
|
33
|
+
assert_equality struct.class_method, nil
|
34
|
+
assert_equality struct.instance_method, nil
|
35
|
+
assert_equality struct.method, "install"
|
36
|
+
end
|
37
|
+
|
38
|
+
test :find do
|
39
|
+
klass = subject.find "command"
|
40
|
+
assert_equality DevSystem::CommandGenerator, klass
|
41
|
+
|
42
|
+
klass = subject.find "c"
|
43
|
+
assert_equality DevSystem::NotFoundGenerator, klass
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -1,10 +1,13 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class LogPanel < Liza::Panel
|
1
|
+
class DevSystem::LogPanel < Liza::Panel
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# https://rubyapi.org/3.1/o/logger
|
4
|
+
def call string
|
5
|
+
unless App.mode == :code
|
6
|
+
pid = Process.pid
|
7
|
+
tid = Lizarb.thread_id.to_s.rjust_zeroes 3
|
8
|
+
string = "#{pid} #{tid} #{string}"
|
7
9
|
end
|
8
|
-
|
10
|
+
puts string
|
9
11
|
end
|
12
|
+
|
10
13
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class LogPanelTest < Liza::PanelTest
|
1
|
+
class DevSystem::LogPanelTest < Liza::PanelTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::LogPanel
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# test :call do
|
13
|
+
# todo "write this"
|
14
|
+
# end
|
16
15
|
|
17
|
-
end
|
18
16
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class DevSystem::TerminalPanelTest < Liza::PanelTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::TerminalPanel
|
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,12 +1,8 @@
|
|
1
|
-
class HappySystem
|
2
|
-
class HappyBox < Liza::Box
|
3
|
-
has_panel :axo
|
4
|
-
has_controller :axo
|
5
|
-
|
6
|
-
# Set up your axo panel per the DSL in http://guides.lizarb.org/panels/axo.html
|
7
|
-
axo do
|
8
|
-
# set :log_level, ENV["happy.axo.log_level"]
|
9
|
-
end
|
1
|
+
class HappySystem::HappyBox < Liza::Box
|
10
2
|
|
3
|
+
# Configure your axo panel per the DSL in http://guides.lizarb.org/panels/axo.html
|
4
|
+
configure :axo do
|
5
|
+
# set :log_level, ENV["happy.axo.log_level"]
|
11
6
|
end
|
7
|
+
|
12
8
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class HappySystem
|
2
|
-
class HappyBoxTest < Liza::BoxTest
|
1
|
+
class HappySystem::HappyBoxTest < Liza::BoxTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :magenta
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == HappySystem::HappyBox
|
5
|
+
end
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :magenta
|
10
|
+
end
|
16
11
|
|
12
|
+
test :panels do
|
13
|
+
assert subject_class[:axo].is_a? HappySystem::AxoPanel
|
17
14
|
end
|
15
|
+
|
18
16
|
end
|
data/lib/lerb.rb
CHANGED
@@ -3,95 +3,141 @@
|
|
3
3
|
# https://docs.ruby-lang.org/en/3.2/ERB.html
|
4
4
|
require "erb"
|
5
5
|
|
6
|
+
$LERB_VERBOSE = ENV["LERB_VERBOSE"]
|
7
|
+
|
6
8
|
class LERB < ERB
|
7
9
|
class Error < StandardError; end
|
8
10
|
class BuildError < Error; end
|
9
11
|
class ExecutionError < Error; end
|
10
12
|
|
11
|
-
#
|
13
|
+
# output
|
12
14
|
|
13
|
-
def self.
|
14
|
-
|
15
|
+
def self.puts string=nil
|
16
|
+
super if $LERB_VERBOSE
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
ret = []
|
19
|
-
|
20
|
-
fname = path
|
21
|
-
return ret unless File.exist? path
|
19
|
+
# loaders
|
22
20
|
|
23
|
-
|
21
|
+
DEFAULT_KEY = "inline.txt.erb"
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
def self.load path_radical
|
24
|
+
erbs = []
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
"#{path_radical}.rb".tap do |filename|
|
27
|
+
_load erbs, filename
|
28
|
+
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
# => ["a", "html", "erb", "\n<html>\n<a></a>\n</html>\n"]
|
35
|
-
key = "#{chunk[0]}.#{chunk[1]}.#{chunk[2]}"
|
36
|
-
content = chunk[3]
|
37
|
-
ret.push new :file, key, content, fname, lineno
|
30
|
+
Dir.glob("#{path_radical}.*.erb").each do |filename|
|
31
|
+
_load erbs, filename
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
|
-
|
34
|
+
Dir.glob("#{path_radical}/*.*.erb").each do |filename|
|
35
|
+
_load erbs, filename
|
36
|
+
end
|
42
37
|
|
43
|
-
|
44
|
-
ret = []
|
38
|
+
#
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
key = fname.split("/").last
|
50
|
-
content = File.read fname
|
51
|
-
ret.push new :folder, key, content, fname, lineno
|
40
|
+
puts "#{erbs.size} erbs".on_red
|
41
|
+
erbs.each do |h|
|
42
|
+
puts "key: #{h.key}".on_green
|
52
43
|
end
|
53
44
|
|
54
|
-
|
45
|
+
erbs
|
55
46
|
end
|
56
47
|
|
57
|
-
|
48
|
+
def self._load erbs, filename
|
49
|
+
is_erb = filename.end_with? ".erb"
|
50
|
+
is_ignoring_ruby = !is_erb
|
51
|
+
is_accepting_views = false
|
52
|
+
|
53
|
+
puts
|
54
|
+
puts "LERB filename: #{filename}".on_red
|
55
|
+
|
56
|
+
puts "LERB is_erb: #{is_erb}".on_red
|
57
|
+
puts "LERB is_ignoring_ruby: #{is_ignoring_ruby}".on_red
|
58
|
+
puts "LERB is_accepting_views: #{is_accepting_views}".on_red
|
59
|
+
|
60
|
+
current_lineno = 0
|
61
|
+
current_content = ""
|
62
|
+
current_key = is_erb ? filename.split("/").last : DEFAULT_KEY
|
63
|
+
|
64
|
+
if current_key
|
65
|
+
puts "LERB declare: #{current_key} | because not erb".green
|
66
|
+
end
|
58
67
|
|
59
|
-
|
68
|
+
File.readlines(filename).each.with_index do |line, lineno|
|
69
|
+
is_line_end = line == "__END__\n"
|
70
|
+
|
71
|
+
# stop ignoring ruby lines if line is __END__
|
72
|
+
# move to next line if ignoring ruby lines
|
73
|
+
|
74
|
+
if is_ignoring_ruby
|
75
|
+
puts "LERB ignore: #{lineno}: #{line[0..-2]}".light_black
|
76
|
+
if is_line_end
|
77
|
+
is_ignoring_ruby = false
|
78
|
+
is_accepting_views = true
|
79
|
+
current_lineno = lineno + 1
|
80
|
+
puts "LERB declare: #{current_key} | current".green if current_key
|
81
|
+
end
|
82
|
+
next
|
83
|
+
end
|
84
|
+
|
85
|
+
if is_accepting_views && line[0..6] == "# view "
|
86
|
+
_load_into erbs, filename, current_lineno, current_key, current_content
|
87
|
+
current_key = line[7..-1].strip
|
88
|
+
current_lineno = lineno + 1
|
89
|
+
current_content = ""
|
90
|
+
puts "LERB declare: #{current_key} | #{lineno}: #{line[0..-2]}".green
|
91
|
+
else
|
92
|
+
current_content += line
|
93
|
+
puts "LERB keeping: #{lineno}: #{line[0..-2]}".bold.white
|
94
|
+
end
|
95
|
+
|
96
|
+
if is_line_end
|
97
|
+
puts "LERB warning: #{lineno}: #{line[0..-2]} found! No longer accepting views".light_yellow
|
98
|
+
is_accepting_views = false
|
99
|
+
end
|
100
|
+
end
|
60
101
|
|
61
|
-
|
62
|
-
|
102
|
+
_load_into erbs, filename, current_lineno, current_key, current_content
|
103
|
+
|
104
|
+
erbs
|
63
105
|
end
|
64
106
|
|
65
|
-
|
107
|
+
def self._load_into erbs, filename, lineno, key, content
|
108
|
+
return unless key
|
109
|
+
return unless key.end_with? "erb"
|
110
|
+
return if content.strip.empty?
|
66
111
|
|
67
|
-
|
112
|
+
content += "\n" if content[-1] != "\n"
|
68
113
|
|
69
|
-
|
70
|
-
@source == :file
|
114
|
+
erbs.push new filename, lineno, key, content
|
71
115
|
end
|
72
116
|
|
73
|
-
|
74
|
-
|
117
|
+
# format
|
118
|
+
|
119
|
+
TAG_FORMATS = %w|xml html|
|
120
|
+
|
121
|
+
def tags?
|
122
|
+
TAG_FORMATS.include? format
|
75
123
|
end
|
76
124
|
|
77
125
|
# constructor
|
78
126
|
|
79
127
|
TRIM_MODE = "<>-"
|
80
128
|
|
81
|
-
attr_reader :
|
82
|
-
|
83
|
-
def initialize source, key, content, filename, lineno
|
84
|
-
raise BuildError, "source :#{source} must be one of #{SOURCES}" unless SOURCES.include? source
|
129
|
+
attr_reader :key, :name, :format
|
85
130
|
|
131
|
+
def initialize filename, lineno, key, content
|
86
132
|
segments = key.split("/").last.split(".")
|
87
133
|
name, format = segments[0..1]
|
88
134
|
|
89
|
-
|
90
|
-
|
91
|
-
|
135
|
+
if format.gsub(/[^a-z0-9]/, "") != format
|
136
|
+
raise BuildError, "key '#{key}' has an invalid format '#{format}'"
|
137
|
+
end
|
92
138
|
|
93
139
|
super content, trim_mode: TRIM_MODE
|
94
|
-
|
140
|
+
self.filename, self.lineno, @key, @name, @format = filename, lineno, key, name, format
|
95
141
|
end
|
96
142
|
|
97
143
|
# result
|