lizarb 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -13
  3. data/Rakefile +38 -0
  4. data/app/dev_box.rb +26 -4
  5. data/app/happy_box.rb +2 -2
  6. data/app/net/databases/sqlite_db_test.rb +5 -5
  7. data/app/net/records/app_record_test.rb +1 -1
  8. data/app/net/records/post_record_test.rb +1 -1
  9. data/app/net/records/user_record_test.rb +1 -1
  10. data/app/net_box.rb +9 -9
  11. data/app/web_box.rb +4 -4
  12. data/app.rb +6 -7
  13. data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
  14. data/app_global.gemfile.rb.lock +19 -0
  15. data/app_global.rb +4 -0
  16. data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
  17. data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
  18. data/app_new/dev/benches/objects_bench.rb +83 -0
  19. data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
  20. data/app_new/dev/benches/sorted_bench.rb +54 -0
  21. data/app_new/dev/benches/sorted_bench_test.rb +12 -0
  22. data/app_new/dev/benches/variables_bench.rb +55 -0
  23. data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
  24. data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
  25. data/{app → app_new}/dev/commands/circle_command.rb +1 -1
  26. data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
  27. data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
  28. data/app_new/dev_box.rb +14 -0
  29. data/app_new.rb +15 -0
  30. data/exe/lizarb +9 -1
  31. data/lib/app.rb +27 -95
  32. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +23 -18
  33. data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
  34. data/lib/dev_system/dev/controllers/bench.rb +1 -9
  35. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  36. data/lib/dev_system/dev/controllers/command/bench_command.rb +19 -22
  37. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  38. data/lib/dev_system/dev/controllers/command/generate_command.rb +5 -31
  39. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  40. data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
  41. data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
  42. data/lib/dev_system/dev/controllers/command/not_found_command.rb +37 -18
  43. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
  44. data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
  45. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
  46. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
  47. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command.rb +9 -15
  49. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  51. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +33 -37
  52. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  53. data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
  54. data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
  55. data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
  56. data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
  57. data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
  58. data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
  59. data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
  60. data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
  61. data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
  62. data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
  63. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
  64. data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
  65. data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
  66. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -17
  67. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
  68. data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
  69. data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
  70. data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
  71. data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
  72. data/lib/dev_system/dev/controllers/log.rb +3 -0
  73. data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
  74. data/lib/dev_system/dev/controllers/shell.rb +22 -0
  75. data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
  76. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +15 -11
  77. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  78. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  79. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  80. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  81. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  82. data/lib/dev_system/dev/dev_box.rb +27 -16
  83. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  84. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  85. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  86. data/lib/dev_system/dev/panels/command_panel.rb +59 -18
  87. data/lib/dev_system/dev/panels/command_panel_test.rb +43 -20
  88. data/lib/dev_system/dev/panels/generator_panel.rb +73 -0
  89. data/lib/dev_system/dev/panels/generator_panel_test.rb +46 -0
  90. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  91. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  92. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  93. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  94. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  95. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  96. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  97. data/lib/happy_system/happy/happy_box.rb +5 -9
  98. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  99. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  100. data/lib/lerb.rb +95 -49
  101. data/lib/liza/base/box.rb +76 -26
  102. data/lib/liza/base/box_test.rb +7 -9
  103. data/lib/liza/base/controller.rb +19 -21
  104. data/lib/liza/base/controller_test.rb +7 -9
  105. data/lib/liza/base/panel.rb +40 -27
  106. data/lib/liza/base/panel_test.rb +36 -12
  107. data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
  108. data/lib/liza/meta/part.rb +12 -14
  109. data/lib/liza/meta/part_extension.rb +14 -16
  110. data/lib/liza/meta/part_test.rb +4 -6
  111. data/lib/liza/meta/system.rb +12 -14
  112. data/lib/liza/meta/system_test.rb +8 -10
  113. data/lib/liza/ruby_test.rb +4 -6
  114. data/lib/liza/ruby_tests/module_test.rb +3 -3
  115. data/lib/liza/test/test.rb +7 -10
  116. data/lib/liza/test/test_test.rb +160 -157
  117. data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
  118. data/lib/liza/test_parts/test_assertions_part.rb +81 -83
  119. data/lib/liza/test_parts/test_dsl_part.rb +47 -49
  120. data/lib/liza/test_parts/test_log_part.rb +88 -90
  121. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  122. data/lib/liza/test_parts/test_tree_part.rb +73 -120
  123. data/lib/liza/unit.rb +105 -107
  124. data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
  125. data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
  126. data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
  127. data/lib/liza/unit_test.rb +80 -71
  128. data/lib/liza.rb +10 -1
  129. data/lib/lizarb/ruby/module.rb +1 -1
  130. data/lib/lizarb/version.rb +1 -1
  131. data/lib/lizarb.rb +247 -23
  132. data/lib/net_system/dev/net_command.rb +15 -17
  133. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  134. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  135. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  136. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  137. data/lib/net_system/net/controllers/client.rb +1 -3
  138. data/lib/net_system/net/controllers/client_test.rb +8 -10
  139. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  140. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  141. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  142. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  143. data/lib/net_system/net/controllers/database.rb +21 -23
  144. data/lib/net_system/net/controllers/database_test.rb +8 -10
  145. data/lib/net_system/net/controllers/record.rb +21 -23
  146. data/lib/net_system/net/controllers/record_test.rb +8 -10
  147. data/lib/net_system/net/net_box.rb +9 -16
  148. data/lib/net_system/net/net_box_test.rb +12 -14
  149. data/lib/net_system/net/panels/client_panel.rb +1 -3
  150. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  151. data/lib/net_system/net/panels/database_panel.rb +6 -8
  152. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  153. data/lib/web_system/dev/rack_command.rb +20 -18
  154. data/lib/web_system/dev/request_command.rb +8 -22
  155. data/lib/web_system/dev/web_command.rb +6 -8
  156. data/lib/web_system/web/controllers/rack.rb +4 -6
  157. data/lib/web_system/web/controllers/rack_test.rb +11 -13
  158. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
  159. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
  160. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
  161. data/lib/web_system/web/controllers/request.rb +1 -3
  162. data/lib/web_system/web/controllers/request_test.rb +11 -13
  163. data/lib/web_system/web/panels/rack_panel.rb +37 -39
  164. data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
  165. data/lib/web_system/web/panels/request_panel.rb +53 -57
  166. data/lib/web_system/web/panels/request_panel_test.rb +1 -1
  167. data/lib/web_system/web/web_box.rb +12 -18
  168. data/lib/web_system/web/web_box_test.rb +11 -13
  169. data/lizarb.gemspec +1 -1
  170. metadata +54 -44
  171. data/.ruby-version +0 -1
  172. data/app/dev/benches/app_bench.rb +0 -5
  173. data/app/dev/benches/app_bench_test.rb +0 -7
  174. data/app/dev/benches/loops_bench_test.rb +0 -11
  175. data/app/dev/commands/app_command.rb +0 -5
  176. data/app/dev/commands/app_command_test.rb +0 -7
  177. data/app/dev/commands/new_command.rb +0 -9
  178. data/app/dev/commands/new_command_test.rb +0 -7
  179. data/app/dev/generators/bench_generator.rb +0 -18
  180. data/app/dev/generators/command_generator/command.rb.erb +0 -26
  181. data/app/dev/generators/command_generator.rb +0 -18
  182. data/app_new/.gitignore +0 -4
  183. data/app_new/Gemfile +0 -31
  184. data/app_new/Procfile +0 -3
  185. data/exe/Gemfile.lock +0 -13
  186. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -60
  187. data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -11
  188. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -14
  189. data/lib/dev_system/dev/controllers/command/version_command.rb +0 -9
  190. data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -14
  191. data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -96
  192. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -14
  193. /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
  194. /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
  195. /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
  196. /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 "Called #{self}.#{__method__} with args #{args}"
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
- Liza.const(:web_box).requests
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,8 +1,6 @@
1
- class WebSystem
2
- class Rack < Liza::Controller
1
+ class WebSystem::Rack < Liza::Controller
2
+
3
+ # def self.call rack_app, host, port
4
+ # end
3
5
 
