lizarb 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.tool-versions +1 -0
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +7 -4
  6. data/README.md +23 -64
  7. data/README_SYSTEMS.md +80 -0
  8. data/Rakefile +3 -1
  9. data/app/dev/benches/loops_bench.rb +35 -0
  10. data/app/dev/commands/calculator_command.rb +69 -0
  11. data/app/dev/commands/calculator_command_test.rb +58 -0
  12. data/app/dev/commands/circle_command.rb +70 -0
  13. data/app/dev/commands/circle_command_test.rb +76 -0
  14. data/app/dev/commands/narrative_method_command.rb +60 -0
  15. data/app/dev/commands/narrative_method_command_test.rb +36 -0
  16. data/app/dev/commands/quadratic_command.rb +66 -0
  17. data/app/dev/commands/quadratic_command_test.rb +47 -0
  18. data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
  19. data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
  20. data/app/dev/generators/bench_generator.rb +2 -51
  21. data/app/dev/generators/command_generator/command.rb.erb +26 -0
  22. data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
  23. data/app/dev/generators/command_generator.rb +2 -35
  24. data/app/dev/generators/record_generator.rb +46 -0
  25. data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
  26. data/app/dev_box.rb +24 -4
  27. data/app/happy_box.rb +1 -1
  28. data/app/net/databases/sqlite_db_test.rb +5 -5
  29. data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
  30. data/app/net/records/app_record_test.rb +8 -0
  31. data/app/net/records/post_record.rb +4 -0
  32. data/app/net/records/post_record_test.rb +8 -0
  33. data/app/net/records/user_record.rb +4 -0
  34. data/app/net/records/user_record_test.rb +8 -0
  35. data/app/net_box.rb +7 -7
  36. data/app/web/requests/api_request.rb +8 -7
  37. data/app/web/requests/assets_request.rb +12 -13
  38. data/app/web/requests/root_request.rb +6 -7
  39. data/app/web/requests/root_request_test.rb +1 -1
  40. data/app/web_box.rb +9 -1
  41. data/exe/lrb +3 -0
  42. data/lib/app.rb +19 -15
  43. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
  44. data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
  45. data/lib/dev_system/dev/controllers/bench.rb +5 -7
  46. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
  47. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
  49. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
  51. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
  52. data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
  53. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  54. data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
  55. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
  56. data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
  57. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
  58. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
  59. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  60. data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
  61. data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
  62. data/lib/dev_system/dev/controllers/command.rb +11 -13
  63. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  64. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  65. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
  66. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  67. data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
  68. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
  69. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
  70. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
  71. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
  72. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
  73. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
  74. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
  75. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -0
  76. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -0
  77. data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
  78. data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
  79. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
  80. data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
  81. data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
  82. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
  83. data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
  84. data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
  85. data/lib/dev_system/dev/controllers/shell.rb +26 -14
  86. data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
  87. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
  88. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  89. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  90. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  91. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  92. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  93. data/lib/dev_system/dev/dev_box.rb +33 -16
  94. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  95. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  96. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  97. data/lib/dev_system/dev/panels/command_panel.rb +24 -6
  98. data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
  99. data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
  100. data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
  101. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  102. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  103. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  104. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  105. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  106. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  107. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  108. data/lib/happy_system/happy/happy_box.rb +6 -9
  109. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  110. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  111. data/lib/lerb.rb +106 -0
  112. data/lib/liza/base/box.rb +71 -26
  113. data/lib/liza/base/box_test.rb +7 -9
  114. data/lib/liza/base/controller.rb +19 -19
  115. data/lib/liza/base/controller_test.rb +7 -9
  116. data/lib/liza/base/panel.rb +40 -24
  117. data/lib/liza/base/panel_test.rb +10 -12
  118. data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
  119. data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
  120. data/lib/liza/meta/part.rb +12 -14
  121. data/lib/liza/meta/part_extension.rb +14 -11
  122. data/lib/liza/meta/part_test.rb +4 -6
  123. data/lib/liza/meta/system.rb +12 -14
  124. data/lib/liza/meta/system_test.rb +8 -10
  125. data/lib/liza/ruby_test.rb +7 -0
  126. data/lib/liza/ruby_tests/module_test.rb +21 -0
  127. data/lib/liza/ruby_tests/string_test.rb +59 -0
  128. data/lib/liza/test/test.rb +7 -8
  129. data/lib/liza/test/test_test.rb +168 -76
  130. data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
  131. data/lib/liza/test_parts/test_assertions_part.rb +81 -82
  132. data/lib/liza/test_parts/test_dsl_part.rb +44 -98
  133. data/lib/liza/test_parts/test_log_part.rb +122 -0
  134. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  135. data/lib/liza/test_parts/test_tree_part.rb +137 -0
  136. data/lib/liza/unit.rb +108 -102
  137. data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
  138. data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
  139. data/lib/liza/unit_test.rb +69 -71
  140. data/lib/liza.rb +5 -0
  141. data/lib/lizarb/ruby/module.rb +17 -0
  142. data/lib/lizarb/ruby/string.rb +10 -2
  143. data/lib/lizarb/version.rb +1 -1
  144. data/lib/lizarb.rb +24 -2
  145. data/lib/net_system/dev/net_command.rb +10 -12
  146. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  147. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  148. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  149. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  150. data/lib/net_system/net/controllers/client.rb +1 -3
  151. data/lib/net_system/net/controllers/client_test.rb +8 -10
  152. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  153. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  154. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  155. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  156. data/lib/net_system/net/controllers/database.rb +21 -23
  157. data/lib/net_system/net/controllers/database_test.rb +8 -10
  158. data/lib/net_system/net/controllers/record.rb +29 -0
  159. data/lib/net_system/net/controllers/record_test.rb +12 -0
  160. data/lib/net_system/net/net_box.rb +11 -16
  161. data/lib/net_system/net/net_box_test.rb +12 -14
  162. data/lib/net_system/net/panels/client_panel.rb +1 -3
  163. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  164. data/lib/net_system/net/panels/database_panel.rb +6 -8
  165. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  166. data/lib/web_system/dev/rack_command.rb +35 -0
  167. data/lib/web_system/dev/request_command.rb +143 -0
  168. data/lib/web_system/dev/web_command.rb +6 -39
  169. data/lib/web_system/web/controllers/rack.rb +6 -0
  170. data/lib/web_system/web/controllers/rack_test.rb +16 -0
  171. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
  172. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
  173. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
  174. data/lib/web_system/web/controllers/request.rb +1 -3
  175. data/lib/web_system/web/controllers/request_test.rb +11 -13
  176. data/lib/web_system/web/panels/rack_panel.rb +42 -0
  177. data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
  178. data/lib/web_system/web/panels/request_panel.rb +54 -37
  179. data/lib/web_system/web/panels/request_panel_test.rb +28 -9
  180. data/lib/web_system/web/web_box.rb +16 -8
  181. data/lib/web_system/web/web_box_test.rb +11 -13
  182. data/lizarb.gemspec +2 -2
  183. metadata +76 -28
  184. data/app/dev/commands/example_command.rb +0 -57
  185. data/app/dev/commands/example_command_test.rb +0 -43
  186. data/app/dev/commands/macro_child_command.rb +0 -32
  187. data/app/dev/commands/macro_child_command_test.rb +0 -7
  188. data/app/dev/commands/macro_parent_command.rb +0 -70
  189. data/app/dev/commands/macro_parent_command_test.rb +0 -7
  190. data/app/dev/commands/my_command.rb +0 -7
  191. data/app/dev/commands/my_command_test.rb +0 -7
  192. data/app/dev/generators/model_generator.rb +0 -46
  193. data/app/net/models/app_model_test.rb +0 -8
  194. data/app/net/models/post_model.rb +0 -4
  195. data/app/net/models/post_model_test.rb +0 -8
  196. data/app/net/models/user_model.rb +0 -4
  197. data/app/net/models/user_model_test.rb +0 -8
  198. data/app_new/.gitignore +0 -4
  199. data/app_new/Gemfile +0 -31
  200. data/app_new/Procfile +0 -3
  201. data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
  202. data/lib/liza/test_parts/test_context_part.rb +0 -81
  203. data/lib/net_system/net/controllers/model.rb +0 -31
  204. 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 bench_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 bench_test_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 command_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 command_test_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
