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
data/app_new.rb ADDED
@@ -0,0 +1,15 @@
1
+ # This is a LizaRB Application
2
+ # Learn more: http://lizarb.org/
3
+
4
+ class App
5
+
6
+ # Modes help you organize your application's behavior and settings.
7
+
8
+ mode :code
9
+ mode :demo
10
+
11
+ # Systems help you organize your application's dependencies and RAM memory usage.
12
+
13
+ system :dev
14
+
15
+ end
data/exe/lizarb CHANGED
@@ -1,11 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $APP = ENV["APP"]
4
+
3
5
  $VERBOSE = ENV["VERBOSE"]
4
6
 
5
7
  $LOAD_PATH.unshift "#{Dir.pwd}/lib"
6
8
 
7
9
  require_relative "../lib/lizarb.rb"
8
10
 
11
+ Lizarb.setup
12
+
13
+ Lizarb.app
14
+
9
15
  Lizarb.call
10
16
 
11
- exit 0
17
+ App.call ARGV
18
+
19
+ Lizarb.exit verbose: true
data/lib/app.rb CHANGED
@@ -1,102 +1,38 @@
1
- module App
1
+ class App
2
2
  class Error < StandardError; end
3
- class ModeNotFound < Error; end
4
3
  class SystemNotFound < Error; end
5
4
 
6
5
  #
7
6
 
8
- module_function
9
-
10
- def log s
7
+ def self.log s
11
8
  puts s.bold
12
9
  end
13
10
 
14
- def logv s
11
+ def self.logv s
15
12
  log s if $VERBOSE
16
13
  end
17
14
 
18
- # called from "#{APP_DIR}/app"
19
- def call argv, &block
20
- instance_exec &block
21
-
22
- setup_env
23
- setup_bundle
24
- setup_liza
25
- bundle_systems_app Lizarb::APP_DIR
26
-
27
- check_mode!
28
-
15
+ # called from exe/lizarb
16
+ def self.call argv
29
17
  puts
30
- ::DevBox.commands.call argv
18
+ Liza[:DevBox][:command].call argv
31
19
  puts
32
20
  end
33
21
 
34
- def root
22
+ def self.root
35
23
  Pathname Dir.pwd
36
24
  end
37
25
 
38
- def setup_env
39
- require "dotenv"
40
- Dotenv.load "app.#{mode}.env", "app.env"
41
- end
42
-
43
- def setup_bundle
44
- require "bundler/setup"
45
- Bundler.require :default, *@systems.keys
46
- end
47
-
48
- def setup_liza
49
- require "liza"
50
-
51
- @loaders << loader = Zeitwerk::Loader.new
52
- loader.tag = Liza.to_s
53
-
54
- # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
55
- loader.collapse "#{Liza.source_location_radical}/**/*"
56
- loader.push_dir "#{Liza.source_location_radical}", namespace: Liza
57
-
58
- loader.enable_reloading
59
- loader.setup
60
- end
61
-
62
- def bundle_systems_app app_dir
63
- @systems.keys.each do |k|
64
- key = "#{k}_system"
65
-
66
- require_system key
67
- klass = Object.const_get key.camelize
68
-
69
- @systems[k] = klass
70
- end
71
-
72
- @loaders << loader = Zeitwerk::Loader.new
73
-
74
- @systems.each do |k, klass|
75
- # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
76
- loader.collapse "#{klass.source_location_radical}/**/*"
77
- loader.push_dir "#{klass.source_location_radical}", namespace: klass
78
- end
79
-
80
- # ORDER MATTERS: IGNORE, COLLAPSE, PUSH
81
- loader.collapse "#{app_dir}/app/**/*"
82
- loader.push_dir "#{app_dir}/app" if Dir.exist? "#{app_dir}/app"
83
-
84
- loader.enable_reloading
85
- loader.setup
86
-
87
- @systems.each do |k, klass|
88
- connect_system k, klass
89
- end
90
-
91
- @systems.freeze
92
- end
93
-
94
26
  # loaders
95
27
 
96
28
  @loaders = []
97
29
  @mutex = Mutex.new
98
30
 
