lizarb 0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +13 -2
- data/Gemfile +21 -2
- data/Gemfile.lock +44 -0
- data/README.md +88 -12
- data/app/dev/commands/app_command.rb +5 -0
- data/app/dev/commands/app_command_test.rb +7 -0
- data/app/dev/commands/example_command.rb +57 -0
- data/app/dev/commands/example_command_test.rb +43 -0
- data/app/dev/commands/macro_child_command.rb +32 -0
- data/app/dev/commands/macro_child_command_test.rb +7 -0
- data/app/dev/commands/macro_parent_command.rb +70 -0
- data/app/dev/commands/macro_parent_command_test.rb +7 -0
- data/app/dev/commands/my_command.rb +7 -0
- data/app/dev/commands/my_command_test.rb +7 -0
- data/app/dev/commands/new_command.rb +69 -0
- data/app/dev/commands/new_command_test.rb +7 -0
- data/app/dev_box.rb +13 -0
- data/app/happy/axos/axo.rb +50 -0
- data/app/happy_box.rb +8 -0
- data/app/net/databases/redis_db.rb +5 -0
- data/app/net/databases/redis_db_test.rb +12 -0
- data/app/net/databases/sqlite_db.rb +11 -0
- data/app/net/databases/sqlite_db_test.rb +12 -0
- data/app/net/models/app_model.rb +20 -0
- data/app/net/models/app_model_test.rb +8 -0
- data/app/net/models/post_model.rb +4 -0
- data/app/net/models/post_model_test.rb +8 -0
- data/app/net/models/user_model.rb +4 -0
- data/app/net/models/user_model_test.rb +8 -0
- data/app/net_box.rb +21 -0
- data/app/web/requests/api_request.rb +61 -0
- data/app/web/requests/api_request_test.rb +31 -0
- data/app/web/requests/app_request.rb +5 -0
- data/app/web/requests/app_request_test.rb +7 -0
- data/app/web/requests/assets_request.rb +71 -0
- data/app/web/requests/assets_request_test.rb +33 -0
- data/app/web/requests/root_request.rb +55 -0
- data/app/web/requests/root_request_test.rb +31 -0
- data/app/web_box.rb +8 -0
- data/app.code.env +11 -0
- data/app.env +11 -0
- data/app.rb +17 -0
- data/app_new/.gitignore +4 -0
- data/app_new/Gemfile +31 -0
- data/app_new/Procfile +3 -0
- data/exe/Gemfile +3 -0
- data/exe/Gemfile.lock +13 -0
- data/exe/liza +3 -0
- data/exe/lizarb +11 -0
- data/lib/app.rb +200 -0
- data/lib/dev_system/dev/controllers/command/dev_command.rb +19 -0
- data/lib/dev_system/dev/controllers/command/dev_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/echo_command.rb +11 -0
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +70 -0
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/version_command.rb +9 -0
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command.rb +19 -0
- data/lib/dev_system/dev/controllers/command_test.rb +14 -0
- data/lib/dev_system/dev/dev_box.rb +19 -0
- data/lib/dev_system/dev/dev_box_test.rb +19 -0
- data/lib/dev_system/dev/panels/command_panel.rb +10 -0
- data/lib/dev_system/dev/panels/command_panel_test.rb +23 -0
- data/lib/dev_system/dev/panels/log_panel.rb +10 -0
- data/lib/dev_system/dev/panels/log_panel_test.rb +18 -0
- data/lib/dev_system.rb +8 -0
- data/lib/happy_system/dev/happy_command.rb +11 -0
- data/lib/happy_system/happy/controllers/axo.rb +8 -0
- data/lib/happy_system/happy/happy_box.rb +12 -0
- data/lib/happy_system/happy/happy_box_test.rb +18 -0
- data/lib/happy_system/happy/panels/axo_panel.rb +5 -0
- data/lib/{viral.rb → happy_system.rb} +7 -3
- data/lib/liza/base/box.rb +40 -0
- data/lib/liza/base/box_test.rb +12 -0
- data/lib/liza/base/controller.rb +27 -0
- data/lib/liza/base/controller_test.rb +12 -0
- data/lib/liza/base/panel.rb +38 -0
- data/lib/liza/base/panel_test.rb +16 -0
- data/lib/liza/meta/part.rb +19 -0
- data/lib/liza/meta/part_extension.rb +13 -0
- data/lib/liza/meta/part_test.rb +8 -0
- data/lib/liza/meta/system.rb +20 -0
- data/lib/liza/meta/system_test.rb +13 -0
- data/lib/liza/test/test.rb +11 -0
- data/lib/liza/test/test_test.rb +108 -0
- data/lib/liza/test_parts/test_assertions_part.rb +110 -0
- data/lib/liza/test_parts/test_context_part.rb +81 -0
- data/lib/liza/test_parts/test_dsl_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +19 -0
- data/lib/liza/unit.rb +149 -0
- data/lib/liza/unit_test.rb +79 -0
- data/lib/liza.rb +34 -0
- data/lib/lizarb/ruby/class.rb +15 -0
- data/lib/lizarb/ruby/string.rb +9 -0
- data/lib/lizarb/ruby/time.rb +9 -0
- data/lib/{viral → lizarb}/version.rb +2 -2
- data/lib/lizarb.rb +68 -0
- data/lib/net_system/dev/net_command.rb +24 -0
- data/lib/net_system/net/controllers/adapter/redis_adapter.rb +28 -0
- data/lib/net_system/net/controllers/adapter/redis_adapter_test.rb +29 -0
- data/lib/net_system/net/controllers/adapter/sqlite_adapter.rb +28 -0
- data/lib/net_system/net/controllers/adapter/sqlite_adapter_test.rb +29 -0
- data/lib/net_system/net/controllers/adapter.rb +5 -0
- data/lib/net_system/net/controllers/adapter_test.rb +14 -0
- data/lib/net_system/net/controllers/database/redis_db.rb +11 -0
- data/lib/net_system/net/controllers/database/redis_db_test.rb +23 -0
- data/lib/net_system/net/controllers/database/sqlite_db.rb +11 -0
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +23 -0
- data/lib/net_system/net/controllers/database.rb +33 -0
- data/lib/net_system/net/controllers/database_test.rb +14 -0
- data/lib/net_system/net/controllers/model.rb +31 -0
- data/lib/net_system/net/controllers/model_test.rb +14 -0
- data/lib/net_system/net/net_box.rb +20 -0
- data/lib/net_system/net/net_box_test.rb +19 -0
- data/lib/net_system/net/panels/adapter_panel.rb +5 -0
- data/lib/net_system/net/panels/adapter_panel_test.rb +18 -0
- data/lib/net_system/net/panels/database_panel.rb +12 -0
- data/lib/net_system/net/panels/database_panel_test.rb +18 -0
- data/lib/net_system.rb +3 -0
- data/lib/web_system/dev/web_command.rb +42 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +18 -0
- data/lib/web_system/web/controllers/request/not_found_request.rb +18 -0
- data/lib/web_system/web/controllers/request/server_error_request.rb +20 -0
- data/lib/web_system/web/controllers/request.rb +5 -0
- data/lib/web_system/web/controllers/request_test.rb +18 -0
- data/lib/web_system/web/panels/request_panel.rb +55 -0
- data/lib/web_system/web/panels/request_panel_test.rb +14 -0
- data/lib/web_system/web/web_box.rb +12 -0
- data/lib/web_system/web/web_box_test.rb +18 -0
- data/lib/web_system.rb +5 -0
- data/lizarb.gemspec +44 -0
- data/sig/{viral.rbs → lizarb.rbs} +1 -1
- data/web_files/favicon.ico +0 -0
- data/web_files/favicon.svg +948 -0
- metadata +190 -13
- data/viral.gemspec +0 -45
data/lib/app.rb
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
module App
|
2
|
+
class Error < StandardError; end
|
3
|
+
class ModeNotFound < Error; end
|
4
|
+
class SystemNotFound < Error; end
|
5
|
+
|
6
|
+
#
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def log s
|
11
|
+
puts s.bold
|
12
|
+
end
|
13
|
+
|
14
|
+
# called from "#{APP_DIR}/app"
|
15
|
+
def call argv, &block
|
16
|
+
instance_exec &block
|
17
|
+
|
18
|
+
setup_env
|
19
|
+
setup_bundle
|
20
|
+
setup_liza
|
21
|
+
bundle_systems_app Lizarb::APP_DIR
|
22
|
+
|
23
|
+
check_mode!
|
24
|
+
|
25
|
+
puts
|
26
|
+
::DevBox.commands.call argv
|
27
|
+
puts
|
28
|
+
end
|
29
|
+
|
30
|
+
def root
|
31
|
+
Pathname Dir.pwd
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_env
|
35
|
+
require "dotenv"
|
36
|
+
Dotenv.load "app.#{mode}.env", "app.env"
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_bundle
|
40
|
+
require "bundler/setup"
|
41
|
+
Bundler.require :default, *@systems.keys
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_liza
|
45
|
+
require "liza"
|
46
|
+
|
47
|
+
@loaders << loader = Zeitwerk::Loader.new
|
48
|
+
loader.tag = Liza.to_s
|
49
|
+
|
50
|
+
# ORDER MATTERS: IGNORE, COLLAPSE, PUSH
|
51
|
+
loader.collapse "#{fname_for Liza}/**/*"
|
52
|
+
loader.push_dir "#{fname_for Liza}", namespace: Liza
|
53
|
+
|
54
|
+
loader.enable_reloading
|
55
|
+
loader.setup
|
56
|
+
end
|
57
|
+
|
58
|
+
def bundle_systems_app app_dir
|
59
|
+
@systems.keys.each do |k|
|
60
|
+
key = "#{k}_system"
|
61
|
+
|
62
|
+
require_system key
|
63
|
+
klass = Object.const_get key.camelize
|
64
|
+
|
65
|
+
@systems[k] = klass
|
66
|
+
end
|
67
|
+
|
68
|
+
@loaders << loader = Zeitwerk::Loader.new
|
69
|
+
|
70
|
+
@systems.each do |k, klass|
|
71
|
+
# ORDER MATTERS: IGNORE, COLLAPSE, PUSH
|
72
|
+
loader.collapse "#{fname_for klass}/**/*"
|
73
|
+
loader.push_dir "#{fname_for klass}", namespace: klass
|
74
|
+
end
|
75
|
+
|
76
|
+
# ORDER MATTERS: IGNORE, COLLAPSE, PUSH
|
77
|
+
loader.collapse "#{app_dir}/app/**/*"
|
78
|
+
loader.push_dir "#{app_dir}/app" if Dir.exist? "#{app_dir}/app"
|
79
|
+
|
80
|
+
loader.enable_reloading
|
81
|
+
loader.setup
|
82
|
+
|
83
|
+
@systems.each do |k, klass|
|
84
|
+
connect_system k, klass
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# loaders
|
89
|
+
|
90
|
+
@loaders = []
|
91
|
+
@mutex = Mutex.new
|
92
|
+
|
93
|
+
def reload &block
|
94
|
+
@mutex.synchronize do
|
95
|
+
@loaders.map &:reload
|
96
|
+
yield if block_given?
|
97
|
+
end
|
98
|
+
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
def eager_load_all
|
103
|
+
Zeitwerk::Loader.eager_load_all
|
104
|
+
end
|
105
|
+
|
106
|
+
# mode
|
107
|
+
|
108
|
+
@modes = [:code]
|
109
|
+
ENV["LIZA_MODE"] ||= @modes.first.to_s
|
110
|
+
@mode = ENV["LIZA_MODE"].to_sym
|
111
|
+
|
112
|
+
def mode mode = nil
|
113
|
+
return @mode if mode.nil?
|
114
|
+
@modes << mode.to_sym
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_mode!
|
118
|
+
return if @modes.include? @mode
|
119
|
+
raise ModeNotFound, "LIZA_MODE `#{@mode}` not found in #{@modes}", []
|
120
|
+
end
|
121
|
+
|
122
|
+
# systems
|
123
|
+
|
124
|
+
@systems = {}
|
125
|
+
|
126
|
+
def system key
|
127
|
+
raise "locked" if @locked
|
128
|
+
@systems[key] = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def systems
|
132
|
+
@systems
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.require_system key
|
136
|
+
require key
|
137
|
+
rescue LoadError => e
|
138
|
+
def e.backtrace; []; end
|
139
|
+
raise SystemNotFound, "FILE #{key}.rb not found on $LOAD_PATH", []
|
140
|
+
end
|
141
|
+
|
142
|
+
# parts
|
143
|
+
|
144
|
+
def connect_part part_klass, key, system
|
145
|
+
klass = if system.nil?
|
146
|
+
Liza.const "#{key}_part"
|
147
|
+
else
|
148
|
+
Liza.const("#{system}_system")
|
149
|
+
.const "#{key}_part"
|
150
|
+
end
|
151
|
+
|
152
|
+
log "CONNECTING PART #{part_klass.to_s.rjust 25}.part :#{key}"
|
153
|
+
|
154
|
+
if klass.insertion
|
155
|
+
part_klass.class_exec &klass.insertion
|
156
|
+
end
|
157
|
+
|
158
|
+
if klass.extension
|
159
|
+
klass.const_set :Extension, Class.new(Liza::PartExtension)
|
160
|
+
klass::Extension.class_exec &klass.extension
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# systems
|
165
|
+
|
166
|
+
def connect_system key, system_klass
|
167
|
+
t = Time.now
|
168
|
+
|
169
|
+
color_system_klass = system_klass.to_s.colorize system_klass.log_color
|
170
|
+
color_key = key.to_s.colorize system_klass.log_color
|
171
|
+
|
172
|
+
registrar_index = 0
|
173
|
+
system_klass.registrar.each do |string, target_block|
|
174
|
+
reg_type, _sep, reg_target = string.to_s.lpartition "_"
|
175
|
+
|
176
|
+
registrar_index += 1
|
177
|
+
|
178
|
+
target_klass = Liza.const reg_target
|
179
|
+
|
180
|
+
if reg_type == "insertion"
|
181
|
+
target_klass.class_exec &target_block
|
182
|
+
else
|
183
|
+
raise "TODO: decide and implement system extension"
|
184
|
+
end
|
185
|
+
|
186
|
+
log "CONNECTING SYSTEM PART #{color_system_klass}.#{reg_type} #{target_klass}"
|
187
|
+
|
188
|
+
end
|
189
|
+
log "CONNECTING SYSTEM - #{t.diff}s for #{color_system_klass} to connect to #{registrar_index} system parts"
|
190
|
+
end
|
191
|
+
|
192
|
+
#
|
193
|
+
|
194
|
+
def fname_for klass
|
195
|
+
# /path/to/liza.rb
|
196
|
+
# /path/to/liza
|
197
|
+
Object.const_source_location(klass.name)[0][0..-4]
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class DevCommand < Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
log :higher, "Called #{self} with args #{args}"
|
6
|
+
|
7
|
+
# https://github.com/ruby/ruby/blob/master/lib/irb.rb
|
8
|
+
require "irb"
|
9
|
+
|
10
|
+
IRB.setup(nil)
|
11
|
+
workspace = IRB::WorkSpace.new(binding)
|
12
|
+
irb = IRB::Irb.new(workspace)
|
13
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
14
|
+
|
15
|
+
irb.eval_input
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class DevCommandTest < CommandTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::DevCommand
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class EchoCommandTest < CommandTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::EchoCommand
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class TestCommand < Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
log :higher, "Called #{self} with args #{args}"
|
6
|
+
|
7
|
+
App.eager_load_all
|
8
|
+
|
9
|
+
now = Time.now
|
10
|
+
test_classes = Liza::Test.descendants
|
11
|
+
|
12
|
+
test_classes = _call_sort test_classes
|
13
|
+
|
14
|
+
log "Testing #{test_classes}"
|
15
|
+
_call_testing test_classes
|
16
|
+
log "Done Testing (#{now.diff}s)"
|
17
|
+
|
18
|
+
puts
|
19
|
+
|
20
|
+
log "Counting #{test_classes.count} Test Classes"
|
21
|
+
_call_counting test_classes
|
22
|
+
log "Done Counting (#{now.diff}s)"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self._call_sort test_classes
|
26
|
+
test_classes.sort_by! &:name
|
27
|
+
|
28
|
+
proc_namespaced = proc { |tc| tc.name.include? "::" }
|
29
|
+
proc_liza = proc { |tc| tc.name[0..3] == "Liza" }
|
30
|
+
|
31
|
+
tc_app = test_classes.reject &proc_namespaced
|
32
|
+
tc_namespaced = test_classes.select &proc_namespaced
|
33
|
+
|
34
|
+
tc_liza = tc_namespaced.select &proc_liza
|
35
|
+
tc_system = tc_namespaced.reject &proc_liza
|
36
|
+
|
37
|
+
tc_app.sort_by! { |tc| Object.const_source_location(tc.name)[0] }
|
38
|
+
tc_liza.sort_by! { |tc| Object.const_source_location(tc.name)[0] }
|
39
|
+
|
40
|
+
[tc_liza, tc_system, tc_app].flatten
|
41
|
+
end
|
42
|
+
|
43
|
+
def self._call_testing test_classes
|
44
|
+
i, count = 0, test_classes.count
|
45
|
+
for test_class in test_classes
|
46
|
+
test_class.call i+=1, count
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self._call_counting test_classes
|
51
|
+
puts
|
52
|
+
totals = Hash.new { 0 }
|
53
|
+
last_namespace = nil
|
54
|
+
test_classes.each do |test_class|
|
55
|
+
namespace = test_class.first_namespace
|
56
|
+
puts if last_namespace != namespace
|
57
|
+
last_namespace = namespace
|
58
|
+
|
59
|
+
test_class.totals.each do |k, v|
|
60
|
+
totals[k] += v.size
|
61
|
+
end
|
62
|
+
Liza.log " #{"#{test_class}.totals".ljust 60} #{test_class.totals.map { |k, v| [k, v.size] }.to_h}"
|
63
|
+
end
|
64
|
+
puts
|
65
|
+
Liza.log " #{"Total".ljust 60} #{totals}"
|
66
|
+
puts
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class TestCommandTest < CommandTest
|
3
|
+
|
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
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class VersionCommandTest < CommandTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::VersionCommand
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class CommandTest < Liza::ControllerTest
|
3
|
+
|
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
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class DevBox < Liza::Box
|
3
|
+
has_panel :command, :commands
|
4
|
+
has_controller :command, :commands
|
5
|
+
|
6
|
+
has_panel :log, :logs
|
7
|
+
|
8
|
+
# Set up your command panel per the DSL in http://guides.lizarb.org/panels/command.html
|
9
|
+
commands do
|
10
|
+
# set :log_level, ENV["dev.command.log_level"]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Set up your command panel per the DSL in http://guides.lizarb.org/panels/log.html
|
14
|
+
logs do
|
15
|
+
# set :log_level, ENV["dev.log.log_level"]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class DevBoxTest < Liza::BoxTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::DevBox
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
test :panels do
|
14
|
+
assert subject_class.commands.is_a? CommandPanel
|
15
|
+
assert subject_class.logs.is_a? LogPanel
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class CommandPanelTest < Liza::PanelTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::CommandPanel
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
test :call do
|
14
|
+
begin
|
15
|
+
subject.call ["echo", 1, 2, 3]
|
16
|
+
assert false
|
17
|
+
rescue RuntimeError => e
|
18
|
+
assert e.message == "[1, 2, 3]"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class DevSystem
|
2
|
+
class LogPanelTest < Liza::PanelTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == DevSystem::LogPanel
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :green
|
11
|
+
end
|
12
|
+
|
13
|
+
# test :call do
|
14
|
+
# todo "write this"
|
15
|
+
# end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/dev_system.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class HappySystem
|
2
|
+
class HappyBoxTest < Liza::BoxTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == HappySystem::HappyBox
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :magenta
|
11
|
+
end
|
12
|
+
|
13
|
+
test :panels do
|
14
|
+
assert subject_class.axo.is_a? AxoPanel
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Liza
|
2
|
+
class Box < Unit
|
3
|
+
inherited_explicitly_sets_system
|
4
|
+
|
5
|
+
def self.has_panel symbol, panel_name = symbol
|
6
|
+
system_klass = get :system
|
7
|
+
panel_class = system_klass.const "#{symbol}_panel"
|
8
|
+
|
9
|
+
_has_panel_define panel_name, "get(:panels)[:#{panel_name}]"
|
10
|
+
|
11
|
+
panel = panel_class.new panel_name
|
12
|
+
add :panels, panel_name, panel
|
13
|
+
|
14
|
+
panel_class.on_connected self
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.has_controller symbol, panel_name = symbol
|
18
|
+
system_klass = get :system
|
19
|
+
controller_class = system_klass.const symbol
|
20
|
+
|
21
|
+
panel = public_send panel_name
|
22
|
+
|
23
|
+
controller_class.on_connected self, panel
|
24
|
+
end
|
25
|
+
|
26
|
+
def self._has_panel_define name, resource
|
27
|
+
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
28
|
+
|
29
|
+
def self.#{name} &block
|
30
|
+
if block_given?
|
31
|
+
#{resource}.instance_eval &block
|
32
|
+
else
|
33
|
+
#{resource}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
CODE
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Liza
|
2
|
+
class Controller < Unit
|
3
|
+
inherited_explicitly_sets_system
|
4
|
+
|
5
|
+
def self.on_connected box_klass, panel
|
6
|
+
set :box, box_klass
|
7
|
+
set :panel, panel
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.box
|
11
|
+
get :box
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.panel
|
15
|
+
get :panel
|
16
|
+
end
|
17
|
+
|
18
|
+
def box
|
19
|
+
self.class.box
|
20
|
+
end
|
21
|
+
|
22
|
+
def panel
|
23
|
+
self.class.panel
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|