lizarb 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -13
  3. data/Rakefile +38 -0
  4. data/app/dev_box.rb +26 -4
  5. data/app/happy_box.rb +2 -2
  6. data/app/net/databases/sqlite_db_test.rb +5 -5
  7. data/app/net/records/app_record_test.rb +1 -1
  8. data/app/net/records/post_record_test.rb +1 -1
  9. data/app/net/records/user_record_test.rb +1 -1
  10. data/app/net_box.rb +9 -9
  11. data/app/web_box.rb +4 -4
  12. data/app.rb +6 -7
  13. data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
  14. data/app_global.gemfile.rb.lock +19 -0
  15. data/app_global.rb +4 -0
  16. data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
  17. data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
  18. data/app_new/dev/benches/objects_bench.rb +83 -0
  19. data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
  20. data/app_new/dev/benches/sorted_bench.rb +54 -0
  21. data/app_new/dev/benches/sorted_bench_test.rb +12 -0
  22. data/app_new/dev/benches/variables_bench.rb +55 -0
  23. data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
  24. data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
  25. data/{app → app_new}/dev/commands/circle_command.rb +1 -1
  26. data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
  27. data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
  28. data/app_new/dev_box.rb +14 -0
  29. data/app_new.rb +15 -0
  30. data/exe/lizarb +9 -1
  31. data/lib/app.rb +27 -95
  32. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +23 -18
  33. data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
  34. data/lib/dev_system/dev/controllers/bench.rb +1 -9
  35. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  36. data/lib/dev_system/dev/controllers/command/bench_command.rb +19 -22
  37. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  38. data/lib/dev_system/dev/controllers/command/generate_command.rb +5 -31
  39. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  40. data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
  41. data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
  42. data/lib/dev_system/dev/controllers/command/not_found_command.rb +37 -18
  43. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
  44. data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
  45. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
  46. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
  47. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command.rb +9 -15
  49. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  51. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +33 -37
  52. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  53. data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
  54. data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
  55. data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
  56. data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
  57. data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
  58. data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
  59. data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
  60. data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
  61. data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
  62. data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
  63. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
  64. data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
  65. data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
  66. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -17
  67. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
  68. data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
  69. data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
  70. data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
  71. data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
  72. data/lib/dev_system/dev/controllers/log.rb +3 -0
  73. data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
  74. data/lib/dev_system/dev/controllers/shell.rb +22 -0
  75. data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
  76. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +15 -11
  77. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  78. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  79. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  80. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  81. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  82. data/lib/dev_system/dev/dev_box.rb +27 -16
  83. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  84. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  85. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  86. data/lib/dev_system/dev/panels/command_panel.rb +59 -18
  87. data/lib/dev_system/dev/panels/command_panel_test.rb +43 -20
  88. data/lib/dev_system/dev/panels/generator_panel.rb +73 -0
  89. data/lib/dev_system/dev/panels/generator_panel_test.rb +46 -0
  90. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  91. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  92. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  93. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  94. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  95. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  96. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  97. data/lib/happy_system/happy/happy_box.rb +5 -9
  98. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  99. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  100. data/lib/lerb.rb +95 -49
  101. data/lib/liza/base/box.rb +76 -26
  102. data/lib/liza/base/box_test.rb +7 -9
  103. data/lib/liza/base/controller.rb +19 -21
  104. data/lib/liza/base/controller_test.rb +7 -9
  105. data/lib/liza/base/panel.rb +40 -27
  106. data/lib/liza/base/panel_test.rb +36 -12
  107. data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
  108. data/lib/liza/meta/part.rb +12 -14
  109. data/lib/liza/meta/part_extension.rb +14 -16
  110. data/lib/liza/meta/part_test.rb +4 -6
  111. data/lib/liza/meta/system.rb +12 -14
  112. data/lib/liza/meta/system_test.rb +8 -10
  113. data/lib/liza/ruby_test.rb +4 -6
  114. data/lib/liza/ruby_tests/module_test.rb +3 -3
  115. data/lib/liza/test/test.rb +7 -10
  116. data/lib/liza/test/test_test.rb +160 -157
  117. data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
  118. data/lib/liza/test_parts/test_assertions_part.rb +81 -83
  119. data/lib/liza/test_parts/test_dsl_part.rb +47 -49
  120. data/lib/liza/test_parts/test_log_part.rb +88 -90
  121. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  122. data/lib/liza/test_parts/test_tree_part.rb +73 -120
  123. data/lib/liza/unit.rb +105 -107
  124. data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
  125. data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
  126. data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
  127. data/lib/liza/unit_test.rb +80 -71
  128. data/lib/liza.rb +10 -1
  129. data/lib/lizarb/ruby/module.rb +1 -1
  130. data/lib/lizarb/version.rb +1 -1
  131. data/lib/lizarb.rb +247 -23
  132. data/lib/net_system/dev/net_command.rb +15 -17
  133. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  134. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  135. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  136. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  137. data/lib/net_system/net/controllers/client.rb +1 -3
  138. data/lib/net_system/net/controllers/client_test.rb +8 -10
  139. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  140. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  141. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  142. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  143. data/lib/net_system/net/controllers/database.rb +21 -23
  144. data/lib/net_system/net/controllers/database_test.rb +8 -10
  145. data/lib/net_system/net/controllers/record.rb +21 -23
  146. data/lib/net_system/net/controllers/record_test.rb +8 -10
  147. data/lib/net_system/net/net_box.rb +9 -16
  148. data/lib/net_system/net/net_box_test.rb +12 -14
  149. data/lib/net_system/net/panels/client_panel.rb +1 -3
  150. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  151. data/lib/net_system/net/panels/database_panel.rb +6 -8
  152. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  153. data/lib/web_system/dev/rack_command.rb +20 -18
  154. data/lib/web_system/dev/request_command.rb +8 -22
  155. data/lib/web_system/dev/web_command.rb +6 -8
  156. data/lib/web_system/web/controllers/rack.rb +4 -6
  157. data/lib/web_system/web/controllers/rack_test.rb +11 -13
  158. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
  159. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
  160. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
  161. data/lib/web_system/web/controllers/request.rb +1 -3
  162. data/lib/web_system/web/controllers/request_test.rb +11 -13
  163. data/lib/web_system/web/panels/rack_panel.rb +37 -39
  164. data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
  165. data/lib/web_system/web/panels/request_panel.rb +53 -57
  166. data/lib/web_system/web/panels/request_panel_test.rb +1 -1
  167. data/lib/web_system/web/web_box.rb +12 -18
  168. data/lib/web_system/web/web_box_test.rb +11 -13
  169. data/lizarb.gemspec +1 -1
  170. metadata +54 -44
  171. data/.ruby-version +0 -1
  172. data/app/dev/benches/app_bench.rb +0 -5
  173. data/app/dev/benches/app_bench_test.rb +0 -7
  174. data/app/dev/benches/loops_bench_test.rb +0 -11
  175. data/app/dev/commands/app_command.rb +0 -5
  176. data/app/dev/commands/app_command_test.rb +0 -7
  177. data/app/dev/commands/new_command.rb +0 -9
  178. data/app/dev/commands/new_command_test.rb +0 -7
  179. data/app/dev/generators/bench_generator.rb +0 -18
  180. data/app/dev/generators/command_generator/command.rb.erb +0 -26
  181. data/app/dev/generators/command_generator.rb +0 -18
  182. data/app_new/.gitignore +0 -4
  183. data/app_new/Gemfile +0 -31
  184. data/app_new/Procfile +0 -3
  185. data/exe/Gemfile.lock +0 -13
  186. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -60
  187. data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -11
  188. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -14
  189. data/lib/dev_system/dev/controllers/command/version_command.rb +0 -9
  190. data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -14
  191. data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -96
  192. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -14
  193. /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
  194. /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
  195. /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
  196. /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