99
- def reload &block
31
+ def self.loaders
32
+ @loaders
33
+ end
34
+
35
+ def self.reload &block
100
36
  @mutex.synchronize do
101
37
  @loaders.map &:reload
102
38
  yield if block_given?
@@ -105,36 +41,33 @@ module App
105
41
  true
106
42
  end
107
43
 
108
- def eager_load_all
109
- Zeitwerk::Loader.eager_load_all
44
+ def self.load_all
45
+ Lizarb.load_all
110
46
  end
111
47
 
112
- # mode
48
+ # modes
113
49
 
114
- @modes = [:code]
115
- ENV["LIZA_MODE"] ||= @modes.first.to_s
116
- @mode = ENV["LIZA_MODE"].to_sym
50
+ @modes = []
117
51
 
118
- def mode mode = nil
119
- return @mode if mode.nil?
52
+ def self.mode mode = nil
53
+ return $MODE if mode.nil?
120
54
  @modes << mode.to_sym
121
55
  end
122
56
 
123
- def check_mode!
124
- return if @modes.include? @mode
125
- raise ModeNotFound, "LIZA_MODE `#{@mode}` not found in #{@modes}", []
57
+ def self.modes
58
+ @modes
126
59
  end
127
60
 
128
61
  # systems
129
62
 
130
63
  @systems = {}
131
64
 
132
- def system key
65
+ def self.system key
133
66
  raise "locked" if @locked
134
67
  @systems[key] = nil
135
68
  end
136
69
 
137
- def systems
70
+ def self.systems
138
71
  @systems
139
72
  end
140
73
 
@@ -150,7 +83,7 @@ module App
150
83
 
151
84
  # parts
152
85
 
153
- def connect_part part_klass, key, system
86
+ def self.connect_part part_klass, key, system
154
87
  t = Time.now
155
88
  string = "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}"
156
89
  logv string
@@ -163,23 +96,22 @@ module App
163
96
  end
164
97
 
165
98
  if klass.insertion
166
- part_klass.class_exec &klass.insertion
99
+ part_klass.class_exec(&klass.insertion)
167
100
  end
168
101
 
169
102
  if klass.extension
170
103
  klass.const_set :Extension, Class.new(Liza::PartExtension)
171
- klass::Extension.class_exec &klass.extension
104
+ klass::Extension.class_exec(&klass.extension)
172
105
  end
173
106
  logv "#{string} takes #{t.diff}s"
174
107
  end
175
108
 
176
109
  # systems
177
110
 
178
- def connect_system key, system_klass
111
+ def self.connect_system key, system_klass
179
112
  t = Time.now
180
113
 
181
114
  color_system_klass = system_klass.to_s.colorize system_klass.log_color
182
- color_key = key.to_s.colorize system_klass.log_color
183
115
 
184
116
  registrar_index = 0
185
117
  system_klass.registrar.each do |string, target_block|
@@ -190,7 +122,7 @@ module App
190
122
  target_klass = Liza.const reg_target
191
123
 
192
124
  if reg_type == "insertion"
193
- target_klass.class_exec &target_block
125
+ target_klass.class_exec(&target_block)
194
126
  else
195
127
  raise "TODO: decide and implement system extension"
196
128
  end
@@ -1,29 +1,34 @@
1
- class DevSystem
2
- class NotFoundBench < Bench
1
+ class DevSystem::NotFoundBench < DevSystem::Bench
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def self.call args
4
+ # 1. LOG
6
5
 
7
- log :higher, "Called #{self}.#{__method__} with args #{args}"
8
- puts
6
+ log "args = #{args.inspect}"
7
+ puts
9
8
 
10
- # 2. FIND generators
9
+ # 2. FIND generators
11
10
 
12
- App.eager_load_all
13
- benches = Liza::Bench.descendants
11
+ App.load_all
12
+ benches = Liza::Bench.descendants
13
+ benches -= ignored_benches
14
14
 
15
- log "Liza comes with #{benches.count} benches you can use."
16
- puts
15
+ # 3. LIST benches
17
16
 
18
- log "Here they are:"
19
- puts
17
+ keys = benches.map { _1.last_namespace.snakecase[0..-7] }.uniq.sort
20
18
 
