lizarb 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -13
- data/Rakefile +38 -0
- data/app/dev_box.rb +26 -4
- data/app/happy_box.rb +2 -2
- 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 +9 -9
- data/app/web_box.rb +4 -4
- data/app.rb +6 -7
- data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
- data/app_global.gemfile.rb.lock +19 -0
- data/app_global.rb +4 -0
- data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
- data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
- data/app_new/dev/benches/objects_bench.rb +83 -0
- data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
- data/app_new/dev/benches/sorted_bench.rb +54 -0
- data/app_new/dev/benches/sorted_bench_test.rb +12 -0
- data/app_new/dev/benches/variables_bench.rb +55 -0
- data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
- data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
- data/{app → app_new}/dev/commands/circle_command.rb +1 -1
- data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
- data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
- data/app_new/dev_box.rb +14 -0
- data/app_new.rb +15 -0
- data/exe/lizarb +9 -1
- data/lib/app.rb +27 -95
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +23 -18
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
- data/lib/dev_system/dev/controllers/bench.rb +1 -9
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +19 -22
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +5 -31
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
- data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +37 -18
- 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.rb +9 -15
- 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 +33 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
- data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
- data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
- data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
- data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
- data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
- data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
- data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
- data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -17
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
- data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
- data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
- data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
- data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/log.rb +3 -0
- data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
- data/lib/dev_system/dev/controllers/shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +15 -11
- 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 +27 -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 +59 -18
- data/lib/dev_system/dev/panels/command_panel_test.rb +43 -20
- data/lib/dev_system/dev/panels/generator_panel.rb +73 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +46 -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 +5 -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 +95 -49
- data/lib/liza/base/box.rb +76 -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 +40 -27
- data/lib/liza/base/panel_test.rb +36 -12
- data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
- 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 +3 -3
- data/lib/liza/test/test.rb +7 -10
- data/lib/liza/test/test_test.rb +160 -157
- 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 +73 -120
- data/lib/liza/unit.rb +105 -107
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
- data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
- data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
- data/lib/liza/unit_test.rb +80 -71
- data/lib/liza.rb +10 -1
- data/lib/lizarb/ruby/module.rb +1 -1
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +247 -23
- data/lib/net_system/dev/net_command.rb +15 -17
- 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 +9 -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 +20 -18
- data/lib/web_system/dev/request_command.rb +8 -22
- 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 +53 -57
- data/lib/web_system/web/panels/request_panel_test.rb +1 -1
- data/lib/web_system/web/web_box.rb +12 -18
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +1 -1
- metadata +54 -44
- data/.ruby-version +0 -1
- data/app/dev/benches/app_bench.rb +0 -5
- data/app/dev/benches/app_bench_test.rb +0 -7
- data/app/dev/benches/loops_bench_test.rb +0 -11
- data/app/dev/commands/app_command.rb +0 -5
- data/app/dev/commands/app_command_test.rb +0 -7
- data/app/dev/commands/new_command.rb +0 -9
- data/app/dev/commands/new_command_test.rb +0 -7
- data/app/dev/generators/bench_generator.rb +0 -18
- data/app/dev/generators/command_generator/command.rb.erb +0 -26
- data/app/dev/generators/command_generator.rb +0 -18
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/exe/Gemfile.lock +0 -13
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -60
- data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -11
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -14
- data/lib/dev_system/dev/controllers/command/version_command.rb +0 -9
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -14
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -96
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -14
- /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/quadratic_command_test.rb +0 -0
@@ -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
|
@@ -1,31 +1,29 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class Record < Liza::Controller
|
1
|
+
class NetSystem::Record < 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? "Record"
|
8
|
+
raise "please rename #{sub.name} to #{sub.name}Record"
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
20
23
|
else
|
21
|
-
valid
|
22
|
-
if valid.include? database_id
|
23
|
-
set :db, database_id
|
24
|
-
else
|
25
|
-
raise "invalid db `#{database_id}`, valid options are #{valid}"
|
26
|
-
end
|
24
|
+
raise "invalid db `#{database_id}`, valid options are #{valid}"
|
27
25
|
end
|
28
26
|
end
|
29
|
-
|
30
27
|
end
|
28
|
+
|
31
29
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class RecordTest < Liza::ControllerTest
|
1
|
+
class NetSystem::RecordTest < 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::Record
|
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,20 +1,13 @@
|
|
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
|
+
# Configure your client panel per the DSL in http://guides.lizarb.org/panels/client.html
|
4
|
+
configure :client do
|
5
|
+
# set :log_level, ENV["net.client.log_level"]
|
6
|
+
end
|
18
7
|
|
8
|
+
# Configure your database panel per the DSL in http://guides.lizarb.org/panels/database.html
|
9
|
+
configure :database do
|
10
|
+
# set :log_level, ENV["net.database.log_level"]
|
19
11
|
end
|
12
|
+
|
20
13
|
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
|
@@ -1,26 +1,28 @@
|
|
1
|
-
class WebSystem
|
2
|
-
class RackCommand < Liza::Command
|
1
|
+
class WebSystem::RackCommand < Liza::Command
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def call args
|
4
|
+
log "args = #{args.inspect}"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
strategy = nil
|
7
|
+
host = nil
|
8
|
+
port = nil
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
args.each do |arg|
|
16
|
-
host = arg.split("=")[1] if arg.start_with? "h="
|
17
|
-
port = arg.split("=")[1] if arg.start_with? "p="
|
18
|
-
end
|
10
|
+
if args.any? && !args[0].include?("=")
|
11
|
+
strategy = args.shift
|
12
|
+
end
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
args.each do |arg|
|
15
|
+
host = arg.split("=")[1] if arg.start_with? "h="
|
16
|
+
port = arg.split("=")[1] if arg.start_with? "p="
|
23
17
|
end
|
24
18
|
|
19
|
+
log({strategy:, host:, port:})
|
20
|
+
|
21
|
+
rack_panel.call strategy, host, port
|
25
22
|
end
|
23
|
+
|
24
|
+
def rack_panel
|
25
|
+
@rack_panel ||= WebBox[:rack]
|
26
|
+
end
|
27
|
+
|
26
28
|
end
|