- # https://www.sqlite.org/
5
- # https://github.com/sparklemotion/sqlite3-ruby
6
- def initialize *args
7
- args = [Liza.const(:net_box).clients.get(:sqlite)] if args.empty?
8
- log "Connecting to #{args}"
9
- @conn = SQLite3::Database.new *args
10
- end
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
- def call sql, *args
15
- t = Time.now
16
- result = @conn.execute2 sql, *args
11
+ attr_reader :conn
17
12
 
18
- result
19
- ensure
20
- log "#{t.diff}s | #{sql} | #{args}"
21
- end
13
+ def call sql, *args
14
+ t = Time.now
15
+ result = @conn.execute2 sql, *args
22
16
 
23
- def now
24
- call "SELECT strftime('%Y-%m-%dT%H:%M:%S.%f', 'now', 'localtime');"
25
- end
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
- def subject
5
- @subject ||= subject_class.new ":memory:"
6
- end
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
- test :subject do
13
- assert subject.conn.class == SQLite3::Database
14
- end
7
+ test :subject_class do
8
+ assert subject_class == NetSystem::SqliteClient
9
+ end
15
10
 
16
- test :call do
17
- result = subject.call "SELECT name, sql FROM sqlite_master WHERE type = 'table';"
18
- assert result == [["name", "sql"]]
19
- end
11
+ test :subject do
12
+ assert subject.conn.class == SQLite3::Database
13
+ end
20
14
 
21
- test :now do
22
- result = subject.now
23
- assert result.class == Array
24
- assert result[0] == ["strftime('%Y-%m-%dT%H:%M:%S.%f', 'now', 'localtime')"]
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,5 +1,3 @@
1
- class NetSystem
2
- class Client < Liza::Controller
1
+ class NetSystem::Client < Liza::Controller
3
2
 
4
- end
5
3
  end
@@ -1,14 +1,12 @@
1
- class NetSystem
2
- class ClientTest < Liza::ControllerTest
1
+ class NetSystem::ClientTest < Liza::ControllerTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == NetSystem::Client
6
- end
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
- class RedisDb < Database
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
- test :subject_class do
5
- assert subject_class == NetSystem::RedisDb
6
- end
3
+ test :subject_class do
4
+ assert subject_class == NetSystem::RedisDb
5
+ end
7
6
 
