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
@@ -1,74 +1,85 @@
1
- class DevSystem
2
- class TestCommand < Command
1
+ class DevSystem::TestCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- log :higher, "Called #{self} with args #{args}"
3
+ def self.call args
4
+ log "args = #{args.inspect}"
6
5
 
7
- App.eager_load_all
6
+ App.load_all
8
7
 
9
- now = Time.now
10
- test_classes = Liza::Test.descendants
11
-
12
- if Lizarb::IS_APP_DIR
13
- test_classes = test_classes.select { |tc| tc.source_location[0].include? Lizarb::APP_DIR }
14
- end
8
+ now = Time.now
9
+ test_classes = Liza::Test.descendants
10
+
11
+ _call_silence_base_units
12
+
13
+ if Lizarb::IS_APP_DIR
14
+ test_classes = test_classes.select { |tc| tc.source_location[0].include? Lizarb::APP_DIR }
15
+ end
15
16
 
16
- test_classes = _call_sort test_classes
17
+ test_classes = _call_sort test_classes
17
18
 
18
- log "Testing #{test_classes}"
19
- _call_testing test_classes
20
- log "Done Testing (#{now.diff}s)"
19
+ log "Testing #{test_classes}"
20
+ _call_testing test_classes
21
+ log "Done Testing (#{now.diff}s)"
21
22
 
22
- puts
23
+ puts
23
24
 
24
- log "Counting #{test_classes.count} Test Classes"
25
- _call_counting test_classes
26
- log "Done Counting (#{now.diff}s)"
25
+ log "Counting #{test_classes.count} Test Classes"
26
+ _call_counting test_classes
27
+ log "Done Counting (#{now.diff}s)"
28
+ end
29
+
30
+ def self._call_silence_base_units
31
+ [
32
+ Liza::Box,
33
+ Liza::Panel,
34
+ Liza::Controller,
35
+ ].each do |x|
36
+ def x.log(...) end
37
+ def x.puts(...) end
27
38
  end
39
+ end
28
40
 
29
- def self._call_sort test_classes
30
- test_classes.sort_by! &:name
41
+ def self._call_sort test_classes
42
+ test_classes.sort_by! &:name
31
43
 
32
- proc_namespaced = proc { |tc| tc.name.include? "::" }
33
- proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
44
+ proc_namespaced = proc { |tc| tc.name.include? "::" }
45
+ proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
34
46
 
35
- tc_app = test_classes.reject &proc_namespaced
36
- tc_namespaced = test_classes.select &proc_namespaced
47
+ tc_app = test_classes.reject(&proc_namespaced)
48
+ tc_namespaced = test_classes.select(&proc_namespaced)
37
49
 
38
- tc_liza = tc_namespaced.select &proc_liza
39
- tc_system = tc_namespaced.reject &proc_liza
50
+ tc_liza = tc_namespaced.select(&proc_liza)
51
+ tc_system = tc_namespaced.reject(&proc_liza)
40
52
 
41
- tc_app.sort_by! &:source_location
42
- tc_liza.sort_by! &:source_location
53
+ tc_app.sort_by! &:source_location
54
+ tc_liza.sort_by! &:source_location
43
55
 
44
- [tc_liza, tc_system, tc_app].flatten
45
- end
56
+ [tc_liza, tc_system, tc_app].flatten
57
+ end
46
58
 
47
- def self._call_testing test_classes
48
- i, count = 0, test_classes.count
49
- for test_class in test_classes
50
- test_class.call i+=1, count
51
- end
59
+ def self._call_testing test_classes
60
+ i, count = 0, test_classes.count
61
+ for test_class in test_classes
62
+ test_class.call i+=1, count
52
63
  end
64
+ end
53
65
 