@@ -1,7 +1,7 @@
1
- class ModelGeneratorTest < Liza::GeneratorTest
1
+ class RecordGeneratorTest < Liza::GeneratorTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == ModelGenerator
4
+ assert subject_class == RecordGenerator
5
5
  end
6
6
 
7
7
  test :settings do
data/app/dev_box.rb CHANGED
@@ -1,13 +1,33 @@
1
1
  class DevBox < Liza::DevBox
2
2
 
3
- commands do
4
- # Set up your command panel per the DSL in http://guides.lizarb.com/panels/command.html
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
- logs do
9
- # Set up your log panel per the DSL in http://guides.lizarb.com/panels/log.html
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
@@ -1,6 +1,6 @@
1
1
  class HappyBox < Liza::HappyBox
2
2
 
3
- axo do
3
+ panel :axo do
4
4
  # Set up your axo panel per the DSL in http://guides.lizarb.com/panels/axo.html
5
5
 
6
6
  end
@@ -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
@@ -1,4 +1,4 @@
1
- class AppModel < Liza::Model
1
+ class AppRecord < Liza::Record
2
2
  db :sqlite
3
3
 
4
4
  def self.create_tables!
@@ -18,3 +18,4 @@ SQLITE
18
18
  end
19
19
 
20
20
  end
