lizarb 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) 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/net/{models/app_model.rb → records/app_record.rb} +2 -1
  27. data/app/net/{models/post_model_test.rb → records/app_record_test.rb} +2 -2
  28. data/app/net/records/post_record.rb +4 -0
  29. data/app/net/{models/app_model_test.rb → records/post_record_test.rb} +2 -2
  30. data/app/net/records/user_record.rb +4 -0
  31. data/app/net/{models/user_model_test.rb → records/user_record_test.rb} +2 -2
  32. data/app/web/requests/api_request.rb +8 -7
  33. data/app/web/requests/assets_request.rb +12 -13
  34. data/app/web/requests/root_request.rb +6 -7
  35. data/app/web/requests/root_request_test.rb +1 -1
  36. data/app/web_box.rb +8 -0
  37. data/app_new/Procfile +1 -1
  38. data/exe/lrb +3 -0
  39. data/lib/app.rb +18 -14
  40. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +29 -0
  41. data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +14 -0
  42. data/lib/dev_system/dev/controllers/command/bench_command.rb +11 -1
  43. data/lib/dev_system/dev/controllers/command/generate_command.rb +14 -2
  44. data/lib/dev_system/dev/controllers/command/not_found_command.rb +29 -0
  45. data/lib/dev_system/dev/controllers/command/{dev_command_test.rb → not_found_command_test.rb} +2 -2
  46. data/lib/dev_system/dev/controllers/command/{dev_command.rb → terminal_command.rb} +1 -1
  47. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +14 -0
  48. data/lib/dev_system/dev/controllers/command/test_command.rb +6 -2
  49. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +1 -1
  50. data/lib/dev_system/dev/controllers/generators/app_generator.rb +30 -5
  51. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
  52. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
  53. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
  54. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
  55. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
  56. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
  57. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +29 -0
  58. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +14 -0
  59. data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
  60. data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
  61. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
  62. data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
  63. data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
  64. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
  65. data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
  66. data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
  67. data/lib/dev_system/dev/controllers/shell.rb +26 -14
  68. data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
  69. data/lib/dev_system/dev/panels/command_panel.rb +21 -1
  70. data/lib/dev_system/dev/panels/log_panel.rb +1 -1
  71. data/lib/lerb.rb +106 -0
  72. data/lib/liza/base/controller.rb +2 -0
  73. data/lib/liza/base/panel.rb +6 -5
  74. data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
  75. data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
  76. data/lib/liza/meta/part_extension.rb +6 -1
  77. data/lib/liza/ruby_test.rb +9 -0
  78. data/lib/liza/ruby_tests/module_test.rb +21 -0
  79. data/lib/liza/ruby_tests/string_test.rb +59 -0
  80. data/lib/liza/test/test.rb +3 -1
  81. data/lib/liza/test/test_test.rb +108 -15
  82. data/lib/liza/test_parts/test_assertions_advanced_part.rb +127 -0
  83. data/lib/liza/test_parts/test_assertions_part.rb +7 -6
  84. data/lib/liza/test_parts/test_dsl_part.rb +37 -89
  85. data/lib/liza/test_parts/test_log_part.rb +124 -0
  86. data/lib/liza/test_parts/test_tree_part.rb +139 -0
  87. data/lib/liza/unit.rb +2 -0
  88. data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
  89. data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
  90. data/lib/liza.rb +5 -0
  91. data/lib/lizarb/ruby/module.rb +17 -0
  92. data/lib/lizarb/ruby/string.rb +10 -2
  93. data/lib/lizarb/version.rb +1 -1
  94. data/lib/lizarb.rb +24 -2
  95. data/lib/net_system/net/controllers/record.rb +31 -0
  96. data/lib/net_system/net/controllers/{model_test.rb → record_test.rb} +2 -2
  97. data/lib/web_system/dev/rack_command.rb +26 -0
  98. data/lib/web_system/dev/request_command.rb +143 -0
  99. data/lib/web_system/dev/web_command.rb +3 -34
  100. data/lib/web_system/web/controllers/rack.rb +8 -0
  101. data/lib/web_system/web/controllers/rack_test.rb +18 -0
  102. data/lib/web_system/web/controllers/request/client_error_request.rb +0 -1
  103. data/lib/web_system/web/controllers/request/not_found_request.rb +0 -1
  104. data/lib/web_system/web/controllers/request/server_error_request.rb +0 -1
  105. data/lib/web_system/web/panels/rack_panel.rb +44 -0
  106. data/lib/web_system/web/panels/rack_panel_test.rb +14 -0
  107. data/lib/web_system/web/panels/request_panel.rb +51 -32
  108. data/lib/web_system/web/panels/request_panel_test.rb +28 -9
  109. data/lib/web_system/web/web_box.rb +12 -0
  110. data/lizarb.gemspec +2 -2
  111. metadata +68 -25
  112. data/app/dev/commands/example_command.rb +0 -57
  113. data/app/dev/commands/example_command_test.rb +0 -43
  114. data/app/dev/commands/macro_child_command.rb +0 -32
  115. data/app/dev/commands/macro_child_command_test.rb +0 -7
  116. data/app/dev/commands/macro_parent_command.rb +0 -70
  117. data/app/dev/commands/macro_parent_command_test.rb +0 -7
  118. data/app/dev/commands/my_command.rb +0 -7
  119. data/app/dev/commands/my_command_test.rb +0 -7
  120. data/app/dev/generators/model_generator.rb +0 -46
  121. data/app/net/models/post_model.rb +0 -4
  122. data/app/net/models/user_model.rb +0 -4
  123. data/lib/liza/test_parts/test_context_part.rb +0 -81
  124. data/lib/net_system/net/controllers/model.rb +0 -31