54
- def self._call_counting test_classes
55
- puts
56
- totals = Hash.new { 0 }
57
- last_namespace = nil
58
- test_classes.each do |test_class|
59
- namespace = test_class.first_namespace
60
- puts if last_namespace != namespace
61
- last_namespace = namespace
62
-
63
- test_class.totals.each do |k, v|
64
- totals[k] += v.size
65
- end
66
- Liza.log " #{"#{test_class}.totals".ljust 60} #{test_class.totals.map { |k, v| [k, v.size] }.to_h}"
66
+ def self._call_counting test_classes
67
+ puts
68
+ totals = Hash.new { 0 }
69
+ last_namespace = nil
70
+ test_classes.each do |test_class|
71
+ namespace = test_class.first_namespace
72
+ puts if last_namespace != namespace
73
+ last_namespace = namespace
74
+
75
+ test_class.totals.each do |k, v|
76
+ totals[k] += v.size
67
77
  end
68
- puts
69
- Liza.log " #{"Total".ljust 60} #{totals}"
70
- puts
78
+ Liza.log " #{"#{test_class}.totals".ljust 60} #{test_class.totals.map { |k, v| [k, v.size] }.to_h}"
71
79
  end
72
-
80
+ puts
81
+ Liza.log " #{"Total".ljust 60} #{totals}"
82
+ puts
73
83
  end
84
+
74
85
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class TestCommandTest < CommandTest
1
+ class DevSystem::TestCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::TestCommand
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::TestCommand
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -1,19 +1,13 @@
1
- class DevSystem
2
- class Command < Liza::Controller
1
+ class DevSystem::Command < Liza::Controller
3
2
 
4
- # def self.call args
5
- # new.call args
6
- # end
7
-
8
- # def initialize args
9
- # @args = args
10
- # end
11
-
12
- # attr_reader :args
13
-
14
- # def call args
15
- #
16
- # end
3
+ def self.call args
4
+ log "args = #{args}"
5
+ new.call args
6
+ end
17
7
 
8
+ def call args
9
+ log "args = #{args}"
10
+ raise NotImplementedError
18
11
  end
12
+
19
13
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class CommandTest < Liza::ControllerTest
1
+ class DevSystem::CommandTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::Command
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::Command
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -1,11 +1,9 @@
1
- class DevSystem
2
- class Generator < Liza::Controller
1
+ class DevSystem::Generator < Liza::Controller
3
2
 
4
- # DSLS
5
-
6
- def self.main_dsl
7
- part :"generator_dsl_main", system: :dev
8
- end
3
+ # DSLS
9
4
 
5
+ def self.main_dsl
6
+ part :"generator_dsl_main", system: :dev
10
7
  end
8
+
11
9
  end
@@ -1,54 +1,50 @@
1
- class DevSystem
2
- class GeneratorDslMainPart < Liza::Part
1
+ class DevSystem::GeneratorDslMainPart < Liza::Part
3
2
 
4
- insertion do
3
+ insertion do
5
4
 
6
- def self.call args
7
- log :higher, "Called #{self}.#{__method__} with args #{args}"
5
+ def self.call args
6
+ log "args = #{args.inspect}"
8
7
 
9
- name = args.shift || raise("args[0] should contain NAME")
10
- name = name.downcase
8
+ name = args.shift || raise("args[0] should contain NAME")
9
+ name = name.downcase
11
10
 
12
- memo.each do |label, bl|
13
- log "Generating #{label}"
14
- g = new label, name, args
15
- g.instance_exec &bl
16
- g.call
17
- end
18
-
19
- puts
20
- log "done"
11
+ memo.each do |label, bl|
12
+ log "Generating #{label}"
13
+ g = new label, name, args
14
+ g.instance_exec(&bl)
15
+ g.call
21
16
  end
22
17
 
23
- def self.memo()= @memo ||= {}
18
+ puts
19
+ log "done"
20
+ end
24
21
 
25
- def self.generate(label, &block)= memo[label] = block
22
+ def self.memo()= @memo ||= {}
26
23
 
27
- attr_reader :label, :name, :args
24
+ def self.generate(label, &block)= memo[label] = block
28
25
 
29
- def initialize label, name, args
30
- @label, @name, @args = label, name, args
31
- end
26
+ attr_reader :label, :name, :args
32
27
 
33
- def call
34
- TextShell.write "#{folder}/#{filename}", "#{content}\n"
35
- end
28
+ def initialize label, name, args
29
+ @label, @name, @args = label, name, args
30
+ end
36
31
 
