lizarb 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -13
  3. data/Rakefile +38 -0
  4. data/app/dev_box.rb +14 -12
  5. data/app/happy_box.rb +2 -2
  6. data/app/net_box.rb +4 -4
  7. data/app/web_box.rb +4 -4
  8. data/app.rb +6 -7
  9. data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
  10. data/app_global.gemfile.rb.lock +19 -0
  11. data/app_global.rb +4 -0
  12. data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
  13. data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
  14. data/app_new/dev/benches/objects_bench.rb +83 -0
  15. data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
  16. data/app_new/dev/benches/sorted_bench.rb +54 -0
  17. data/app_new/dev/benches/sorted_bench_test.rb +12 -0
  18. data/app_new/dev/benches/variables_bench.rb +55 -0
  19. data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
  20. data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
  21. data/{app → app_new}/dev/commands/circle_command.rb +1 -1
  22. data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
  23. data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
  24. data/app_new/dev_box.rb +14 -0
  25. data/app_new.rb +15 -0
  26. data/exe/lizarb +9 -1
  27. data/lib/app.rb +27 -95
  28. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +15 -8
  29. data/lib/dev_system/dev/controllers/bench.rb +0 -6
  30. data/lib/dev_system/dev/controllers/command/bench_command.rb +1 -2
  31. data/lib/dev_system/dev/controllers/command/generate_command.rb +3 -27
  32. data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
  33. data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
  34. data/lib/dev_system/dev/controllers/command/not_found_command.rb +29 -8
  35. data/lib/dev_system/dev/controllers/command/terminal_command.rb +2 -2
  36. data/lib/dev_system/dev/controllers/command/test_command.rb +6 -6
  37. data/lib/dev_system/dev/controllers/command.rb +9 -13
  38. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +2 -4
  39. data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
  40. data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
  41. data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
  42. data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
  43. data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
  44. data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
  45. data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
  46. data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
  47. data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
  48. data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
  49. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
  50. data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
  51. data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
  52. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +20 -8
  53. data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
  54. data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
  55. data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
  56. data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
  57. data/lib/dev_system/dev/controllers/log.rb +3 -0
  58. data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
  59. data/lib/dev_system/dev/controllers/shell.rb +22 -0
  60. data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
  61. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +7 -1
  62. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +1 -1
  63. data/lib/dev_system/dev/dev_box.rb +12 -18
  64. data/lib/dev_system/dev/panels/command_panel.rb +54 -11
  65. data/lib/dev_system/dev/panels/command_panel_test.rb +35 -10
  66. data/lib/dev_system/dev/panels/generator_panel.rb +70 -0
  67. data/lib/dev_system/dev/panels/generator_panel_test.rb +34 -0
  68. data/lib/happy_system/happy/happy_box.rb +2 -3
  69. data/lib/lerb.rb +95 -49
  70. data/lib/liza/base/box.rb +6 -1
  71. data/lib/liza/base/panel.rb +16 -18
  72. data/lib/liza/base/panel_test.rb +27 -1
  73. data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
  74. data/lib/liza/ruby_tests/module_test.rb +2 -2
  75. data/lib/liza/test/test_test.rb +5 -1
  76. data/lib/liza/test_parts/test_assertions_part.rb +1 -1
  77. data/lib/liza/test_parts/test_dsl_part.rb +3 -3
  78. data/lib/liza/test_parts/test_tree_part.rb +4 -49
  79. data/lib/liza/unit.rb +73 -79
  80. data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
  81. data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
  82. data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
  83. data/lib/liza/unit_test.rb +11 -0
  84. data/lib/liza.rb +10 -1
  85. data/lib/lizarb/ruby/module.rb +1 -1
  86. data/lib/lizarb/version.rb +1 -1
  87. data/lib/lizarb.rb +247 -23
  88. data/lib/net_system/dev/net_command.rb +9 -9
  89. data/lib/net_system/net/controllers/client/redis_client.rb +1 -1
  90. data/lib/net_system/net/controllers/client/sqlite_client.rb +1 -1
  91. data/lib/net_system/net/net_box.rb +4 -6
  92. data/lib/web_system/dev/rack_command.rb +1 -8
  93. data/lib/web_system/dev/request_command.rb +6 -20
  94. data/lib/web_system/web/panels/request_panel.rb +0 -2
  95. data/lib/web_system/web/web_box.rb +4 -6
  96. data/lizarb.gemspec +1 -1
  97. metadata +46 -41
  98. data/.ruby-version +0 -1
  99. data/app/dev/benches/app_bench.rb +0 -5
  100. data/app/dev/benches/app_bench_test.rb +0 -7
  101. data/app/dev/benches/loops_bench_test.rb +0 -11
  102. data/app/dev/commands/app_command.rb +0 -5
  103. data/app/dev/commands/app_command_test.rb +0 -7
  104. data/app/dev/commands/new_command.rb +0 -9
  105. data/app/dev/commands/new_command_test.rb +0 -7
  106. data/app/dev/generators/bench_generator.rb +0 -18
  107. data/app/dev/generators/command_generator/command.rb.erb +0 -26
  108. data/app/dev/generators/command_generator.rb +0 -18
  109. data/exe/Gemfile.lock +0 -13
  110. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -58
  111. data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -9
  112. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -12
  113. data/lib/dev_system/dev/controllers/command/version_command.rb +0 -7
  114. data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -12
  115. data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -146
  116. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -12
  117. /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
  118. /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
  119. /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
  120. /data/{app → app_new}/dev/commands/quadratic_command_test.rb +0 -0
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[:command].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
@@ -3,25 +3,32 @@ class DevSystem::NotFoundBench < DevSystem::Bench
3
3
  def self.call args
