lizarb 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.tool-versions +1 -0
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +7 -4
  6. data/README.md +23 -64
  7. data/README_SYSTEMS.md +80 -0
  8. data/Rakefile +3 -1
  9. data/app/dev/benches/loops_bench.rb +35 -0
  10. data/app/dev/commands/calculator_command.rb +69 -0
  11. data/app/dev/commands/calculator_command_test.rb +58 -0
  12. data/app/dev/commands/circle_command.rb +70 -0
  13. data/app/dev/commands/circle_command_test.rb +76 -0
  14. data/app/dev/commands/narrative_method_command.rb +60 -0
  15. data/app/dev/commands/narrative_method_command_test.rb +36 -0
  16. data/app/dev/commands/quadratic_command.rb +66 -0
  17. data/app/dev/commands/quadratic_command_test.rb +47 -0
  18. data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
  19. data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
  20. data/app/dev/generators/bench_generator.rb +2 -51
  21. data/app/dev/generators/command_generator/command.rb.erb +26 -0
  22. data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
  23. data/app/dev/generators/command_generator.rb +2 -35
  24. data/app/dev/generators/record_generator.rb +46 -0
  25. data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
  26. data/app/dev_box.rb +24 -4
  27. data/app/happy_box.rb +1 -1
  28. data/app/net/databases/sqlite_db_test.rb +5 -5
  29. data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
  30. data/app/net/records/app_record_test.rb +8 -0
  31. data/app/net/records/post_record.rb +4 -0
  32. data/app/net/records/post_record_test.rb +8 -0
  33. data/app/net/records/user_record.rb +4 -0
  34. data/app/net/records/user_record_test.rb +8 -0
  35. data/app/net_box.rb +7 -7
  36. data/app/web/requests/api_request.rb +8 -7
  37. data/app/web/requests/assets_request.rb +12 -13
  38. data/app/web/requests/root_request.rb +6 -7
  39. data/app/web/requests/root_request_test.rb +1 -1
  40. data/app/web_box.rb +9 -1
  41. data/exe/lrb +3 -0
  42. data/lib/app.rb +19 -15
  43. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
  44. data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
  45. data/lib/dev_system/dev/controllers/bench.rb +5 -7
  46. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
  47. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
  49. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
  51. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
  52. data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
  53. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  54. data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
  55. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
  56. data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
  57. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
  58. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
  59. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  60. data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
  61. data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
  62. data/lib/dev_system/dev/controllers/command.rb +11 -13
  63. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  64. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  65. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
  66. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  67. data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
  68. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
  69. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
  70. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
  71. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
  72. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
  73. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
  74. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
  75. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -0
  76. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -0
  77. data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
  78. data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
  79. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
  80. data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
  81. data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
  82. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
  83. data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
  84. data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
  85. data/lib/dev_system/dev/controllers/shell.rb +26 -14
  86. data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
  87. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
  88. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  89. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  90. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  91. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  92. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  93. data/lib/dev_system/dev/dev_box.rb +33 -16
  94. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  95. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  96. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  97. data/lib/dev_system/dev/panels/command_panel.rb +24 -6
  98. data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
  99. data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
  100. data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
  101. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  102. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  103. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  104. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  105. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  106. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  107. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  108. data/lib/happy_system/happy/happy_box.rb +6 -9
  109. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  110. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  111. data/lib/lerb.rb +106 -0
  112. data/lib/liza/base/box.rb +71 -26
  113. data/lib/liza/base/box_test.rb +7 -9
  114. data/lib/liza/base/controller.rb +19 -19
  115. data/lib/liza/base/controller_test.rb +7 -9
  116. data/lib/liza/base/panel.rb +40 -24
  117. data/lib/liza/base/panel_test.rb +10 -12
  118. data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
  119. data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
  120. data/lib/liza/meta/part.rb +12 -14
  121. data/lib/liza/meta/part_extension.rb +14 -11
  122. data/lib/liza/meta/part_test.rb +4 -6
  123. data/lib/liza/meta/system.rb +12 -14
  124. data/lib/liza/meta/system_test.rb +8 -10
  125. data/lib/liza/ruby_test.rb +7 -0
  126. data/lib/liza/ruby_tests/module_test.rb +21 -0
  127. data/lib/liza/ruby_tests/string_test.rb +59 -0
  128. data/lib/liza/test/test.rb +7 -8
  129. data/lib/liza/test/test_test.rb +168 -76
  130. data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
  131. data/lib/liza/test_parts/test_assertions_part.rb +81 -82
  132. data/lib/liza/test_parts/test_dsl_part.rb +44 -98
  133. data/lib/liza/test_parts/test_log_part.rb +122 -0
  134. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  135. data/lib/liza/test_parts/test_tree_part.rb +137 -0
  136. data/lib/liza/unit.rb +108 -102
  137. data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
  138. data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
  139. data/lib/liza/unit_test.rb +69 -71
  140. data/lib/liza.rb +5 -0
  141. data/lib/lizarb/ruby/module.rb +17 -0
  142. data/lib/lizarb/ruby/string.rb +10 -2
  143. data/lib/lizarb/version.rb +1 -1
  144. data/lib/lizarb.rb +24 -2
  145. data/lib/net_system/dev/net_command.rb +10 -12
  146. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  147. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  148. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  149. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  150. data/lib/net_system/net/controllers/client.rb +1 -3
  151. data/lib/net_system/net/controllers/client_test.rb +8 -10
  152. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  153. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  154. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  155. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  156. data/lib/net_system/net/controllers/database.rb +21 -23
  157. data/lib/net_system/net/controllers/database_test.rb +8 -10
  158. data/lib/net_system/net/controllers/record.rb +29 -0
  159. data/lib/net_system/net/controllers/record_test.rb +12 -0
  160. data/lib/net_system/net/net_box.rb +11 -16
  161. data/lib/net_system/net/net_box_test.rb +12 -14
  162. data/lib/net_system/net/panels/client_panel.rb +1 -3
  163. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  164. data/lib/net_system/net/panels/database_panel.rb +6 -8
  165. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  166. data/lib/web_system/dev/rack_command.rb +35 -0
  167. data/lib/web_system/dev/request_command.rb +143 -0
  168. data/lib/web_system/dev/web_command.rb +6 -39
  169. data/lib/web_system/web/controllers/rack.rb +6 -0
  170. data/lib/web_system/web/controllers/rack_test.rb +16 -0
  171. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
  172. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
  173. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
  174. data/lib/web_system/web/controllers/request.rb +1 -3
  175. data/lib/web_system/web/controllers/request_test.rb +11 -13
  176. data/lib/web_system/web/panels/rack_panel.rb +42 -0
  177. data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
  178. data/lib/web_system/web/panels/request_panel.rb +54 -37
  179. data/lib/web_system/web/panels/request_panel_test.rb +28 -9
  180. data/lib/web_system/web/web_box.rb +16 -8
  181. data/lib/web_system/web/web_box_test.rb +11 -13
  182. data/lizarb.gemspec +2 -2
  183. metadata +76 -28
  184. data/app/dev/commands/example_command.rb +0 -57
  185. data/app/dev/commands/example_command_test.rb +0 -43
  186. data/app/dev/commands/macro_child_command.rb +0 -32
  187. data/app/dev/commands/macro_child_command_test.rb +0 -7
  188. data/app/dev/commands/macro_parent_command.rb +0 -70
  189. data/app/dev/commands/macro_parent_command_test.rb +0 -7
  190. data/app/dev/commands/my_command.rb +0 -7
  191. data/app/dev/commands/my_command_test.rb +0 -7
  192. data/app/dev/generators/model_generator.rb +0 -46
  193. data/app/net/models/app_model_test.rb +0 -8
  194. data/app/net/models/post_model.rb +0 -4
  195. data/app/net/models/post_model_test.rb +0 -8
  196. data/app/net/models/user_model.rb +0 -4
  197. data/app/net/models/user_model_test.rb +0 -8
  198. data/app_new/.gitignore +0 -4
  199. data/app_new/Gemfile +0 -31
  200. data/app_new/Procfile +0 -3
  201. data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
  202. data/lib/liza/test_parts/test_context_part.rb +0 -81
  203. data/lib/net_system/net/controllers/model.rb +0 -31
  204. 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