37
- %w|folder filename content|.each do |s|
38
- class_eval <<-CODE, __FILE__, __LINE__ + 1
39
- attr_reader :#{s}
32
+ def call
33
+ TextShell.write "#{folder}/#{filename}", "#{content}\n"
34
+ end
40
35
 
41
- def #{s} #{s} = nil
42
- if #{s}
43
- @#{s} = #{s}
44
- else
45
- @#{s}
46
- end
36
+ %w|folder filename content|.each do |s|
37
+ class_eval <<-CODE, __FILE__, __LINE__ + 1
38
+ def #{s} #{s} = nil
39
+ if #{s}
40
+ @#{s} = #{s}
41
+ else
42
+ @#{s}
47
43
  end
48
- CODE
49
- end
50
-
44
+ end
45
+ CODE
51
46
  end
52
47
 
53
48
  end
49
+
54
50
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class GeneratorTest < Liza::ControllerTest
1
+ class DevSystem::GeneratorTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::Generator
6
- end
7
-
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :green
11
- end
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::Generator
5
+ end
12
6
 
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
13
10
  end
11
+
14
12
  end
@@ -1,5 +1,4 @@
1
- class <%= name.camelize %>Bench < AppBench
2
- main_dsl
1
+ class <%= @name.camelize %>Bench < SortedBench
3
2
 
4
3
  setup do
5
4
  N = 1_000_000
@@ -1,7 +1,7 @@
1
- class <%= name.camelize %>BenchTest < AppBenchTest
1
+ class <%= @name.camelize %>BenchTest < SortedBenchTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == <%= name.camelize %>Bench
4
+ assert subject_class == <%= @name.camelize %>Bench
5
5
  end
6
6
 
7
7
  test :settings do
@@ -0,0 +1,12 @@
1
+ class DevSystem::BenchGenerator < DevSystem::ControllerGenerator
2
+
3
+ def self.call args
4
+ log "args = #{args.inspect}"
5
+
6
+ name = args.shift || raise("args[0] should contain NAME")
7
+ name = name.downcase
8
+
9
+ new.generate_app_controller :dev, :bench, :benches, name
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ class DevSystem::BenchGeneratorTest < DevSystem::ControllerGeneratorTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::BenchGenerator
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
@@ -0,0 +1,41 @@
1
+ class <%= @name.camelize %>Command < Liza::Command
2
+
3
+ def self.call args
4
+ log "args = #{args.inspect}"
5
+ new.call args
6
+ end
7
+
8
+ def call args
9
+ log "@args = #{args.inspect}"
10
+ @args = args
11
+
12
+ # log "puts render inline.txt"
13
+ # puts render "inline.txt"
14
+
15
+ # log "puts render text.txt"
16
+ # puts render "text.txt"
17
+
18
+ log "Time.now #{Time.now}"
19
+ end
20
+
21
+ end
22
+
23
+ __END__
24
+
25
+ The default view can be rendered by calling `render "inline.txt`"
26
+
27
+ Self is the instance of the class that called `render`:
28
+ self: <%%= self %>
29
+
30
+ # view text.txt.erb
31
+
32
+ This named view can be rendered by calling `render "text.txt`"
33
+
34
+ Instance variables are accessible from the view:
35
+ @args: <%%= @args %>
36
+
37
+ Written at <%%= Time.now %>
38
+
39
+ # view lalala.txt.erb.ignored
40
+
41
+ This named view will be ignored.
@@ -1,7 +1,7 @@
1
- class <%= name.camelize %>CommandTest < AppCommandTest
1
+ class <%= @name.camelize %>CommandTest < Liza::CommandTest
2
2
 
3
3
  test :subject_class do
4
- assert subject_class == <%= name.camelize %>Command
4
+ assert subject_class == <%= @name.camelize %>Command
5
5
  end
6
6
 
7
7
  test :settings do