4
- # def self.call rack_app, host, port
5
- # end
6
-
7
- end
8
6
  end
@@ -1,18 +1,16 @@
1
- class WebSystem
2
- class RackTest < Liza::ControllerTest
1
+ class WebSystem::RackTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == WebSystem::Rack
6
- end
3
+ test :subject_class do
4
+ assert subject_class == WebSystem::Rack
5
+ end
7
6
 
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :blue
11
- end
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :blue
10
+ end
12
11
 
13
- # test :call do
14
- # todo "write this"
15
- # end
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
- def self.call env
5
- status = 400
3
+ def self.call env
4
+ status = 400
6
5
 
7
- headers = {
8
- "Framework" => "Liza #{Lizarb::VERSION}"
9
- }
6
+ headers = {
7
+ "Framework" => "Liza #{Lizarb::VERSION}"
8
+ }
10
9
 
11
- body = "Client Error #{status} - #{env["LIZA_PATH"]}"
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
- def self.call env
5
- status = 404
3
+ def self.call env
4
+ status = 404
6
5
 
7
- headers = {
8
- "Framework" => "Liza #{Lizarb::VERSION}"
9
- }
6
+ headers = {
7
+ "Framework" => "Liza #{Lizarb::VERSION}"
8
+ }
10
9
 