21
+
@@ -0,0 +1,8 @@
1
+ class AppRecordTest < Liza::RecordTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == AppRecord
5
+ assert subject_class.db == SqliteDb
6
+ end
7
+
8
+ end
@@ -0,0 +1,4 @@
1
+ class PostRecord < AppRecord
2
+ set :table, :posts
3
+
4
+ end
@@ -0,0 +1,8 @@
1
+ class PostRecordTest < Liza::RecordTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == PostRecord
5
+ assert subject_class.db == SqliteDb
6
+ end
7
+
8
+ end
@@ -0,0 +1,4 @@
1
+ class UserRecord < AppRecord
2
+ set :table, :users
3
+
4
+ end
@@ -0,0 +1,8 @@
1
+ class UserRecordTest < Liza::RecordTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == UserRecord
5
+ assert subject_class.db == SqliteDb
6
+ end
7
+
8
+ end
data/app/net_box.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  class NetBox < Liza::NetBox
2
2
 
3
- clients do
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 :sqlite, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
8
- set :sqlite, "app.#{App.mode}.sqlite"
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
- databases do
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.current
16
- define :sql, SqliteDb.current
17
- define :sqlite, SqliteDb.current
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
- log status
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
- "route: render_route_api_auth_sign_up"
40
+ {route: "render_route_api_auth_sign_up"}
40
41
  end
41
42
 
42
43
  def self.render_route_api_auth_sign_in
43
- "route: render_route_api_auth_sign_in"
44
+ {route: "render_route_api_auth_sign_in"}
44
45
  end
45
46
 
46
47
  def self.render_route_api_auth_account
47
- "route: render_route_api_auth_account"
48
+ {route: "render_route_api_auth_account"}
48
49
  end
49
50
 
50
51
  def self.render_route_api_auth_sign_out
51
- "route: render_route_api_auth_sign_out"
52
+ {route: "render_route_api_auth_sign_out"}
52
53
  end
53
54
 
54
55
  def self.render_route_api_users
55
- "route: render_route_api_users"
56
+ {route: "render_route_api_users"}
56
57
  end
57
58
 
58
59
  def self.render_route_not_found path
59
- "route: render_route_not_found #{path}"
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
- @status = 200
14
- @headers = {
13
+ status = 200
14
+ headers = {
15
15
  "Framework" => "Liza #{Lizarb::VERSION}"
16
16
  }
17
- @body = ""
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
- log @status
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
- @body = "alert('it works')"
30
+ "alert('it works')"
32
31
  end
33
32
 
34
33
  def render_action_admin_format_css
35
- @body = "body { background: gray }"
34
+ "body { background: gray }"
36
35
  end
37
36
 
38
37
  def render_action_app_format_js
39
- @body = <<-CODE
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
- @body = <<-CODE
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 == "root"
18
- render_action_root
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.render_action_root
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
@@ -6,7 +6,7 @@ class RootRequestTest < AppRequestTest
6
6
 
7
7
  test :actions, :root do
8
8
  env = {
9
- "LIZA_ACTION" => "root",
9
+ "LIZA_ACTION" => "index",
10
10
  }
11
11
 
12
12
  status, headers, body = subject_class.call env
data/app/web_box.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  class WebBox < Liza::WebBox
2
2
 
3
- requests do
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
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load "#{__dir__}/lizarb"