@@ -0,0 +1,19 @@
1
+ class DevSystem::CommandGenerator < DevSystem::ControllerGenerator
2
+
3
+ def self.call args
4
+ log "args = #{args.inspect}"
5
+
6
+ name = args.shift || raise("args[0] should contain NAME")
7
+ name = name.downcase
8
+
9
+ new.generate_app_controller :dev, :command, :commands, name
10
+ end
11
+
12
+ end
13
+
14
+ __END__
15
+
16
+ # view install_insert_panel.rb.erb
17
+
18
+ short :b, :bench
19
+ short :g, :generate
@@ -0,0 +1,12 @@
1
+ class DevSystem::CommandGeneratorTest < DevSystem::ControllerGeneratorTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::CommandGenerator
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
@@ -0,0 +1,97 @@
1
+ class DevSystem::ControllerGenerator < DevSystem::Generator
2
+
3
+ def self.call args
4
+ log "args = #{args.inspect}"
5
+ new.generate_app_controller(*args)
6
+ end
7
+
8
+ def generate_app_controller system_name, controller_name, folder, name
9
+ log "(#{system_name.inspect}, #{controller_name.inspect}, #{folder.inspect}, #{name.inspect})"
10
+
11
+ @name = name
12
+ @panels = []
13
+
14
+ filename = "app/#{system_name}/#{folder}/#{name}_#{controller_name}.rb"
15
+ content = render "controller.rb"
16
+ TextShell.write filename, content
17
+
18
+ filename = "app/#{system_name}/#{folder}/#{name}_#{controller_name}_test.rb"
19
+ content = render "controller_test.rb"
20
+ TextShell.write filename, content
21
+ end
22
+
23
+ #
24
+
25
+ def self.install args
26
+ log "args = #{args.inspect}"
27
+
28
+ system_name = get(:system).name.snakecase.gsub "_system", ""
29
+ controller_name = last_namespace.snakecase.gsub "_generator", ""
30
+
31
+ new.instance_exec do
32
+ log "#install_app_panel"
33
+
34
+ @filename = "app/#{system_name}_box.rb"
35
+ @system_name = system_name
36
+ @controller_name = controller_name
37
+ @panels = {}
38
+
39
+ install_write_box unless FileShell.exist? @filename
40
+ install_read_box
41
+ install_insert_panel
42
+ install_write_box
43
+ end
44
+ end
45
+
46
+ # helper methods
47
+
48
+ def install_write_box
49
+ @content = render "app_box.rb"
50
+ TextShell.write @filename, "#{@content.strip}\n"
51
+ end
52
+
53
+ def install_read_box
54
+ @content ||= TextShell.read @filename
55
+
56
+ cursor = nil
57
+ @content.split("\n").each do |line|
58
+ md = line.match(/^ configure :(.*) do$/)
59
+ if md
60
+ cursor = md[1]
61
+ @panels[cursor] = {lines: []}
62
+ elsif line =~ /^ end$/
63
+ cursor = nil
64
+ else
65
+ next unless cursor
66
+ @panels[cursor][:lines] << line
67
+ end
68
+ end
69
+ end
70
+
71
+ def install_insert_panel
72
+ lines = render("install_insert_panel.rb").split("\n").reject(&:empty?)
73
+ @panels[@controller_name] = {lines: lines}
74
+ @panels = @panels.sort_by(&:first)
75
+ end
76
+
77
+ end
78
+
79
+ __END__
80
+
81
+ # view app_box.rb.erb
82
+
83
+ class <%= @system_name.camelcase %>Box < Liza::<%= @system_name.camelcase %>Box
84
+
85
+ <% @panels.each do |key, panel| -%>
86
+ configure :<%= key %> do
87
+ <% panel[:lines].each do |line| -%>
88
+ <%= line %>
89
+ <% end -%>
90
+ end
91
+
92
+ <% end -%>
93
+ end
94
+
95
+ # view install_insert_panel.rb.erb
96
+
97
+ #
@@ -0,0 +1,12 @@
1
+ class DevSystem::ControllerGeneratorTest < DevSystem::GeneratorTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::ControllerGenerator
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
@@ -4,6 +4,6 @@ end
4
4
 
5
5
  __END__
6
6
 
7
- # text.txt.erb
7
+ # view text.txt.erb
8
8
  Called <%%%= self %>.<%%%= __method__ %>
9
9
  @args: <%%%= @args %>