8
- test :subject do
9
- assert subject.client.class == NetSystem::RedisClient
10
- end
7
+ test :subject do
8
+ assert subject.client.class == NetSystem::RedisClient
9
+ end
11
10
 
12
- test :now do
13
- t = subject.now
14
- assert! t.is_a? Time
15
- assert t.yday == Time.now.yday
16
- end
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
- # test :call do
19
- # todo "write this"
20
- # end
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
- class SqliteDb < Database
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
- test :subject_class do
5
- assert subject_class == NetSystem::SqliteDb
6
- end
3
+ test :subject_class do
4
+ assert subject_class == NetSystem::SqliteDb
5
+ end
7
6
 
8
- test :subject do
9
- assert subject.client.class == NetSystem::SqliteClient
10
- end
7
+ test :subject do
8
+ assert subject.client.class == NetSystem::SqliteClient
9
+ end
11
10
 
12
- test :now do
13
- t = subject.now
14
- assert! t.is_a? Time
15
- assert t.yday == Time.now.yday
16
- end
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
- # test :call do
19
- # todo "write this"
20
- # end
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
- def self.inherited sub
5
- super
3
+ def self.inherited sub
4
+ super
6
5
 
7
- return if sub.name.nil?
8
- return if sub.name.end_with? "Db"
9
- raise "please rename #{sub.name} to #{sub.name}Db"
10
- end
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
- attr_reader :client
11
+ attr_reader :client
13
12
 
14
- def initialize client: get(:client).new
15
- @client = client
16
- end
13
+ def initialize client: get(:client).new
14
+ @client = client
15
+ end
17
16
 
18
- def self.set_client client_id
19
- set :client, Liza.const("#{client_id}_client")
20
- end
17
+ def self.set_client client_id
18
+ set :client, Liza.const("#{client_id}_client")
19
+ end
21
20
 
22
- def self.current
23
- Thread.current[last_namespace] ||= begin
24
- log "Connecting to #{last_namespace}"
25
- new
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
- def self.call(...); current.call(...); end
30
- def call(...); @client.call(...); end
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
- test :subject_class do
5
- assert subject_class == NetSystem::Database
6
- end
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
- def self.inherited sub
5
- super
3
+ def self.inherited sub
4
+ super
6
5
 
7
- return if sub.name.nil?
8
- return if sub.name.end_with? "Record"
9
- raise "please rename #{sub.name} to #{sub.name}Record"
10
- end
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
- def self.db database_id = nil
13
- if database_id.nil?
14
- db = get :db
15
- if db
16
- Liza.const(:NetBox).databases.get db
17
- else
18
- raise "please set a db to record #{self}"
19
- end
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 = Liza.const(:NetBox).databases.settings.keys
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
- test :subject_class do
5
- assert subject_class == NetSystem::Record
6
- end
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
- # Set up your client panel per the DSL in http://guides.lizarb.org/panels/client.html
7
- clients do
8
- # set :log_level, ENV["net.client.log_level"]
9
- end
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
- test :subject_class do
5
- assert subject_class == NetSystem::NetBox
6
- end
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
- test :panels do
14
- assert subject_class.clients.is_a? ClientPanel
15
- assert subject_class.databases.is_a? DatabasePanel
16
- end
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,5 +1,3 @@
1
- class NetSystem
2
- class ClientPanel < Liza::Panel
1
+ class NetSystem::ClientPanel < Liza::Panel
3
2
 
4
- end
5
3
  end
@@ -1,18 +1,16 @@
1
- class NetSystem
2
- class ClientPanelTest < Liza::PanelTest
1
+ class NetSystem::ClientPanelTest < Liza::PanelTest
3
2
 
4
- test :subject_class do
5
- assert subject_class == NetSystem::ClientPanel
6
- end
3
+ test :subject_class do
4
+ assert subject_class == NetSystem::ClientPanel
5
+ end
7
6
 
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :red
11
- end
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :red
10
+ end
12
11
 
13
- # test :call do
14
- # todo "write this"
15
- # end
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
- def define key, instance
5
- set key, instance
6
- define_singleton_method key do
7
- get key
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
- test :subject_class do
5
- assert subject_class == NetSystem::DatabasePanel
6
- end
3
+ test :subject_class do
4
+ assert subject_class == NetSystem::DatabasePanel
5
+ end
7
6
 
8
- test :settings do
9
- assert subject_class.log_level == :normal
10
- assert subject_class.log_color == :red
11
- end
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :red
10
+ end
12
11
 
13
- # test :call do
14
- # todo "write this"
15
- # end
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
- def self.call args
5
- log "args #{args}"
3
+ def call args
4
+ log "args = #{args.inspect}"
6
5
 
7
- strategy = nil
8
- host = nil
9
- port = nil
6
+ strategy = nil
7
+ host = nil
8
+ port = nil
10
9
 
11
- if args.any? && !args[0].include?("=")
12
- strategy = args.shift
13
- end
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
- log({strategy:, host:, port:})
21
-
22
- Liza.const(:web_box).rack.call strategy, host, port
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