21
- # 3. LIST benches
19
+ log "Liza comes with #{keys.count} benches you can use."
20
+ log "Here they are:"
21
+ puts
22
22
 
23
- keys = benches.map { |k| k.last_namespace.snakecase[0..-7] }.sort
24
- keys.reject! { |s| s == "not_found" }
25
- keys.each { |s| log "liza bench #{s}" }
26
- end
23
+ keys.each { |s| log "liza bench #{s}" }
24
+ end
27
25
 
26
+ def self.ignored_benches
27
+ [
28
+ self,
29
+ DevSystem::NotFoundBench,
30
+ (DevSystem::SortedBench if defined? SortedBench),
31
+ ].uniq.compact
28
32
  end
33
+
29
34
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class NotFoundBenchTest < BenchTest
1
+ class DevSystem::NotFoundBenchTest < DevSystem::BenchTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::NotFoundBench
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::NotFoundBench
5
+ end
6
+
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :green
10
+ end
12
11
 
13
- end
14
12
  end
@@ -1,11 +1,3 @@
1
- class DevSystem
2
- class Bench < Liza::Controller
1
+ class DevSystem::Bench < Liza::Controller
3
2
 
4
- # DSLS
5
-
6
- def self.main_dsl
7
- part :"bench_dsl_main", system: :dev
8
- end
9
-
10
- end
11
3
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class BenchTest < Liza::ControllerTest
1
+ class DevSystem::BenchTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::Bench
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::Bench
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,34 +1,31 @@
1
- class DevSystem
2
- class BenchCommand < Command
1
+ class DevSystem::BenchCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def self.call args
4
+ # 1. LOG
6
5
 
7
- log :higher, "args: #{args}"
8
- puts
6
+ log "args = #{args.inspect}"
9
7
 
10
- # 2. FIND bench
8
+ # 2. FIND bench
11
9
 
12
- return call_not_found args if args.none?
10
+ return call_not_found args if args.none?
13
11
 
14
- bench = args[0]
12
+ bench = args[0]
15
13
 
16
- log({bench:})
14
+ log({bench:})
17
15
 
18
- begin
19
- bench_klass = Liza.const "#{bench}_bench"
20
- rescue Liza::ConstNotFound
21
- bench_klass = NotFoundBench
22
- end
23
-
24
- # 3. CALL
25
-
26
- bench_klass.call args[1..-1]
16
+ begin
17
+ bench_klass = Liza.const "#{bench}_bench"
18
+ rescue Liza::ConstNotFound
19
+ bench_klass = NotFoundBench
27
20
  end
28
21
 
29
- def self.call_not_found args
30
- Liza::NotFoundBench.call args
31
- end
22
+ # 3. CALL
32
23
 
24
+ bench_klass.call args[1..-1]
33
25
  end
26
+
27
+ def self.call_not_found args
28
+ Liza::NotFoundBench.call args
29
+ end
30
+
34
31
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class BenchCommandTest < CommandTest
1
+ class DevSystem::BenchCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::BenchCommand
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::BenchCommand
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,35 +1,9 @@
1
- class DevSystem
2
- class GenerateCommand < Command
1
+ class DevSystem::GenerateCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def call args
4
+ log "args = #{args}" if DevBox[:generator].get :log_details
6
5
 
7
- log :higher, "args: #{args}"
8
- puts
9
-
10
- # 2. FIND generator
11
-
12
- return call_not_found args if args.none?
13
-
14
- generator = args[0]
15
-
16
- log({generator:})
17
-
18
- #
19
-
20
- begin
21
- generator_class = Liza.const "#{generator}_generator"
22
- rescue Liza::ConstNotFound
23
- generator_class = NotFoundGenerator
24
- end
25
-
26
- # 3. CALL
27
-
28
- generator_class.call args[1..-1]
29
- end
30
-
31
- def self.call_not_found args
32
- Liza::NotFoundGenerator.call args
33
- end
6
+ DevBox[:generator].call args
34
7
  end