11
- body = "Client Error #{status} - #{env["LIZA_PATH"]}"
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
- def self.call env
5
- status = 500
3
+ def self.call env
4
+ status = 500
6
5
 
7
- headers = {
8
- "Framework" => "Liza #{Lizarb::VERSION}"
9
- }
6
+ headers = {
7
+ "Framework" => "Liza #{Lizarb::VERSION}"
8
+ }
10
9
 
11
- e = env["LIZA_ERROR"]
10
+ e = env["LIZA_ERROR"]
12
11
 
13
- body = "Server Error #{status} - #{e.class} - #{e.message}"
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,5 +1,3 @@
1
- class WebSystem
2
- class Request < Liza::Controller
1
+ class WebSystem::Request < Liza::Controller
3
2
 
4
- end
5
3
  end
@@ -1,18 +1,16 @@
1
- class WebSystem
2
- class RequestTest < Liza::ControllerTest
1
+ class WebSystem::RequestTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == WebSystem::Request
6
- end
3
+ test :subject_class do
4
+ assert subject_class == WebSystem::Request
5
+ end
7
6
 
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :blue
11
- end
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :blue
10
+ end
12
11
 
13
- # test :call do
14
- # todo "write this"
15
- # end
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
- class RackPanel < Liza::Panel
3
-
4
- def call strategy, host, port
5
- puts
6
- log({strategy:, host:, port:})
7
-
8
- strategy ||= get :strategy
9
- host ||= get :host
10
- port ||= 3000
11
- files ||= get :files
12
-
13
- log({strategy:, host:, port:})
14
-
15
- x = App.mode == :code ? "development" : "production"
16
- ENV["RACK_ENV"] = x
17
- rack_app = send "get_rack_app_#{x}"
18
-
19
- rack_files = Object::Rack::Files.new files
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
- def get_rack_app_production()= Liza.const(:web_box).requests
31
-
32
- def get_rack_app_development
33
- Proc.new do |env|
34
- ret = nil
35
- App.reload do
36
- log "reloading"
37
- ret = get_rack_app_production.call env
38
- end
39
- ret
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
- test :settings do
5
- assert subject_class.log_level == :normal
6
- assert subject_class.log_color == :blue
7
- end
3
+ test :settings do
4
+ assert subject_class.log_level == :normal
5
+ assert subject_class.log_color == :blue
6
+ end
8
7
 
