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
@@ -2,15 +2,8 @@ class WebSystem::RequestCommand < Liza::Command
|
|
2
2
|
|
3
3
|
VALID_ACTIONS = %w[find get post]
|
4
4
|
|
5
|
-
def self.call(args)
|
6
|
-
log "Called #{self}.#{__method__} with args #{args}"
|
7
|
-
new.call(args)
|
8
|
-
end
|
9
|
-
|
10
|
-
# instance methods
|
11
|
-
|
12
5
|
def call(args)
|
13
|
-
log "
|
6
|
+
log "args = #{args.inspect}"
|
14
7
|
|
15
8
|
@command = args.shift
|
16
9
|
@args = args
|
@@ -23,8 +16,6 @@ class WebSystem::RequestCommand < Liza::Command
|
|
23
16
|
end
|
24
17
|
|
25
18
|
def perform
|
26
|
-
log "Called #{self}.#{__method__}"
|
27
|
-
|
28
19
|
case @command
|
29
20
|
when "find"
|
30
21
|
find
|
@@ -36,19 +27,16 @@ class WebSystem::RequestCommand < Liza::Command
|
|
36
27
|
end
|
37
28
|
|
38
29
|
def handle
|
39
|
-
log "Called #{self}.#{__method__}"
|
40
30
|
log render "error.txt"
|
41
31
|
end
|
42
32
|
|
43
33
|
def help
|
44
|
-
log "Called #{self}.#{__method__}"
|
45
34
|
log render "help.txt"
|
46
35
|
end
|
47
36
|
|
48
37
|
# actions
|
49
38
|
|
50
39
|
def find
|
51
|
-
log "Called #{self}.#{__method__}"
|
52
40
|
path = @args.first
|
53
41
|
|
54
42
|
@env = {}
|
@@ -56,13 +44,12 @@ class WebSystem::RequestCommand < Liza::Command
|
|
56
44
|
|
57
45
|
request_panel.find @env
|
58
46
|
|
59
|
-
@request_class = @env["LIZA_REQUEST_CLASS"]
|
47
|
+
@request_class = @env["LIZA_REQUEST_CLASS"] || raise("No request class found")
|
60
48
|
|
61
49
|
puts render "find.txt"
|
62
50
|
end
|
63
51
|
|
64
52
|
def get_request
|
65
|
-
log "Called #{self}.#{__method__}"
|
66
53
|
path = @args.first
|
67
54
|
|
68
55
|
@env = {}
|
@@ -75,7 +62,6 @@ class WebSystem::RequestCommand < Liza::Command
|
|
75
62
|
end
|
76
63
|
|
77
64
|
def post_request
|
78
|
-
log "Called #{self}.#{__method__}"
|
79
65
|
path = @args.first
|
80
66
|
|
81
67
|
@env = {}
|
@@ -90,20 +76,20 @@ class WebSystem::RequestCommand < Liza::Command
|
|
90
76
|
# helpers
|
91
77
|
|
92
78
|
def request_panel
|
93
|
-
|
79
|
+
@request_panel ||= WebBox[:request]
|
94
80
|
end
|
95
81
|
end
|
96
82
|
|
97
83
|
__END__
|
98
84
|
|
99
|
-
# success.txt.erb
|
85
|
+
# view success.txt.erb
|
100
86
|
|
101
87
|
RESULT:
|
102
88
|
|
103
89
|
class <%= @result.class %>
|
104
90
|
value <%= @result %>
|
105
91
|
|
106
|
-
# error.txt.erb
|
92
|
+
# view error.txt.erb
|
107
93
|
|
108
94
|
ERROR:
|
109
95
|
|
@@ -111,7 +97,7 @@ class <%= @error.class %>
|
|
111
97
|
message <%= @error.message %>
|
112
98
|
backtrace <%= @error.backtrace.select { |s| @stop = true if s.include?("/exe/lizarb:"); !defined? @stop }.join "\n " %>
|
113
99
|
|
114
|
-
# help.txt.erb
|
100
|
+
# view help.txt.erb
|
115
101
|
|
116
102
|
USAGE:
|
117
103
|
|
@@ -119,7 +105,7 @@ liza request find /path/to/action.format
|
|
119
105
|
liza request get /path/to/action.format
|
120
106
|
liza request post /path/to/action.format
|
121
107
|
|
122
|
-
# find.txt.erb
|
108
|
+
# view find.txt.erb
|
123
109
|
|
124
110
|
ENV:
|
125
111
|
<% @env.each do |k, v| %>
|
@@ -133,7 +119,7 @@ class <%= @request_class %> < <%= @request_class.superclass %>
|
|
133
119
|
# ...
|
134
120
|
end
|
135
121
|
|
136
|
-
# response.http.erb
|
122
|
+
# view response.http.erb
|
137
123
|
|
138
124
|
<%= @status %>
|
139
125
|
<% @headers.each do |k, v| -%>
|
@@ -1,11 +1,9 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class WebCommand < Liza::Command
|
3
|
-
|
4
|
-
def self.call args
|
5
|
-
log "args #{args}"
|
6
|
-
log "DEPRECATED: please use `lizarb rack` instead"
|
7
|
-
RackCommand.call args
|
8
|
-
end
|
1
|
+
class WebSystem::WebCommand < Liza::Command
|
9
2
|
|
3
|
+
def self.call args
|
4
|
+
log "args #{args}"
|
5
|
+
log "DEPRECATED: please use `lizarb rack` instead"
|
6
|
+
RackCommand.call args
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class RackTest < Liza::ControllerTest
|
1
|
+
class WebSystem::RackTest < Liza::ControllerTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == WebSystem::Rack
|
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 == :blue
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# test :call do
|
13
|
+
# todo "write this"
|
14
|
+
# end
|
16
15
|
|
17
|
-
end
|
18
16
|
end
|
@@ -1,17 +1,15 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class ClientErrorRequest < Request
|
1
|
+
class WebSystem::ClientErrorRequest < WebSystem::Request
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call env
|
4
|
+
status = 400
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
headers = {
|
7
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
8
|
+
}
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
[status, headers, [body]]
|
14
|
-
end
|
10
|
+
body = "Client Error #{status} - #{env["LIZA_PATH"]}"
|
15
11
|
|
12
|
+
[status, headers, [body]]
|
16
13
|
end
|
14
|
+
|
17
15
|
end
|
@@ -1,17 +1,15 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class NotFoundRequest < Request
|
1
|
+
class WebSystem::NotFoundRequest < WebSystem::Request
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call env
|
4
|
+
status = 404
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
headers = {
|
7
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
8
|
+
}
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
[status, headers, [body]]
|
14
|
-
end
|
10
|
+
body = "Client Error #{status} - #{env["LIZA_PATH"]}"
|
15
11
|
|
12
|
+
[status, headers, [body]]
|
16
13
|
end
|
14
|
+
|
17
15
|
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class ServerErrorRequest < Request
|
1
|
+
class WebSystem::ServerErrorRequest < WebSystem::Request
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call env
|
4
|
+
status = 500
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
headers = {
|
7
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
8
|
+
}
|
10
9
|
|
11
|
-
|
10
|
+
e = env["LIZA_ERROR"]
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
[status, headers, [body]]
|
16
|
-
end
|
12
|
+
body = "Server Error #{status} - #{e.class} - #{e.message}"
|
17
13
|
|
14
|
+
[status, headers, [body]]
|
18
15
|
end
|
16
|
+
|
19
17
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class RequestTest < Liza::ControllerTest
|
1
|
+
class WebSystem::RequestTest < Liza::ControllerTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == WebSystem::Request
|
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 == :blue
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# test :call do
|
13
|
+
# todo "write this"
|
14
|
+
# end
|
16
15
|
|
17
|
-
end
|
18
16
|
end
|
@@ -1,44 +1,42 @@
|
|
1
|
-
class WebSystem
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
rack_app = Object::Rack::Cascade.new [rack_files, rack_app]
|
21
|
-
|
22
|
-
# TODO: PumaRack
|
23
|
-
# handler = Liza.const(:"#{strategy}_rack")
|
24
|
-
|
25
|
-
require "rack/handler/puma"
|
26
|
-
handler = Object::Rack::Handler::Puma
|
27
|
-
handler.run rack_app, Host: host, Port: port
|
28
|
-
end
|
1
|
+
class WebSystem::RackPanel < Liza::Panel
|
2
|
+
|
3
|
+
def call strategy, host, port
|
4
|
+
puts
|
5
|
+
log({strategy:, host:, port:})
|
6
|
+
|
7
|
+
strategy ||= get :strategy
|
8
|
+
host ||= get :host
|
9
|
+
port ||= 3000
|
10
|
+
files ||= get :files
|
11
|
+
|
12
|
+
log({strategy:, host:, port:})
|
13
|
+
|
14
|
+
x = App.mode == :code ? "development" : "production"
|
15
|
+
ENV["RACK_ENV"] = x
|
16
|
+
rack_app = send "get_rack_app_#{x}"
|
17
|
+
|
18
|
+
rack_files = Object::Rack::Files.new files
|
19
|
+
rack_app = Object::Rack::Cascade.new [rack_files, rack_app]
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
21
|
+
# TODO: PumaRack
|
22
|
+
# handler = Liza.const(:"#{strategy}_rack")
|
23
|
+
|
24
|
+
require "rack/handler/puma"
|
25
|
+
handler = Object::Rack::Handler::Puma
|
26
|
+
handler.run rack_app, Host: host, Port: port
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_rack_app_production()= WebBox[:request]
|
30
|
+
|
31
|
+
def get_rack_app_development
|
32
|
+
Proc.new do |env|
|
33
|
+
ret = nil
|
34
|
+
App.reload do
|
35
|
+
log "reloading"
|
36
|
+
ret = get_rack_app_production.call env
|
40
37
|
end
|
38
|
+
ret
|
41
39
|
end
|
42
|
-
|
43
40
|
end
|
41
|
+
|
44
42
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class RackPanelTest < Liza::PanelTest
|
1
|
+
class WebSystem::RackPanelTest < Liza::PanelTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
test :settings do
|
4
|
+
assert subject_class.log_level == :normal
|
5
|
+
assert subject_class.log_color == :blue
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
# test :call do
|
9
|
+
# todo "write this"
|
10
|
+
# end
|
12
11
|
|
13
|
-
end
|
14
12
|
end
|
@@ -1,74 +1,70 @@
|
|
1
|
-
class WebSystem
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
def find env
|
24
|
-
_prepare env
|
1
|
+
class WebSystem::RequestPanel < Liza::Panel
|
2
|
+
|
3
|
+
def call env
|
4
|
+
t = Time.now
|
5
|
+
request_klass = find env
|
6
|
+
ret = request_klass.call env
|
7
|
+
_html_beautify env, ret
|
8
|
+
ret
|
9
|
+
rescue => e
|
10
|
+
request_klass = WebSystem::ServerErrorRequest
|
11
|
+
env["LIZA_ERROR"] = e
|
12
|
+
|
13
|
+
ret = request_klass.call env
|
14
|
+
ensure
|
15
|
+
log "#{ret[0]} with #{ret[2].first.size} bytes in #{t.diff}s"
|
16
|
+
puts
|
17
|
+
ret
|
18
|
+
end
|
25
19
|
|
26
|
-
|
20
|
+
#
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
action = segments.shift || "index"
|
22
|
+
def find env
|
23
|
+
_prepare env
|
31
24
|
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
segments = env["LIZA_SEGMENTS"].dup
|
26
|
+
request = segments.shift || "root"
|
27
|
+
action = segments.shift || "index"
|
35
28
|
|
36
|
-
|
29
|
+
env["LIZA_REQUEST"] = request
|
30
|
+
env["LIZA_ACTION"] = action
|
31
|
+
format = env["LIZA_FORMAT"]
|
37
32
|
|
38
|
-
|
39
|
-
end
|
33
|
+
log({request:, action:, format:})
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
rescue NameError
|
44
|
-
NotFoundRequest
|
45
|
-
end
|
35
|
+
env["LIZA_REQUEST_CLASS"] = _find_request_class request
|
36
|
+
end
|
46
37
|
|
47
|
-
|
38
|
+
def _find_request_class request
|
39
|
+
Liza.const "#{request}_request"
|
40
|
+
rescue NameError
|
41
|
+
WebSystem::NotFoundRequest
|
42
|
+
end
|
48
43
|
|
49
|
-
|
50
|
-
return unless defined? HtmlBeautifier
|
51
|
-
return unless env["LIZA_FORMAT"] == "html"
|
44
|
+
#
|
52
45
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
46
|
+
def _html_beautify env, ret
|
47
|
+
return unless defined? HtmlBeautifier
|
48
|
+
return unless env["LIZA_FORMAT"] == "html"
|
57
49
|
|
58
|
-
|
59
|
-
|
50
|
+
body = ret[2].first
|
51
|
+
body = HtmlBeautifier.beautify body
|
52
|
+
ret[2] = [body]
|
53
|
+
end
|
60
54
|
|
61
|
-
|
55
|
+
def _prepare env
|
56
|
+
log "#{env["REQUEST_METHOD"]} #{env["REQUEST_PATH"]}"
|
62
57
|
|
63
|
-
|
64
|
-
format = "html" if format.empty?
|
58
|
+
path = env["REQUEST_PATH"]
|
65
59
|
|
66
|
-
|
60
|
+
path, _sep, format = path.lpartition "."
|
61
|
+
format = "html" if format.empty?
|
67
62
|
|
68
|
-
|
69
|
-
env["LIZA_FORMAT"] = format
|
70
|
-
env["LIZA_SEGMENTS"] = segments
|
71
|
-
end
|
63
|
+
segments = Array path.split("/")[1..-1]
|
72
64
|
|
65
|
+
env["LIZA_PATH"] = path
|
66
|
+
env["LIZA_FORMAT"] = format
|
67
|
+
env["LIZA_SEGMENTS"] = segments
|
73
68
|
end
|
69
|
+
|
74
70
|
end
|
@@ -1,24 +1,18 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class WebBox < Liza::Box
|
3
|
-
has_panel :rack, :rack
|
4
|
-
has_controller :rack, :rack
|
5
|
-
has_panel :request, :requests
|
6
|
-
has_controller :request, :requests
|
1
|
+
class WebSystem::WebBox < Liza::Box
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
set :files, App.root.join("web_files")
|
13
|
-
set :host, "localhost"
|
14
|
-
set :port, 3000
|
15
|
-
end
|
3
|
+
# Configure your rack panel per the DSL in http://guides.lizarb.org/panels/rack.html
|
4
|
+
configure :rack do
|
5
|
+
# set :log_level, ENV["web.rack.log_level"]
|
16
6
|
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
set :files, App.root.join("web_files")
|
8
|
+
set :host, "localhost"
|
9
|
+
set :port, 3000
|
10
|
+
end
|
20
11
|
|
21
|
-
|
12
|
+
# Configure your request panel per the DSL in http://guides.lizarb.org/panels/request.html
|
13
|
+
configure :request do
|
14
|
+
# set :log_level, ENV["web.request.log_level"]
|
22
15
|
|
23
16
|
end
|
17
|
+
|
24
18
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class WebBoxTest < Liza::BoxTest
|
1
|
+
class WebSystem::WebBoxTest < 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 == :blue
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == WebSystem::WebBox
|
5
|
+
end
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :blue
|
10
|
+
end
|
16
11
|
|
12
|
+
test :panels do
|
13
|
+
assert subject_class[:request].is_a? WebSystem::RequestPanel
|
17
14
|
end
|
15
|
+
|
18
16
|
end
|
data/lizarb.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "Liza is a light, experimental framework primarily developed to help study the Ruby language and the Ruby ecosystem."
|
13
13
|
spec.homepage = "http://lizarb.org"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 3.
|
15
|
+
spec.required_ruby_version = ">= 3.1.0"
|
16
16
|
|
17
17
|
spec.metadata = {
|
18
18
|
"homepage_uri" => "https://github.com/rubyonrails-brasil/lizarb",
|