8
+
35
9
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class GenerateCommandTest < CommandTest
1
+ class DevSystem::GenerateCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::GenerateCommand
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::GenerateCommand
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
@@ -0,0 +1,9 @@
1
+ class DevSystem::NewCommand < DevSystem::Command
2
+
3
+ def call args
4
+ log "args = #{args.inspect}"
5
+
6
+ Liza[:GenerateCommand].call ["new", *args]
7
+ end
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ class DevSystem::NewCommandTest < DevSystem::CommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == DevSystem::NewCommand
5
+ end
6
+
7
+ end
@@ -1,29 +1,48 @@
1
- class DevSystem
2
- class NotFoundCommand < Command
1
+ class DevSystem::NotFoundCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def self.call args
4
+ # 1. LOG
6
5
 
7
- log :higher, "Called #{self}.#{__method__} with args #{args}"
8
- puts
6
+ log "args = #{args.inspect}"
7
+ puts
9
8
 
10
- # 2. FIND commands
9
+ # 2. FIND commands
11
10
 
12
- App.eager_load_all
13
- commands = Liza::Command.descendants
11
+ App.load_all
12
+ commands = Liza::Command.descendants
13
+ commands -= ignored_commands
14
14
 
15
- log "Liza comes with #{commands.count} commands you can use."
16
- puts
15
+ # 3. LIST commands
17
16
 
18
- log "Here they are:"
19
- puts
17
+ keys = commands.map { _1.last_namespace.snakecase[0..-9] }.uniq.sort
20
18
 
21
- # 3. LIST commands
19
+ log "Liza comes with #{keys.count} commands you can use."
20
+ log "Here they are:"
21
+ puts
22
22
 
23
- keys = commands.map { |k| k.last_namespace.snakecase[0..-9] }.sort
24
- keys.reject! { |s| s == "not_found" }
25
- keys.each { |s| log "liza #{s}" }
26
- end
23
+ keys.each { |s| log "liza #{s}" }
24
+ end
25
+
26
+ def self.ignored_commands
27
+ [
28
+ self,
29
+ DevSystem::NotFoundCommand,
30
+ DevSystem::NewCommand,
31
+ DevSystem::TerminalCommand,
32
+ (DevSystem::NarrativeMethodCommand if defined? NarrativeMethodCommand),
33
+ ].uniq.compact
34
+ end
27
35
 
36
+ if $APP == "app_global"
37
+ def self.ignored_commands
38
+ [
39
+ self,
40
+ DevSystem::NotFoundCommand,
41
+ DevSystem::BenchCommand,
42
+ DevSystem::GenerateCommand,
43
+ DevSystem::TestCommand,
44
+ ].uniq.compact
45
+ end
28
46
  end
47
+
29
48
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class NotFoundCommandTest < CommandTest
1
+ class DevSystem::NotFoundCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::NotFoundCommand
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::NotFoundCommand
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,24 +1,22 @@
1
- class DevSystem
2
- class TerminalCommand < Command
1
+ class DevSystem::TerminalCommand < DevSystem::Command
3
2
 
4
- def self.call args
5
- # 1. LOG
3
+ def call args
4
+ # 1. LOG
6
5
 
7
- log :higher, "args: #{args}"
8
- puts
6
+ log "args = #{args.inspect}"
7
+ puts
9
8
 
10
- # 2. FIND terminal
9
+ # 2. FIND terminal
11
10
 
12
- terminal = args[0] || "irb"
11
+ terminal = args[0] || "irb"
13
12
 
14
- log({terminal:})
13
+ log({terminal:})
15
14
 
16
- terminal_klass = Liza.const "#{terminal}_terminal"
15
+ terminal_klass = Liza.const "#{terminal}_terminal"
17
16
 
18
- # 3. CALL
19
-
20
- terminal_klass.call Array(args[1..-1])
21
- end
17
+ # 3. CALL
22
18
 
19
+ terminal_klass.call Array(args[1..-1])
23
20
  end
21
+
24
22
  end
@@ -1,14 +1,12 @@
1
- class DevSystem
2
- class TerminalCommandTest < CommandTest
1
+ class DevSystem::TerminalCommandTest < DevSystem::CommandTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == DevSystem::TerminalCommand
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::TerminalCommand
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