- # https://redis.io/
5
- # https://github.com/redis/redis-rb
6
- def initialize *args
7
- args = [url: Liza.const(:net_box).clients.get(:redis_url)] if args.empty?
8
- log "Connecting to #{args}"
9
- @conn = Redis.new *args
10
- end
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
- def call cmd_name, *args
15
- t = Time.now
16
- result = @conn.send cmd_name, *args
11
+ attr_reader :conn
17
12
 
18
- result
19
- ensure
20
- log "#{t.diff}s | #{cmd_name} | #{args}"
21
- end
13
+ def call cmd_name, *args
14
+ t = Time.now
15
+ result = @conn.send cmd_name, *args
22
16
 
23
- def now
24
- call :time
25
- end
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
- def subject
5
- @subject ||= subject_class.new
6
- end
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
- test :subject do
13
- assert subject.conn.class == Redis
14
- end
7
+ test :subject_class do
8
+ assert subject_class == NetSystem::RedisClient
9
+ end
15
10
 
16
- test :call do
17
- result = subject.call :keys
18
- assert result.class == Array
19
- assert result.count == 0
20
- end
11
+ test :subject do
12
+ assert subject.conn.class == Redis
13
+ end
21
14
 
22
- test :now do
23
- result = subject.now
24
- assert result.class == Array
25
- assert result.map(&:class) == [Integer, Integer]
26
- end
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
- # 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
@@ -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
@@ -0,0 +1,12 @@
1
+ class NetSystem::RecordTest < Liza::ControllerTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == NetSystem::Record
5
+ end
6
+
7
+ test :settings do
8
+ assert subject_class.log_level == :normal
9
+ assert subject_class.log_color == :red
10
+ end
11
+
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
- # 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
+ # 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
- 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
@@ -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