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
@@ -0,0 +1,66 @@
|
|
1
|
+
class QuadraticCommand < NarrativeMethodCommand
|
2
|
+
class Error < Error; end
|
3
|
+
|
4
|
+
def self.quadratic(a, b, c)
|
5
|
+
d = b**2 - 4 * a * c
|
6
|
+
case
|
7
|
+
when d < 0
|
8
|
+
[]
|
9
|
+
when d == 0
|
10
|
+
[-b / (2 * a)]
|
11
|
+
else
|
12
|
+
[(-b + Math.sqrt(d)) / (2 * a), (-b - Math.sqrt(d)) / (2 * a)].sort
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# instance methods
|
17
|
+
|
18
|
+
def validate
|
19
|
+
log "Called #{self}.#{__method__}"
|
20
|
+
raise Invalid, "liza quadratic 0 0 0" if @args.size != 3
|
21
|
+
|
22
|
+
@a = @args[0].to_f
|
23
|
+
@b = @args[1].to_f
|
24
|
+
@c = @args[2].to_f
|
25
|
+
|
26
|
+
log "@a = #{@a}"
|
27
|
+
log "@b = #{@b}"
|
28
|
+
log "@c = #{@c}"
|
29
|
+
|
30
|
+
raise Invalid, "a can't be zero" if @a == 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def perform
|
34
|
+
log "Called #{self}.#{__method__}"
|
35
|
+
|
36
|
+
@result = self.class.quadratic(@a, @b, @c)
|
37
|
+
log "RESULT: #{@result}"
|
38
|
+
log render "success.txt"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
__END__
|
44
|
+
|
45
|
+
# help.txt.erb
|
46
|
+
|
47
|
+
NAME:
|
48
|
+
|
49
|
+
liza quadratic
|
50
|
+
|
51
|
+
DESCRIPTION:
|
52
|
+
|
53
|
+
Calculates the result of a quadratic equation.
|
54
|
+
|
55
|
+
USAGE:
|
56
|
+
|
57
|
+
liza quadratic <a> <b> <c>
|
58
|
+
|
59
|
+
where <a>, <b> and <c> are numbers.
|
60
|
+
|
61
|
+
EXAMPLES:
|
62
|
+
|
63
|
+
liza quadratic 1 0 0
|
64
|
+
liza quadratic 1 0 1
|
65
|
+
liza quadratic 1 1 1
|
66
|
+
liza quadratic 1 2 1
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class QuadraticCommandTest < NarrativeMethodCommandTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == QuadraticCommand
|
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 :subject_class, :quadratic do
|
13
|
+
assert subject_class.quadratic(1, -11, 30) == [5, 6]
|
14
|
+
assert subject_class.quadratic(1, +11, 30) == [-6, -5]
|
15
|
+
end
|
16
|
+
|
17
|
+
test :validate, :valid do
|
18
|
+
subject = subject_class.new
|
19
|
+
subject.instance_variable_set :@args, ["1", "2", "3"]
|
20
|
+
subject.validate
|
21
|
+
assert subject.instance_variable_get(:@a) == 1
|
22
|
+
assert subject.instance_variable_get(:@b) == 2
|
23
|
+
assert subject.instance_variable_get(:@c) == 3
|
24
|
+
end
|
25
|
+
|
26
|
+
test :validate, :invalid do
|
27
|
+
subject = subject_class.new
|
28
|
+
subject.instance_variable_set :@args, ["0", "2", "3"]
|
29
|
+
begin
|
30
|
+
subject.validate
|
31
|
+
assert false
|
32
|
+
rescue QuadraticCommand::Invalid
|
33
|
+
assert true
|
34
|
+
else
|
35
|
+
assert false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
test :perform do
|
40
|
+
subject = subject_class.new
|
41
|
+
subject.instance_variable_set :@args, ["1", "-11", "30"]
|
42
|
+
subject.validate
|
43
|
+
subject.perform
|
44
|
+
assert subject.instance_variable_get(:@result) == [5, 6]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class <%= name.camelize %>Bench < AppBench
|
2
|
+
main_dsl
|
3
|
+
|
4
|
+
setup do
|
5
|
+
N = 1_000_000
|
6
|
+
end
|
7
|
+
|
8
|
+
mark "alternative 1" do
|
9
|
+
i = 0
|
10
|
+
|
11
|
+
while (i += 1) <= N
|
12
|
+
a = "1".to_sym
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
mark "alternative 2" do
|
17
|
+
i = 0
|
18
|
+
|
19
|
+
while (i += 1) <= N
|
20
|
+
a = :"1"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= name.camelize %>BenchTest < AppBenchTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == <%= name.camelize %>Bench
|
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
|
@@ -6,62 +6,13 @@ class BenchGenerator < Liza::Generator
|
|
6
6
|
generate :controller do
|
7
7
|
folder FOLDER
|
8
8
|
filename "#{name}_bench.rb"
|
9
|
-
content
|
9
|
+
content render "bench.rb"
|
10
10
|
end
|
11
11
|
|
12
12
|
generate :controller_test do
|
13
13
|
folder FOLDER
|
14
14
|
filename "#{name}_bench_test.rb"
|
15
|
-
content
|
16
|
-
end
|
17
|
-
|
18
|
-
# helper methods
|
19
|
-
|
20
|
-
def bench_content
|
21
|
-
<<~CODE
|
22
|
-
class #{name.camelize}Bench < AppBench
|
23
|
-
|
24
|
-
main_dsl
|
25
|
-
|
26
|
-
setup do
|
27
|
-
N = 1_000_000
|
28
|
-
end
|
29
|
-
|
30
|
-
mark "alternative 1" do
|
31
|
-
i = 0
|
32
|
-
|
33
|
-
while (i += 1) <= N
|
34
|
-
a = "1".to_sym
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
mark "alternative 2" do
|
39
|
-
i = 0
|
40
|
-
|
41
|
-
while (i += 1) <= N
|
42
|
-
a = :"1"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
CODE
|
48
|
-
end
|
49
|
-
|
50
|
-
def bench_test_content
|
51
|
-
<<~CODE
|
52
|
-
class #{name.camelize}BenchTest < Liza::BenchTest
|
53
|
-
|
54
|
-
test :subject_class do
|
55
|
-
assert subject_class == #{name.camelize}Bench
|
56
|
-
end
|
57
|
-
|
58
|
-
test :settings do
|
59
|
-
assert subject_class.log_level == :normal
|
60
|
-
assert subject_class.log_color == :green
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
CODE
|
15
|
+
content render "bench_test.rb"
|
65
16
|
end
|
66
17
|
|
67
18
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class <%= name.camelize %>Command < AppCommand
|
2
|
+
|
3
|
+
def self.call args
|
4
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
5
|
+
new(args).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize args
|
9
|
+
@args = args
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
log :higher, "Called #{self}.#{__method__}"
|
14
|
+
|
15
|
+
text = render "text.txt"
|
16
|
+
|
17
|
+
log :higher, "text: #{text}"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
__END__
|
23
|
+
|
24
|
+
# text.txt.erb
|
25
|
+
Called <%%= self %>.<%%= __method__ %>
|
26
|
+
@args: <%%= @args %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= name.camelize %>CommandTest < AppCommandTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == <%= name.camelize %>Command
|
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
|
@@ -6,46 +6,13 @@ class CommandGenerator < Liza::Generator
|
|
6
6
|
generate :controller do
|
7
7
|
folder FOLDER
|
8
8
|
filename "#{name}_command.rb"
|
9
|
-
content
|
9
|
+
content render "command.rb"
|
10
10
|
end
|
11
11
|
|
12
12
|
generate :controller_test do
|
13
13
|
folder FOLDER
|
14
14
|
filename "#{name}_command_test.rb"
|
15
|
-
content
|
16
|
-
end
|
17
|
-
|
18
|
-
# helper methods
|
19
|
-
|
20
|
-
def command_content
|
21
|
-
<<~CODE
|
22
|
-
class #{name.camelize}Command < Liza::Command
|
23
|
-
|
24
|
-
def self.call args
|
25
|
-
log :higher, "Called \#{self}.\#{__method__} with args \#{args}"
|
26
|
-
|
27
|
-
#
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
CODE
|
32
|
-
end
|
33
|
-
|
34
|
-
def command_test_content
|
35
|
-
<<~CODE
|
36
|
-
class #{name.camelize}CommandTest < Liza::CommandTest
|
37
|
-
|
38
|
-
test :subject_class do
|
39
|
-
assert subject_class == #{name.camelize}Command
|
40
|
-
end
|
41
|
-
|
42
|
-
test :settings do
|
43
|
-
assert subject_class.log_level == :normal
|
44
|
-
assert subject_class.log_color == :green
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
CODE
|
15
|
+
content render "command_test.rb"
|
49
16
|
end
|
50
17
|
|
51
18
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class RecordGenerator < Liza::Generator
|
2
|
+
main_dsl
|
3
|
+
|
4
|
+
FOLDER = "app/net/records"
|
5
|
+
|
6
|
+
generate :controller do
|
7
|
+
folder FOLDER
|
8
|
+
filename "#{name}_record.rb"
|
9
|
+
content record_content name
|
10
|
+
end
|
11
|
+
|
12
|
+
generate :controller_test do
|
13
|
+
folder FOLDER
|
14
|
+
filename "#{name}_record_test.rb"
|
15
|
+
content record_test_content name
|
16
|
+
end
|
17
|
+
|
18
|
+
# helper methods
|
19
|
+
|
20
|
+
def record_content name
|
21
|
+
<<~CODE
|
22
|
+
class #{name.camelize}Record < AppRecord
|
23
|
+
set :table, :#{name}s
|
24
|
+
|
25
|
+
end
|
26
|
+
CODE
|
27
|
+
end
|
28
|
+
|
29
|
+
def record_test_content name
|
30
|
+
<<~CODE
|
31
|
+
class #{name.camelize}RecordTest < Liza::RecordTest
|
32
|
+
|
33
|
+
test :subject_class do
|
34
|
+
assert subject_class == #{name.camelize}Record
|
35
|
+
end
|
36
|
+
|
37
|
+
test :settings do
|
38
|
+
assert subject_class.log_level == :normal
|
39
|
+
assert subject_class.log_color == :red
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
CODE
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/app/dev_box.rb
CHANGED
@@ -1,13 +1,33 @@
|
|
1
1
|
class DevBox < Liza::DevBox
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# Set up your bench panel per the DSL in http://guides.lizarb.org/panels/bench.html
|
4
|
+
panel :bench do
|
5
|
+
# set :log_level, ENV["dev.bench.log_level"]
|
6
|
+
end
|
7
|
+
|
8
|
+
# Set up your command panel per the DSL in http://guides.lizarb.org/panels/command.html
|
9
|
+
panel :command do
|
10
|
+
# set :log_level, ENV["dev.command.log_level"]
|
11
|
+
end
|
5
12
|
|
13
|
+
# Set up your generator panel per the DSL in http://guides.lizarb.org/panels/generator.html
|
14
|
+
panel :generator do
|
15
|
+
# set :log_level, ENV["dev.generator.log_level"]
|
6
16
|
end
|
7
17
|
|
8
|
-
|
9
|
-
|
18
|
+
# Set up your command panel per the DSL in http://guides.lizarb.org/panels/log.html
|
19
|
+
panel :log do
|
20
|
+
# set :log_level, ENV["dev.log.log_level"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Set up your shell panel per the DSL in http://guides.lizarb.org/panels/shell.html
|
24
|
+
panel :shell do
|
25
|
+
# set :log_level, ENV["dev.shell.log_level"]
|
26
|
+
end
|
10
27
|
|
28
|
+
# Set up your terminal panel per the DSL in http://guides.lizarb.org/panels/terminal.html
|
29
|
+
panel :terminal do
|
30
|
+
# set :log_level, ENV["dev.terminal.log_level"]
|
11
31
|
end
|
12
32
|
|
13
33
|
end
|
data/app/happy_box.rb
CHANGED
@@ -2,11 +2,11 @@ class SqliteDbTest < Liza::SqliteDbTest
|
|
2
2
|
|
3
3
|
test :subject_class do
|
4
4
|
assert subject_class == SqliteDb
|
5
|
-
assert SqliteDb.current.class == SqliteDb
|
6
|
-
assert Liza::SqliteDb.current.class == SqliteDb
|
7
|
-
assert SqliteDb.current == Liza::SqliteDb.current
|
8
|
-
assert SqliteDb.current.client == Liza::SqliteDb.current.client
|
9
|
-
assert SqliteDb.current.client.conn == Liza::SqliteDb.current.client.conn
|
5
|
+
# assert SqliteDb.current.class == SqliteDb
|
6
|
+
# assert Liza::SqliteDb.current.class == SqliteDb
|
7
|
+
# assert SqliteDb.current == Liza::SqliteDb.current
|
8
|
+
# assert SqliteDb.current.client == Liza::SqliteDb.current.client
|
9
|
+
# assert SqliteDb.current.client.conn == Liza::SqliteDb.current.client.conn
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
data/app/net_box.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
class NetBox < Liza::NetBox
|
2
2
|
|
3
|
-
|
3
|
+
panel :client do
|
4
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
|
-
set :
|
8
|
-
set :
|
7
|
+
set :sqlite_path, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
|
8
|
+
set :sqlite_path, "app.#{App.mode}.sqlite"
|
9
9
|
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
panel :database do
|
13
13
|
# Set up your database panel per the DSL in http://guides.lizarb.org/panels/database.html
|
14
14
|
|
15
|
-
define :redis, RedisDb
|
16
|
-
define :sql, SqliteDb
|
17
|
-
define :sqlite, SqliteDb
|
15
|
+
define :redis, RedisDb
|
16
|
+
define :sql, SqliteDb
|
17
|
+
define :sqlite, SqliteDb
|
18
18
|
|
19
19
|
end
|
20
20
|
|
@@ -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,6 +1,14 @@
|
|
1
1
|
class WebBox < Liza::WebBox
|
2
2
|
|
3
|
-
|
3
|
+
panel :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
|
+
|
11
|
+
panel :request do
|
4
12
|
# Set up your request panel per the DSL in http://guides.lizarb.org/panels/request.html
|
5
13
|
|
6
14
|
end
|
data/exe/lrb
ADDED