4
4
  # 1. LOG
5
5
 
6
- log :higher, "Called #{self}.#{__method__} with args #{args}"
6
+ log "args = #{args.inspect}"
7
7
  puts
8
8
 
9
9
  # 2. FIND generators
10
10
 
11
- App.eager_load_all
11
+ App.load_all
12
12
  benches = Liza::Bench.descendants
13
+ benches -= ignored_benches
13
14
 
14
- log "Liza comes with #{benches.count} benches you can use."
15
- puts
15
+ # 3. LIST benches
16
16
 
17
+ keys = benches.map { _1.last_namespace.snakecase[0..-7] }.uniq.sort
18
+
19
+ log "Liza comes with #{keys.count} benches you can use."
17
20
  log "Here they are:"
18
21
  puts
19
22
 
20
- # 3. LIST benches
21
-
22
- keys = benches.map { |k| k.last_namespace.snakecase[0..-7] }.sort
23
- keys.reject! { |s| s == "not_found" }
24
23
  keys.each { |s| log "liza bench #{s}" }
25
24
  end
26
25
 
26
+ def self.ignored_benches
27
+ [
28
+ self,
29
+ DevSystem::NotFoundBench,
30
+ (DevSystem::SortedBench if defined? SortedBench),
31
+ ].uniq.compact
32
+ end
33
+
27
34
  end
@@ -1,9 +1,3 @@
1
1
  class DevSystem::Bench < Liza::Controller
2
2
 
3
- # DSLS
4
-
5
- def self.main_dsl
6
- part :"bench_dsl_main", system: :dev
7
- end
8
-
9
3
  end
@@ -3,8 +3,7 @@ class DevSystem::BenchCommand < DevSystem::Command
3
3
  def self.call args
4
4
  # 1. LOG
5
5
 
6
- log :higher, "args: #{args}"
7
- puts
6
+ log "args = #{args.inspect}"
8
7
 
9
8
  # 2. FIND bench
10
9
 
@@ -1,33 +1,9 @@
1
1
  class DevSystem::GenerateCommand < DevSystem::Command
2
2
 
3
- def self.call args
4
- # 1. LOG
3
+ def call args
4
+ log "args = #{args}" if DevBox[:generator].get :log_details
5
5
 
6
- log :higher, "args: #{args}"
7
- puts
8
-
9
- # 2. FIND generator
10
-
11
- return call_not_found args if args.none?
12
-
13
- generator = args[0]
14
-
15
- log({generator:})
16
-
17
- #
18
-
19
- begin
20
- generator_class = Liza.const "#{generator}_generator"
21
- rescue Liza::ConstNotFound
22
- generator_class = NotFoundGenerator
23
- end
24
-
25
- # 3. CALL
26
-
27
- generator_class.call args[1..-1]
6
+ DevBox[:generator].call args
28
7
  end
29
8
 
30
- def self.call_not_found args
31
- Liza::NotFoundGenerator.call args
32
- end
33
9
  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
@@ -3,25 +3,46 @@ class DevSystem::NotFoundCommand < DevSystem::Command
3
3
  def self.call args
4
4
  # 1. LOG
5
5
 
6
- log :higher, "Called #{self}.#{__method__} with args #{args}"
6
+ log "args = #{args.inspect}"
7
7
  puts