@@ -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
@@ -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
+
@@ -1,7 +1,7 @@
1
- class PostModelTest < Liza::ModelTest
1
+ class AppRecordTest < Liza::RecordTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == PostModel
4
+ assert subject_class == AppRecord
5
5
  assert subject_class.db == SqliteDb.current
6
6
  end
7
7
 
@@ -0,0 +1,4 @@
1
+ class PostRecord < AppRecord
2
+ set :table, :posts
3
+
4
+ end
@@ -1,7 +1,7 @@
1
- class AppModelTest < Liza::ModelTest
1
+ class PostRecordTest < Liza::RecordTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == AppModel
4
+ assert subject_class == PostRecord
5
5
  assert subject_class.db == SqliteDb.current
6
6
  end
7
7
 
@@ -0,0 +1,4 @@
1
+ class UserRecord < AppRecord
2
+ set :table, :users
3
+
4
+ end
@@ -1,7 +1,7 @@
1
- class UserModelTest < Liza::ModelTest
1
+ class UserRecordTest < Liza::RecordTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == UserModel
4
+ assert subject_class == UserRecord
5
5
  assert subject_class.db == SqliteDb.current
6
6
  end
7
7
 
@@ -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,5 +1,13 @@
1
1
  class WebBox < Liza::WebBox
2
2
 
3
+ 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
+
3
11
  requests do
4
12
  # Set up your request panel per the DSL in http://guides.lizarb.org/panels/request.html
5
13
 
data/app_new/Procfile CHANGED
@@ -1,3 +1,3 @@
1
1
  # FOR HEROKU
2
2
 
3
- web: LIZA_MODE=demo bundle exec liza web h=0.0.0.0 p=$PORT
3
+ web: LIZA_MODE=demo bundle exec liza rack h=0.0.0.0 p=$PORT
data/exe/lrb ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load "#{__dir__}/lizarb"
data/lib/app.rb CHANGED
@@ -11,6 +11,10 @@ module App
11
11
  puts s.bold
12
12
  end
13
13
 
14
+ def logv s
15
+ log s if $VERBOSE
16
+ end
17
+
14
18
  # called from "#{APP_DIR}/app"
15
19
  def call argv, &block
16
20
  instance_exec &block
@@ -48,8 +52,8 @@ module App
48
52
  loader.tag = Liza.to_s
49
53
 
50
54
  # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
51
- loader.collapse "#{fname_for Liza}/**/*"
52
- loader.push_dir "#{fname_for Liza}", namespace: Liza
55
+ loader.collapse "#{Liza.source_location_radical}/**/*"
56
+ loader.push_dir "#{Liza.source_location_radical}", namespace: Liza
53
57
 
54
58
  loader.enable_reloading
55
59
  loader.setup
@@ -69,8 +73,8 @@ module App
69
73
 
70
74
  @systems.each do |k, klass|
71
75
  # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
72
- loader.collapse "#{fname_for klass}/**/*"
73
- loader.push_dir "#{fname_for klass}", namespace: klass
76
+ loader.collapse "#{klass.source_location_radical}/**/*"
77
+ loader.push_dir "#{klass.source_location_radical}", namespace: klass
74
78
  end
75
79
 
76
80
  # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
@@ -83,6 +87,8 @@ module App
83
87
  @systems.each do |k, klass|
84
88
  connect_system k, klass
85
89
  end
90
+
91
+ @systems.freeze
86
92
  end
87
93
 
88
94
  # loaders
@@ -133,7 +139,10 @@ module App
133
139
  end
134
140
 
135
141
  def self.require_system key
142
+ t = Time.now
143
+ logv "App.system :#{key}"
136
144
  require key
145
+ logv "App.system :#{key} takes #{t.diff}s"
137
146
  rescue LoadError => e
138
147
  def e.backtrace; []; end
139
148
  raise SystemNotFound, "FILE #{key}.rb not found on $LOAD_PATH", []
@@ -142,6 +151,10 @@ module App
142
151
  # parts
143
152
 
144
153
  def connect_part part_klass, key, system
154
+ t = Time.now
155
+ string = "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}"
156
+ logv string
157
+
145
158
  klass = if system.nil?
146
159
  Liza.const "#{key}_part"
147
160
  else
@@ -149,8 +162,6 @@ module App
149
162
  .const "#{key}_part"
150
163
  end
151
164
 
152
- log "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}" if $VERBOSE
153
-
154
165
  if klass.insertion
155
166
  part_klass.class_exec &klass.insertion
156
167
  end
@@ -159,6 +170,7 @@ module App
159
170
  klass.const_set :Extension, Class.new(Liza::PartExtension)
160
171
  klass::Extension.class_exec &klass.extension
161
172
  end
173
+ logv "#{string} takes #{t.diff}s"
162
174
  end
163
175
 
164
176
  # systems
@@ -189,12 +201,4 @@ module App
189
201
  log "CONNECTING SYSTEM - #{t.diff}s for #{color_system_klass} to connect to #{registrar_index} system parts"
190
202
  end
191
203
 
192
- #
193
-
194
- def fname_for klass
195
- # /path/to/liza.rb
196
- # /path/to/liza
197
- Object.const_source_location(klass.name)[0][0..-4]
198
- end
199
-
200
204
  end