lizarb 1.0.1 → 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/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -4
- data/README.md +23 -64
- data/README_SYSTEMS.md +80 -0
- data/Rakefile +3 -1
- data/app/dev/benches/loops_bench.rb +35 -0
- data/app/dev/commands/calculator_command.rb +69 -0
- data/app/dev/commands/calculator_command_test.rb +58 -0
- data/app/dev/commands/circle_command.rb +70 -0
- data/app/dev/commands/circle_command_test.rb +76 -0
- data/app/dev/commands/narrative_method_command.rb +60 -0
- data/app/dev/commands/narrative_method_command_test.rb +36 -0
- data/app/dev/commands/quadratic_command.rb +66 -0
- data/app/dev/commands/quadratic_command_test.rb +47 -0
- data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
- data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
- data/app/dev/generators/bench_generator.rb +2 -51
- data/app/dev/generators/command_generator/command.rb.erb +26 -0
- data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
- data/app/dev/generators/command_generator.rb +2 -35
- data/app/dev/generators/record_generator.rb +46 -0
- data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
- 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/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/records/app_record_test.rb +8 -0
- data/app/net/records/post_record.rb +4 -0
- data/app/net/records/post_record_test.rb +8 -0
- data/app/net/records/user_record.rb +4 -0
- data/app/net/records/user_record_test.rb +8 -0
- data/app/net_box.rb +7 -7
- data/app/web/requests/api_request.rb +8 -7
- data/app/web/requests/assets_request.rb +12 -13
- data/app/web/requests/root_request.rb +6 -7
- data/app/web/requests/root_request_test.rb +1 -1
- data/app/web_box.rb +9 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +19 -15
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
- data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
- 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 -12
- 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 +22 -12
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
- 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 +122 -47
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
- data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
- data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
- data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
- data/lib/dev_system/dev/controllers/shell.rb +26 -14
- data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
- 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 +24 -6
- 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/lerb.rb +106 -0
- data/lib/liza/base/box.rb +71 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -19
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +40 -24
- data/lib/liza/base/panel_test.rb +10 -12
- data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
- data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
- data/lib/liza/meta/part.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -11
- 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 +7 -0
- data/lib/liza/ruby_tests/module_test.rb +21 -0
- data/lib/liza/ruby_tests/string_test.rb +59 -0
- data/lib/liza/test/test.rb +7 -8
- data/lib/liza/test/test_test.rb +168 -76
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
- data/lib/liza/test_parts/test_assertions_part.rb +81 -82
- data/lib/liza/test_parts/test_dsl_part.rb +44 -98
- data/lib/liza/test_parts/test_log_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +137 -0
- data/lib/liza/unit.rb +108 -102
- data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
- data/lib/liza/unit_test.rb +69 -71
- data/lib/liza.rb +5 -0
- data/lib/lizarb/ruby/module.rb +17 -0
- data/lib/lizarb/ruby/string.rb +10 -2
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +24 -2
- 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 +29 -0
- data/lib/net_system/net/controllers/record_test.rb +12 -0
- 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 +35 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +6 -39
- data/lib/web_system/web/controllers/rack.rb +6 -0
- data/lib/web_system/web/controllers/rack_test.rb +16 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
- 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 +42 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
- data/lib/web_system/web/panels/request_panel.rb +54 -37
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +16 -8
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +2 -2
- metadata +76 -28
- data/app/dev/commands/example_command.rb +0 -57
- data/app/dev/commands/example_command_test.rb +0 -43
- data/app/dev/commands/macro_child_command.rb +0 -32
- data/app/dev/commands/macro_child_command_test.rb +0 -7
- data/app/dev/commands/macro_parent_command.rb +0 -70
- data/app/dev/commands/macro_parent_command_test.rb +0 -7
- data/app/dev/commands/my_command.rb +0 -7
- data/app/dev/commands/my_command_test.rb +0 -7
- data/app/dev/generators/model_generator.rb +0 -46
- data/app/net/models/app_model_test.rb +0 -8
- data/app/net/models/post_model.rb +0 -4
- data/app/net/models/post_model_test.rb +0 -8
- data/app/net/models/user_model.rb +0 -4
- data/app/net/models/user_model_test.rb +0 -8
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/model.rb +0 -31
- data/lib/net_system/net/controllers/model_test.rb +0 -14
@@ -1,28 +1,26 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class RedisClient < Client
|
1
|
+
class NetSystem::RedisClient < NetSystem::Client
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
attr_reader :conn
|
3
|
+
# https://redis.io/
|
4
|
+
# https://github.com/redis/redis-rb
|
5
|
+
def initialize *args
|
6
|
+
args = [url: NetBox[:client].get(:redis_url)] if args.empty?
|
7
|
+
log "Connecting to #{args}"
|
8
|
+
@conn = Redis.new *args
|
9
|
+
end
|
13
10
|
|
14
|
-
|
15
|
-
t = Time.now
|
16
|
-
result = @conn.send cmd_name, *args
|
11
|
+
attr_reader :conn
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
13
|
+
def call cmd_name, *args
|
14
|
+
t = Time.now
|
15
|
+
result = @conn.send cmd_name, *args
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
result
|
18
|
+
ensure
|
19
|
+
log "#{t.diff}s | #{cmd_name} | #{args}"
|
20
|
+
end
|
26
21
|
|
22
|
+
def now
|
23
|
+
call :time
|
27
24
|
end
|
25
|
+
|
28
26
|
end
|
@@ -1,29 +1,27 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class RedisClientTest < ClientTest
|
1
|
+
class NetSystem::RedisClientTest < NetSystem::ClientTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :subject_class do
|
9
|
-
assert subject_class == Liza::RedisClient
|
10
|
-
end
|
3
|
+
def subject
|
4
|
+
@subject ||= subject_class.new
|
5
|
+
end
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
test :subject_class do
|
8
|
+
assert subject_class == NetSystem::RedisClient
|
9
|
+
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
assert result.count == 0
|
20
|
-
end
|
11
|
+
test :subject do
|
12
|
+
assert subject.conn.class == Redis
|
13
|
+
end
|
21
14
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
test :call do
|
16
|
+
result = subject.call :keys
|
17
|
+
assert result.class == Array
|
18
|
+
assert result.count == 0
|
19
|
+
end
|
27
20
|
|
21
|
+
test :now do
|
22
|
+
result = subject.now
|
23
|
+
assert result.class == Array
|
24
|
+
assert result.map(&:class) == [Integer, Integer]
|
28
25
|
end
|
26
|
+
|
29
27
|
end
|
@@ -1,28 +1,26 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class SqliteClient < Client
|
1
|
+
class NetSystem::SqliteClient < NetSystem::Client
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
attr_reader :conn
|
3
|
+
# https://www.sqlite.org/
|
4
|
+
# https://github.com/sparklemotion/sqlite3-ruby
|
5
|
+
def initialize *args
|
6
|
+
args = [NetBox[:client].get(:sqlite_path)] if args.empty?
|
7
|
+
log "Connecting to #{args}"
|
8
|
+
@conn = SQLite3::Database.new *args
|
9
|
+
end
|
13
10
|
|
14
|
-
|
15
|
-
t = Time.now
|
16
|
-
result = @conn.execute2 sql, *args
|
11
|
+
attr_reader :conn
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
13
|
+
def call sql, *args
|
14
|
+
t = Time.now
|
15
|
+
result = @conn.execute2 sql, *args
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
result
|
18
|
+
ensure
|
19
|
+
log "#{t.diff}s | #{sql} | #{args}"
|
20
|
+
end
|
26
21
|
|
22
|
+
def now
|
23
|
+
call "SELECT strftime('%Y-%m-%dT%H:%M:%S.%f', 'now', 'localtime');"
|
27
24
|
end
|
25
|
+
|
28
26
|
end
|
@@ -1,29 +1,27 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class SqliteClientTest < ClientTest
|
1
|
+
class NetSystem::SqliteClientTest < NetSystem::ClientTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :subject_class do
|
9
|
-
assert subject_class == Liza::SqliteClient
|
10
|
-
end
|
3
|
+
def subject
|
4
|
+
@subject ||= subject_class.new ":memory:"
|
5
|
+
end
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
test :subject_class do
|
8
|
+
assert subject_class == NetSystem::SqliteClient
|
9
|
+
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
11
|
+
test :subject do
|
12
|
+
assert subject.conn.class == SQLite3::Database
|
13
|
+
end
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
assert result[1][0].class == String
|
26
|
-
end
|
15
|
+
test :call do
|
16
|
+
result = subject.call "SELECT name, sql FROM sqlite_master WHERE type = 'table';"
|
17
|
+
assert result == [["name", "sql"]]
|
18
|
+
end
|
27
19
|
|
20
|
+
test :now do
|
21
|
+
result = subject.now
|
22
|
+
assert result.class == Array
|
23
|
+
assert result[0] == ["strftime('%Y-%m-%dT%H:%M:%S.%f', 'now', 'localtime')"]
|
24
|
+
assert result[1][0].class == String
|
28
25
|
end
|
26
|
+
|
29
27
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class ClientTest < Liza::ControllerTest
|
1
|
+
class NetSystem::ClientTest < 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 == :red
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::Client
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :red
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
class NetSystem
|
2
|
-
|
3
|
-
set_client :redis
|
4
|
-
|
5
|
-
def now
|
6
|
-
array = client.now
|
7
|
-
Time.at array[0]
|
8
|
-
end
|
1
|
+
class NetSystem::RedisDb < NetSystem::Database
|
2
|
+
set_client :redis
|
9
3
|
|
4
|
+
def now
|
5
|
+
array = client.now
|
6
|
+
Time.at array[0]
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,23 +1,21 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class RedisDbTest < DatabaseTest
|
1
|
+
class NetSystem::RedisDbTest < NetSystem::DatabaseTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::RedisDb
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
test :subject do
|
8
|
+
assert subject.client.class == NetSystem::RedisClient
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
test :now do
|
12
|
+
t = subject.now
|
13
|
+
assert! t.is_a? Time
|
14
|
+
assert t.yday == Time.now.yday
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
# test :call do
|
18
|
+
# todo "write this"
|
19
|
+
# end
|
21
20
|
|
22
|
-
end
|
23
21
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
class NetSystem
|
2
|
-
|
3
|
-
set_client :sqlite
|
4
|
-
|
5
|
-
def now
|
6
|
-
array = client.now
|
7
|
-
Time.parse array[1][0]
|
8
|
-
end
|
1
|
+
class NetSystem::SqliteDb < NetSystem::Database
|
2
|
+
set_client :sqlite
|
9
3
|
|
4
|
+
def now
|
5
|
+
array = client.now
|
6
|
+
Time.parse array[1][0]
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,23 +1,21 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class SqliteDbTest < DatabaseTest
|
1
|
+
class NetSystem::SqliteDbTest < NetSystem::DatabaseTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::SqliteDb
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
test :subject do
|
8
|
+
assert subject.client.class == NetSystem::SqliteClient
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
test :now do
|
12
|
+
t = subject.now
|
13
|
+
assert! t.is_a? Time
|
14
|
+
assert t.yday == Time.now.yday
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
# test :call do
|
18
|
+
# todo "write this"
|
19
|
+
# end
|
21
20
|
|
22
|
-
end
|
23
21
|
end
|
@@ -1,33 +1,31 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class Database < Liza::Controller
|
1
|
+
class NetSystem::Database < Liza::Controller
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.inherited sub
|
4
|
+
super
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
return if sub.name.nil?
|
7
|
+
return if sub.name.end_with? "Db"
|
8
|
+
raise "please rename #{sub.name} to #{sub.name}Db"
|
9
|
+
end
|
11
10
|
|
12
|
-
|
11
|
+
attr_reader :client
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def initialize client: get(:client).new
|
14
|
+
@client = client
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def self.set_client client_id
|
18
|
+
set :client, Liza.const("#{client_id}_client")
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
def self.current
|
22
|
+
Thread.current[last_namespace] ||= begin
|
23
|
+
log "Connecting to #{last_namespace}"
|
24
|
+
new
|
27
25
|
end
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
def self.call(...); current.call(...); end
|
29
|
+
def call(...); @client.call(...); end
|
31
30
|
|
32
|
-
end
|
33
31
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class DatabaseTest < Liza::ControllerTest
|
1
|
+
class NetSystem::DatabaseTest < 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 == :red
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::Database
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :red
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class NetSystem::Record < Liza::Controller
|
2
|
+
|
3
|
+
def self.inherited sub
|
4
|
+
super
|
5
|
+
|
6
|
+
return if sub.name.nil?
|
7
|
+
return if sub.name.end_with? "Record"
|
8
|
+
raise "please rename #{sub.name} to #{sub.name}Record"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.db database_id = nil
|
12
|
+
if database_id.nil?
|
13
|
+
db = get :db
|
14
|
+
if db
|
15
|
+
NetBox[:database].get(db)
|
16
|
+
else
|
17
|
+
raise "please set a db to record #{self}"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
valid = NetBox[:database].settings.keys
|
21
|
+
if valid.include? database_id
|
22
|
+
set :db, database_id
|
23
|
+
else
|
24
|
+
raise "invalid db `#{database_id}`, valid options are #{valid}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -1,20 +1,15 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class NetBox < Liza::Box
|
3
|
-
has_panel :client, :clients
|
4
|
-
has_controller :client, :clients
|
1
|
+
class NetSystem::NetBox < Liza::Box
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
has_panel :database, :databases
|
12
|
-
has_controller :database, :databases
|
13
|
-
|
14
|
-
# Set up your database panel per the DSL in http://guides.lizarb.org/panels/database.html
|
15
|
-
databases do
|
16
|
-
# set :log_level, ENV["net.database.log_level"]
|
17
|
-
end
|
3
|
+
# Set up your client panel per the DSL in http://guides.lizarb.org/panels/client.html
|
4
|
+
panel :client do
|
5
|
+
# set :log_level, ENV["net.client.log_level"]
|
6
|
+
end
|
18
7
|
|
8
|
+
# Set up your database panel per the DSL in http://guides.lizarb.org/panels/database.html
|
9
|
+
panel :database do
|
10
|
+
# set :log_level, ENV["net.database.log_level"]
|
19
11
|
end
|
12
|
+
|
13
|
+
has_controller :client, :client
|
14
|
+
has_controller :database, :database
|
20
15
|
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class NetBoxTest < Liza::BoxTest
|
1
|
+
class NetSystem::NetBoxTest < Liza::BoxTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :red
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::NetBox
|
5
|
+
end
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :red
|
10
|
+
end
|
17
11
|
|
12
|
+
test :panels do
|
13
|
+
assert subject_class[:client].is_a? NetSystem::ClientPanel
|
14
|
+
assert subject_class[:database].is_a? NetSystem::DatabasePanel
|
18
15
|
end
|
16
|
+
|
19
17
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class ClientPanelTest < Liza::PanelTest
|
1
|
+
class NetSystem::ClientPanelTest < Liza::PanelTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::ClientPanel
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :red
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# test :call do
|
13
|
+
# todo "write this"
|
14
|
+
# end
|
16
15
|
|
17
|
-
end
|
18
16
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class DatabasePanel < Liza::Panel
|
1
|
+
class NetSystem::DatabasePanel < Liza::Panel
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
3
|
+
def define key, instance
|
4
|
+
set key, instance
|
5
|
+
define_singleton_method key do
|
6
|
+
get key
|
9
7
|
end
|
10
|
-
|
11
8
|
end
|
9
|
+
|
12
10
|
end
|
@@ -1,18 +1,16 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class DatabasePanelTest < Liza::PanelTest
|
1
|
+
class NetSystem::DatabasePanelTest < Liza::PanelTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == NetSystem::DatabasePanel
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :red
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# test :call do
|
13
|
+
# todo "write this"
|
14
|
+
# end
|
16
15
|
|
17
|
-
end
|
18
16
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class WebSystem::RackCommand < Liza::Command
|
2
|
+
|
3
|
+
def self.call args
|
4
|
+
log "Called #{self}.#{__method__} with args #{args}"
|
5
|
+
new.call args
|
6
|
+
end
|
7
|
+
|
8
|
+
# instance methods
|
9
|
+
|
10
|
+
def call args
|
11
|
+
log "Called #{self}.#{__method__} with args #{args}"
|
12
|
+
|
13
|
+
strategy = nil
|
14
|
+
host = nil
|
15
|
+
port = nil
|
16
|
+
|
17
|
+
if args.any? && !args[0].include?("=")
|
18
|
+
strategy = args.shift
|
19
|
+
end
|
20
|
+
|
21
|
+
args.each do |arg|
|
22
|
+
host = arg.split("=")[1] if arg.start_with? "h="
|
23
|
+
port = arg.split("=")[1] if arg.start_with? "p="
|
24
|
+
end
|
25
|
+
|
26
|
+
log({strategy:, host:, port:})
|
27
|
+
|
28
|
+
rack_panel.call strategy, host, port
|
29
|
+
end
|
30
|
+
|
31
|
+
def rack_panel
|
32
|
+
@rack_panel ||= WebBox[:rack]
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|