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
@@ -1,14 +1,13 @@
|
|
1
|
-
class NetSystem
|
2
|
-
class NetCommand < Liza::Command
|
1
|
+
class NetSystem::NetCommand < Liza::Command
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
log :higher, "Called #{self} with args #{args}"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
ruby_time = Time.now
|
7
|
+
redis_time = ::NetBox.databases.redis.now
|
8
|
+
sqlite_time = ::NetBox.databases.sqlite.now
|
9
|
+
# redis_time = ::RedisDb.current.now
|
10
|
+
# sqlite_time = ::SqliteDb.current.now
|
12
11
|
|
13
12
|
puts <<-OUTPUT.bold
|
14
13
|
|
@@ -17,8 +16,7 @@ class NetSystem
|
|
17
16
|
Time for Sqlite: #{sqlite_time.to_s.light_red}
|
18
17
|
|
19
18
|
OUTPUT
|
20
|
-
|
21
|
-
end
|
22
|
-
|
19
|
+
Liza::DevCommand.call []
|
23
20
|
end
|
21
|
+
|
24
22
|
end
|
@@ -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
|
@@ -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,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
|