9
- # test :call do
10
- # todo "write this"
11
- # end
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
- class RequestPanel < Liza::Panel
3
-
4
- def call env
5
- t = Time.now
6
- request_klass = find env
7
- ret = request_klass.call env
8
- _html_beautify env, ret
9
- ret
10
- rescue => e
11
- request_klass = ServerErrorRequest
12
- env["LIZA_ERROR"] = e
13
-
14
- ret = request_klass.call env
15
- ensure
16
- log "#{ret[0]} with #{ret[2].first.size} bytes in #{t.diff}s"
17
- puts
18
- ret
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
- path = env["LIZA_PATH"]
20
+ #
27
21
 
28
- segments = env["LIZA_SEGMENTS"].dup
29
- request = segments.shift || "root"
30
- action = segments.shift || "index"
22
+ def find env
23
+ _prepare env
31
24
 
32
- env["LIZA_REQUEST"] = request
33
- env["LIZA_ACTION"] = action
34
- format = env["LIZA_FORMAT"]
25
+ segments = env["LIZA_SEGMENTS"].dup
26
+ request = segments.shift || "root"
27
+ action = segments.shift || "index"
35
28
 
36
- log({request:, action:, format:})
29
+ env["LIZA_REQUEST"] = request
30
+ env["LIZA_ACTION"] = action
31
+ format = env["LIZA_FORMAT"]
37
32
 
38
- env["LIZA_REQUEST_CLASS"] = _find_request_class request
39
- end
33
+ log({request:, action:, format:})
40
34
 
41
- def _find_request_class request
42
- Liza.const "#{request}_request"
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
- def _html_beautify env, ret
50
- return unless defined? HtmlBeautifier
51
- return unless env["LIZA_FORMAT"] == "html"
44
+ #
52
45
 
53
- body = ret[2].first
54
- body = HtmlBeautifier.beautify body
55
- ret[2] = [body]
56
- end
46
+ def _html_beautify env, ret
47
+ return unless defined? HtmlBeautifier
48
+ return unless env["LIZA_FORMAT"] == "html"
57
49
 
58
- def _prepare env
59
- log "#{env["REQUEST_METHOD"]} #{env["REQUEST_PATH"]}"
50
+ body = ret[2].first
51
+ body = HtmlBeautifier.beautify body
52
+ ret[2] = [body]
53
+ end
60
54
 
61
- path = env["REQUEST_PATH"]
55
+ def _prepare env
56
+ log "#{env["REQUEST_METHOD"]} #{env["REQUEST_PATH"]}"
62
57
 
63
- path, _sep, format = path.lpartition "."
64
- format = "html" if format.empty?
58
+ path = env["REQUEST_PATH"]
65
59
 
66
- segments = Array path.split("/")[1..-1]
60
+ path, _sep, format = path.lpartition "."
61
+ format = "html" if format.empty?
67
62
 
68
- env["LIZA_PATH"] = path
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
@@ -8,7 +8,7 @@ class WebSystem::RequestPanelTest < Liza::PanelTest
8
8
  #
9
9
 
10
10
  test :_prepare do
11
- subject = WebSystem::WebBox.requests
11
+ subject = WebBox[:request]
12
12
  env = {}
13
13
  env["REQUEST_PATH"] = "/foo/bar/baz"
14
14
  subject._prepare env
@@ -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
- # Set up your rack panel per the DSL in http://guides.lizarb.org/panels/rack.html
9
- rack do
10
- # set :log_level, ENV["web.rack.log_level"]
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
- # Set up your request panel per the DSL in http://guides.lizarb.org/panels/request.html
18
- requests do
19
- # set :log_level, ENV["web.request.log_level"]
7
+ set :files, App.root.join("web_files")
8
+ set :host, "localhost"
9
+ set :port, 3000
10
+ end
20
11
 
21
- end
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
- test :subject_class do
5
- assert subject_class == WebSystem::WebBox
6
- end
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
- test :panels do
14
- assert subject_class.requests.is_a? RequestPanel
15
- end
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.2.0"
15
+ spec.required_ruby_version = ">= 3.1.0"
16
16
 
17
17
  spec.metadata = {
18
18
  "homepage_uri" => "https://github.com/rubyonrails-brasil/lizarb",