8
8
 
9
9
  # 2. FIND commands
10
10
 
11
- App.eager_load_all
11
+ App.load_all
12
12
  commands = Liza::Command.descendants
13
+ commands -= ignored_commands
13
14
 
14
- log "Liza comes with #{commands.count} commands you can use."
15
- puts
15
+ # 3. LIST commands
16
+
17
+ keys = commands.map { _1.last_namespace.snakecase[0..-9] }.uniq.sort
16
18
 
19
+ log "Liza comes with #{keys.count} commands you can use."
17
20
  log "Here they are:"
18
21
  puts
19
22
 
20
- # 3. LIST commands
21
-
22
- keys = commands.map { |k| k.last_namespace.snakecase[0..-9] }.sort
23
- keys.reject! { |s| s == "not_found" }
24
23
  keys.each { |s| log "liza #{s}" }
25
24
  end
26
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
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
46
+ end
47
+
27
48
  end
@@ -1,9 +1,9 @@
1
1
  class DevSystem::TerminalCommand < DevSystem::Command
2
2
 
3
- def self.call args
3
+ def call args
4
4
  # 1. LOG
5
5
 
6
- log :higher, "args: #{args}"
6
+ log "args = #{args.inspect}"
7
7
  puts
8
8
 
9
9
  # 2. FIND terminal
@@ -1,9 +1,9 @@
1
1
  class DevSystem::TestCommand < DevSystem::Command
2
2
 
3
3
  def self.call args
4
- log :higher, "Called #{self} with args #{args}"
4
+ log "args = #{args.inspect}"
5
5
 
6
- App.eager_load_all
6
+ App.load_all
7
7
 
8
8
  now = Time.now
9
9
  test_classes = Liza::Test.descendants
@@ -44,11 +44,11 @@ class DevSystem::TestCommand < DevSystem::Command
44
44
  proc_namespaced = proc { |tc| tc.name.include? "::" }
45
45
  proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
46
46
 
47
- tc_app = test_classes.reject &proc_namespaced
48
- tc_namespaced = test_classes.select &proc_namespaced
47
+ tc_app = test_classes.reject(&proc_namespaced)
48
+ tc_namespaced = test_classes.select(&proc_namespaced)
49
49
 
50
- tc_liza = tc_namespaced.select &proc_liza
51
- tc_system = tc_namespaced.reject &proc_liza
50
+ tc_liza = tc_namespaced.select(&proc_liza)
51
+ tc_system = tc_namespaced.reject(&proc_liza)
52
52
 
53
53
  tc_app.sort_by! &:source_location
54
54
  tc_liza.sort_by! &:source_location
@@ -1,17 +1,13 @@
1
1
  class DevSystem::Command < Liza::Controller
2
2
 
3
- # def self.call args
4
- # new.call args
5
- # end
6
-
7
- # def initialize args
8
- # @args = args
9
- # end
10
-
11
- # attr_reader :args
12
-
13
- # def call args
14
- #
15
- # end
3
+ def self.call args
4
+ log "args = #{args}"
5
+ new.call args
6
+ end
7
+
8
+ def call args
9
+ log "args = #{args}"
10
+ raise NotImplementedError
11
+ end
16
12
 
17
13
  end
@@ -3,7 +3,7 @@ class DevSystem::GeneratorDslMainPart < Liza::Part
3
3
  insertion do
4
4
 
5
5
  def self.call args
6
- log :higher, "Called #{self}.#{__method__} with args #{args}"
6
+ log "args = #{args.inspect}"
7
7
 
8
8
  name = args.shift || raise("args[0] should contain NAME")
9
9
  name = name.downcase
@@ -11,7 +11,7 @@ class DevSystem::GeneratorDslMainPart < Liza::Part
11
11
  memo.each do |label, bl|
12
12
  log "Generating #{label}"
13
13
  g = new label, name, args
14
- g.instance_exec &bl
14
+ g.instance_exec(&bl)
15
15
  g.call
16
16
  end
17
17
 
@@ -35,8 +35,6 @@ class DevSystem::GeneratorDslMainPart < Liza::Part
35
35
 
36
36
  %w|folder filename content|.each do |s|
37
37
  class_eval <<-CODE, __FILE__, __LINE__ + 1
38
- attr_reader :#{s}
39
-
40
38
  def #{s} #{s} = nil
41
39
  if #{s}
42
40
  @#{s} = #{s}
@@ -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