lizarb 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/dev_box.rb +24 -4
- data/app/happy_box.rb +1 -1
- data/app/net/databases/sqlite_db_test.rb +5 -5
- data/app/net/records/app_record_test.rb +1 -1
- data/app/net/records/post_record_test.rb +1 -1
- data/app/net/records/user_record_test.rb +1 -1
- data/app/net_box.rb +7 -7
- data/app/web_box.rb +2 -2
- data/lib/app.rb +1 -1
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +17 -19
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
- data/lib/dev_system/dev/controllers/bench.rb +5 -7
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -22
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +20 -22
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +17 -19
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command.rb +11 -13
- data/lib/dev_system/dev/controllers/command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generator.rb +5 -7
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +103 -53
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +17 -19
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
- data/lib/dev_system/dev/dev_box.rb +33 -16
- data/lib/dev_system/dev/dev_box_test.rb +12 -14
- data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
- data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/command_panel.rb +16 -18
- data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
- data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/log_panel.rb +9 -6
- data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
- data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
- data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
- data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
- data/lib/happy_system/happy/controllers/axo.rb +4 -5
- data/lib/happy_system/happy/happy_box.rb +6 -9
- data/lib/happy_system/happy/happy_box_test.rb +11 -13
- data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
- data/lib/liza/base/box.rb +71 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -21
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +42 -27
- data/lib/liza/base/panel_test.rb +10 -12
- data/lib/liza/meta/part.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -16
- data/lib/liza/meta/part_test.rb +4 -6
- data/lib/liza/meta/system.rb +12 -14
- data/lib/liza/meta/system_test.rb +8 -10
- data/lib/liza/ruby_test.rb +4 -6
- data/lib/liza/ruby_tests/module_test.rb +1 -1
- data/lib/liza/test/test.rb +7 -10
- data/lib/liza/test/test_test.rb +158 -159
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
- data/lib/liza/test_parts/test_assertions_part.rb +81 -83
- data/lib/liza/test_parts/test_dsl_part.rb +47 -49
- data/lib/liza/test_parts/test_log_part.rb +88 -90
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +105 -107
- data/lib/liza/unit.rb +108 -104
- data/lib/liza/unit_test.rb +69 -71
- data/lib/lizarb/version.rb +1 -1
- data/lib/net_system/dev/net_command.rb +10 -12
- data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
- data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
- data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client.rb +1 -3
- data/lib/net_system/net/controllers/client_test.rb +8 -10
- data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
- data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database.rb +21 -23
- data/lib/net_system/net/controllers/database_test.rb +8 -10
- data/lib/net_system/net/controllers/record.rb +21 -23
- data/lib/net_system/net/controllers/record_test.rb +8 -10
- data/lib/net_system/net/net_box.rb +11 -16
- data/lib/net_system/net/net_box_test.rb +12 -14
- data/lib/net_system/net/panels/client_panel.rb +1 -3
- data/lib/net_system/net/panels/client_panel_test.rb +11 -13
- data/lib/net_system/net/panels/database_panel.rb +6 -8
- data/lib/net_system/net/panels/database_panel_test.rb +11 -13
- data/lib/web_system/dev/rack_command.rb +26 -17
- data/lib/web_system/dev/request_command.rb +2 -2
- data/lib/web_system/dev/web_command.rb +6 -8
- data/lib/web_system/web/controllers/rack.rb +4 -6
- data/lib/web_system/web/controllers/rack_test.rb +11 -13
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
- data/lib/web_system/web/controllers/request.rb +1 -3
- data/lib/web_system/web/controllers/request_test.rb +11 -13
- data/lib/web_system/web/panels/rack_panel.rb +37 -39
- data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
- data/lib/web_system/web/panels/request_panel.rb +54 -56
- data/lib/web_system/web/panels/request_panel_test.rb +1 -1
- data/lib/web_system/web/web_box.rb +14 -18
- data/lib/web_system/web/web_box_test.rb +11 -13
- metadata +10 -5
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e926fac5423110d8a9468bac9598dbe3a88922c61ac584311dc2b9a49ce81f
|
4
|
+
data.tar.gz: 0a2e15f3cd064944b01d02a8761fca520a3167172c7193c00f7c5d807e0e88ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba9279ab0d31e64b01d41d764542a73465171497950a681119ecc2a2c8f01a66f04172dc67617b03c92a04302c8772c88209f5803053cf1c405216ac5cb003d9
|
7
|
+
data.tar.gz: 5b27e32f1f16dd6c2536c4ad6046bb782a9eb20a8e8c9f68d7b6ab412950a464367193b435e801f9c3b442120414ad0cf7b8f034c3fae40b9050efebcf2cfe17
|
data/Gemfile.lock
CHANGED
data/app/dev_box.rb
CHANGED
@@ -1,13 +1,33 @@
|
|
1
1
|
class DevBox < Liza::DevBox
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# Set up your bench panel per the DSL in http://guides.lizarb.org/panels/bench.html
|
4
|
+
panel :bench do
|
5
|
+
# set :log_level, ENV["dev.bench.log_level"]
|
6
|
+
end
|
7
|
+
|
8
|
+
# Set up your command panel per the DSL in http://guides.lizarb.org/panels/command.html
|
9
|
+
panel :command do
|
10
|
+
# set :log_level, ENV["dev.command.log_level"]
|
11
|
+
end
|
5
12
|
|
13
|
+
# Set up your generator panel per the DSL in http://guides.lizarb.org/panels/generator.html
|
14
|
+
panel :generator do
|
15
|
+
# set :log_level, ENV["dev.generator.log_level"]
|
6
16
|
end
|
7
17
|
|
8
|
-
|
9
|
-
|
18
|
+
# Set up your command panel per the DSL in http://guides.lizarb.org/panels/log.html
|
19
|
+
panel :log do
|
20
|
+
# set :log_level, ENV["dev.log.log_level"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Set up your shell panel per the DSL in http://guides.lizarb.org/panels/shell.html
|
24
|
+
panel :shell do
|
25
|
+
# set :log_level, ENV["dev.shell.log_level"]
|
26
|
+
end
|
10
27
|
|
28
|
+
# Set up your terminal panel per the DSL in http://guides.lizarb.org/panels/terminal.html
|
29
|
+
panel :terminal do
|
30
|
+
# set :log_level, ENV["dev.terminal.log_level"]
|
11
31
|
end
|
12
32
|
|
13
33
|
end
|
data/app/happy_box.rb
CHANGED
@@ -2,11 +2,11 @@ class SqliteDbTest < Liza::SqliteDbTest
|
|
2
2
|
|
3
3
|
test :subject_class do
|
4
4
|
assert subject_class == SqliteDb
|
5
|
-
assert SqliteDb.current.class == SqliteDb
|
6
|
-
assert Liza::SqliteDb.current.class == SqliteDb
|
7
|
-
assert SqliteDb.current == Liza::SqliteDb.current
|
8
|
-
assert SqliteDb.current.client == Liza::SqliteDb.current.client
|
9
|
-
assert SqliteDb.current.client.conn == Liza::SqliteDb.current.client.conn
|
5
|
+
# assert SqliteDb.current.class == SqliteDb
|
6
|
+
# assert Liza::SqliteDb.current.class == SqliteDb
|
7
|
+
# assert SqliteDb.current == Liza::SqliteDb.current
|
8
|
+
# assert SqliteDb.current.client == Liza::SqliteDb.current.client
|
9
|
+
# assert SqliteDb.current.client.conn == Liza::SqliteDb.current.client.conn
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
data/app/net_box.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
class NetBox < Liza::NetBox
|
2
2
|
|
3
|
-
|
3
|
+
panel :client do
|
4
4
|
# Set up your client panel per the DSL in http://guides.lizarb.org/panels/client.html
|
5
5
|
|
6
6
|
set :redis_url, "redis://localhost:6379/15"
|
7
|
-
set :
|
8
|
-
set :
|
7
|
+
set :sqlite_path, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
|
8
|
+
set :sqlite_path, "app.#{App.mode}.sqlite"
|
9
9
|
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
panel :database do
|
13
13
|
# Set up your database panel per the DSL in http://guides.lizarb.org/panels/database.html
|
14
14
|
|
15
|
-
define :redis, RedisDb
|
16
|
-
define :sql, SqliteDb
|
17
|
-
define :sqlite, SqliteDb
|
15
|
+
define :redis, RedisDb
|
16
|
+
define :sql, SqliteDb
|
17
|
+
define :sqlite, SqliteDb
|
18
18
|
|
19
19
|
end
|
20
20
|
|
data/app/web_box.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class WebBox < Liza::WebBox
|
2
2
|
|
3
|
-
rack do
|
3
|
+
panel :rack do
|
4
4
|
# Set up your rack panel per the DSL in http://guides.lizarb.org/panels/rack.html
|
5
5
|
|
6
6
|
# set :files, App.root.join("web_files")
|
@@ -8,7 +8,7 @@ class WebBox < Liza::WebBox
|
|
8
8
|
# set :port, 3000
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
panel :request do
|
12
12
|
# Set up your request panel per the DSL in http://guides.lizarb.org/panels/request.html
|
13
13
|
|
14
14
|
end
|
data/lib/app.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class NotFoundBench < Bench
|
1
|
+
class DevSystem::NotFoundBench < DevSystem::Bench
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
7
|
+
puts
|
9
8
|
|
10
|
-
|
9
|
+
# 2. FIND generators
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
App.eager_load_all
|
12
|
+
benches = Liza::Bench.descendants
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
log "Liza comes with #{benches.count} benches you can use."
|
15
|
+
puts
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
log "Here they are:"
|
18
|
+
puts
|
20
19
|
|
21
|
-
|
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
|
20
|
+
# 3. LIST benches
|
27
21
|
|
22
|
+
keys = benches.map { |k| k.last_namespace.snakecase[0..-7] }.sort
|
23
|
+
keys.reject! { |s| s == "not_found" }
|
24
|
+
keys.each { |s| log "liza bench #{s}" }
|
28
25
|
end
|
26
|
+
|
29
27
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class NotFoundBenchTest < BenchTest
|
1
|
+
class DevSystem::NotFoundBenchTest < DevSystem::BenchTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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,9 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class Bench < Liza::Controller
|
1
|
+
class DevSystem::Bench < Liza::Controller
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
def self.main_dsl
|
7
|
-
part :"bench_dsl_main", system: :dev
|
8
|
-
end
|
3
|
+
# DSLS
|
9
4
|
|
5
|
+
def self.main_dsl
|
6
|
+
part :"bench_dsl_main", system: :dev
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,60 +1,58 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class BenchDslMainPart < Liza::Part
|
1
|
+
class DevSystem::BenchDslMainPart < Liza::Part
|
3
2
|
|
4
|
-
|
3
|
+
insertion do
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
def self.call args
|
6
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
# https://rubyapi.org/3.1/o/benchmark
|
9
|
+
require "benchmark"
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
if @setup_bl
|
12
|
+
log "Setting up..."
|
13
|
+
instance_exec &@setup_bl
|
14
|
+
log "Set up"
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
log "Benchmarking #{marks.count} Ruby Blocks"
|
18
|
+
puts
|
20
19
|
|
21
|
-
|
20
|
+
length = marks.keys.map(&:length).max
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
marks.each do |label, bl|
|
23
|
+
log "Benchmarking #{label}"
|
24
|
+
marks[label] = Benchmark.measure label, &bl
|
25
|
+
end
|
27
26
|
|
28
|
-
|
27
|
+
puts
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
log "#{"Reporting".ljust_blanks(length + 17)} App CPU Time Kernel CPU Time Total CPU Time"
|
30
|
+
puts
|
32
31
|
|
33
|
-
|
32
|
+
sorted = marks.sort_by { |_k, tms| tms.total }.to_h
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
sorted.each.with_index do |(label, tms), i|
|
35
|
+
tms = tms.format "%10.6u %10.6y %10.6t"
|
36
|
+
s = "[#{i.next.to_s.rjust_zeroes 2}/#{marks.count.to_s.rjust_zeroes 2}] #{label.rjust_blanks length} #{tms}"
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
puts
|
44
|
-
log "Done"
|
38
|
+
s = s.green if i == 0
|
39
|
+
s = s.red if i == marks.count-1
|
40
|
+
log s
|
45
41
|
end
|
42
|
+
puts
|
43
|
+
log "Done"
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
def self.marks()= @marks ||= {}
|
46
|
+
#
|
50
47
|
|
51
|
-
|
48
|
+
def self.marks()= @marks ||= {}
|
52
49
|
|
53
|
-
|
54
|
-
@setup_bl = block if block_given?
|
55
|
-
end
|
50
|
+
def self.mark(label, &block)= marks[label] = block
|
56
51
|
|
52
|
+
def self.setup &block
|
53
|
+
@setup_bl = block if block_given?
|
57
54
|
end
|
58
55
|
|
59
56
|
end
|
57
|
+
|
60
58
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class BenchTest < Liza::ControllerTest
|
1
|
+
class DevSystem::BenchTest < Liza::ControllerTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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,32 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class BenchCommand < Command
|
1
|
+
class DevSystem::BenchCommand < DevSystem::Command
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
log :higher, "args: #{args}"
|
7
|
+
puts
|
9
8
|
|
10
|
-
|
9
|
+
# 2. FIND bench
|
11
10
|
|
12
|
-
|
11
|
+
return call_not_found args if args.none?
|
13
12
|
|
14
|
-
|
13
|
+
bench = args[0]
|
15
14
|
|
16
|
-
|
15
|
+
log({bench:})
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
# 3. CALL
|
25
|
-
|
26
|
-
bench_klass.call args[1..-1]
|
17
|
+
begin
|
18
|
+
bench_klass = Liza.const "#{bench}_bench"
|
19
|
+
rescue Liza::ConstNotFound
|
20
|
+
bench_klass = NotFoundBench
|
27
21
|
end
|
28
22
|
|
29
|
-
|
30
|
-
Liza::NotFoundBench.call args
|
31
|
-
end
|
23
|
+
# 3. CALL
|
32
24
|
|
25
|
+
bench_klass.call args[1..-1]
|
33
26
|
end
|
27
|
+
|
28
|
+
def self.call_not_found args
|
29
|
+
Liza::NotFoundBench.call args
|
30
|
+
end
|
31
|
+
|
34
32
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class BenchCommandTest < CommandTest
|
1
|
+
class DevSystem::BenchCommandTest < DevSystem::CommandTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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,11 +1,9 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class EchoCommand < Command
|
1
|
+
class DevSystem::EchoCommand < DevSystem::Command
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
raise RuntimeError, args.to_s
|
8
|
-
end
|
3
|
+
def self.call args
|
4
|
+
log :higher, "Called #{self} with args #{args}"
|
9
5
|
|
6
|
+
raise RuntimeError, args.to_s
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class EchoCommandTest < CommandTest
|
1
|
+
class DevSystem::EchoCommandTest < DevSystem::CommandTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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::EchoCommand
|
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,33 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class GenerateCommand < Command
|
1
|
+
class DevSystem::GenerateCommand < DevSystem::Command
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
log :higher, "args: #{args}"
|
7
|
+
puts
|
9
8
|
|
10
|
-
|
9
|
+
# 2. FIND generator
|
11
10
|
|
12
|
-
|
11
|
+
return call_not_found args if args.none?
|
13
12
|
|
14
|
-
|
13
|
+
generator = args[0]
|
15
14
|
|
16
|
-
|
15
|
+
log({generator:})
|
17
16
|
|
18
|
-
|
17
|
+
#
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
begin
|
20
|
+
generator_class = Liza.const "#{generator}_generator"
|
21
|
+
rescue Liza::ConstNotFound
|
22
|
+
generator_class = NotFoundGenerator
|
23
|
+
end
|
25
24
|
|
26
|
-
|
25
|
+
# 3. CALL
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
generator_class.call args[1..-1]
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
def self.call_not_found args
|
31
|
+
Liza::NotFoundGenerator.call args
|
34
32
|
end
|
35
33
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class GenerateCommandTest < CommandTest
|
1
|
+
class DevSystem::GenerateCommandTest < DevSystem::CommandTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
@@ -1,29 +1,27 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class NotFoundCommand < Command
|
1
|
+
class DevSystem::NotFoundCommand < DevSystem::Command
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
7
|
+
puts
|
9
8
|
|
10
|
-
|
9
|
+
# 2. FIND commands
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
App.eager_load_all
|
12
|
+
commands = Liza::Command.descendants
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
log "Liza comes with #{commands.count} commands you can use."
|
15
|
+
puts
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
log "Here they are:"
|
18
|
+
puts
|
20
19
|
|
21
|
-
|
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
|
20
|
+
# 3. LIST commands
|
27
21
|
|
22
|
+
keys = commands.map { |k| k.last_namespace.snakecase[0..-9] }.sort
|
23
|
+
keys.reject! { |s| s == "not_found" }
|
24
|
+
keys.each { |s| log "liza #{s}" }
|
28
25
|
end
|
26
|
+
|
29
27
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class NotFoundCommandTest < CommandTest
|
1
|
+
class DevSystem::NotFoundCommandTest < DevSystem::CommandTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|