lizarb 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) 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/net/{models/app_model.rb → records/app_record.rb} +2 -1
  27. data/app/net/{models/post_model_test.rb → records/app_record_test.rb} +2 -2
  28. data/app/net/records/post_record.rb +4 -0
  29. data/app/net/{models/app_model_test.rb → records/post_record_test.rb} +2 -2
  30. data/app/net/records/user_record.rb +4 -0
  31. data/app/net/{models/user_model_test.rb → records/user_record_test.rb} +2 -2
  32. data/app/web/requests/api_request.rb +8 -7
  33. data/app/web/requests/assets_request.rb +12 -13
  34. data/app/web/requests/root_request.rb +6 -7
  35. data/app/web/requests/root_request_test.rb +1 -1
  36. data/app/web_box.rb +8 -0
  37. data/app_new/Procfile +1 -1
  38. data/exe/lrb +3 -0
  39. data/lib/app.rb +18 -14
  40. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +29 -0
  41. data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +14 -0
  42. data/lib/dev_system/dev/controllers/command/bench_command.rb +11 -1
  43. data/lib/dev_system/dev/controllers/command/generate_command.rb +14 -2
  44. data/lib/dev_system/dev/controllers/command/not_found_command.rb +29 -0
  45. data/lib/dev_system/dev/controllers/command/{dev_command_test.rb → not_found_command_test.rb} +2 -2
  46. data/lib/dev_system/dev/controllers/command/{dev_command.rb → terminal_command.rb} +1 -1
  47. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +14 -0
  48. data/lib/dev_system/dev/controllers/command/test_command.rb +6 -2
  49. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +1 -1
  50. data/lib/dev_system/dev/controllers/generators/app_generator.rb +30 -5
  51. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
  52. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
  53. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
  54. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
  55. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
  56. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
  57. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +29 -0
  58. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +14 -0
  59. data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
  60. data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
  61. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
  62. data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
  63. data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
  64. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
  65. data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
  66. data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
  67. data/lib/dev_system/dev/controllers/shell.rb +26 -14
  68. data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
  69. data/lib/dev_system/dev/panels/command_panel.rb +21 -1
  70. data/lib/dev_system/dev/panels/log_panel.rb +1 -1
  71. data/lib/lerb.rb +106 -0
  72. data/lib/liza/base/controller.rb +2 -0
  73. data/lib/liza/base/panel.rb +6 -5
  74. data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
  75. data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
  76. data/lib/liza/meta/part_extension.rb +6 -1
  77. data/lib/liza/ruby_test.rb +9 -0
  78. data/lib/liza/ruby_tests/module_test.rb +21 -0
  79. data/lib/liza/ruby_tests/string_test.rb +59 -0
  80. data/lib/liza/test/test.rb +3 -1
  81. data/lib/liza/test/test_test.rb +108 -15
  82. data/lib/liza/test_parts/test_assertions_advanced_part.rb +127 -0
  83. data/lib/liza/test_parts/test_assertions_part.rb +7 -6
  84. data/lib/liza/test_parts/test_dsl_part.rb +37 -89
  85. data/lib/liza/test_parts/test_log_part.rb +124 -0
  86. data/lib/liza/test_parts/test_tree_part.rb +139 -0
  87. data/lib/liza/unit.rb +2 -0
  88. data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
  89. data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
  90. data/lib/liza.rb +5 -0
  91. data/lib/lizarb/ruby/module.rb +17 -0
  92. data/lib/lizarb/ruby/string.rb +10 -2
  93. data/lib/lizarb/version.rb +1 -1
  94. data/lib/lizarb.rb +24 -2
  95. data/lib/net_system/net/controllers/record.rb +31 -0
  96. data/lib/net_system/net/controllers/{model_test.rb → record_test.rb} +2 -2
  97. data/lib/web_system/dev/rack_command.rb +26 -0
  98. data/lib/web_system/dev/request_command.rb +143 -0
  99. data/lib/web_system/dev/web_command.rb +3 -34
  100. data/lib/web_system/web/controllers/rack.rb +8 -0
  101. data/lib/web_system/web/controllers/rack_test.rb +18 -0
  102. data/lib/web_system/web/controllers/request/client_error_request.rb +0 -1
  103. data/lib/web_system/web/controllers/request/not_found_request.rb +0 -1
  104. data/lib/web_system/web/controllers/request/server_error_request.rb +0 -1
  105. data/lib/web_system/web/panels/rack_panel.rb +44 -0
  106. data/lib/web_system/web/panels/rack_panel_test.rb +14 -0
  107. data/lib/web_system/web/panels/request_panel.rb +51 -32
  108. data/lib/web_system/web/panels/request_panel_test.rb +28 -9
  109. data/lib/web_system/web/web_box.rb +12 -0
  110. data/lizarb.gemspec +2 -2
  111. metadata +68 -25
  112. data/app/dev/commands/example_command.rb +0 -57
  113. data/app/dev/commands/example_command_test.rb +0 -43
  114. data/app/dev/commands/macro_child_command.rb +0 -32
  115. data/app/dev/commands/macro_child_command_test.rb +0 -7
  116. data/app/dev/commands/macro_parent_command.rb +0 -70
  117. data/app/dev/commands/macro_parent_command_test.rb +0 -7
  118. data/app/dev/commands/my_command.rb +0 -7
  119. data/app/dev/commands/my_command_test.rb +0 -7
  120. data/app/dev/generators/model_generator.rb +0 -46
  121. data/app/net/models/post_model.rb +0 -4
  122. data/app/net/models/user_model.rb +0 -4
  123. data/lib/liza/test_parts/test_context_part.rb +0 -81
  124. data/lib/net_system/net/controllers/model.rb +0 -31
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lizarb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Pinto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-28 00:00:00.000000000 Z
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -70,18 +70,21 @@ description: Liza is a light, experimental framework primarily developed to help
70
70
  the Ruby language and the Ruby ecosystem.
71
71
  email: thiagopintodev@gmail.com
72
72
  executables:
73
+ - lrb
73
74
  - liza
74
75
  - lizarb
75
76
  extensions: []
76
77
  extra_rdoc_files: []
77
78
  files:
78
79
  - ".ruby-version"
80
+ - ".tool-versions"
79
81
  - CHANGELOG.md
80
82
  - CODE_OF_CONDUCT.md
81
83
  - Gemfile
82
84
  - Gemfile.lock
83
85
  - LICENSE.txt
84
86
  - README.md
87
+ - README_SYSTEMS.md
85
88
  - Rakefile
86
89
  - app.code.env
87
90
  - app.env
@@ -92,22 +95,26 @@ files:
92
95
  - app/dev/benches/loops_bench_test.rb
93
96
  - app/dev/commands/app_command.rb
94
97
  - app/dev/commands/app_command_test.rb
95
- - app/dev/commands/example_command.rb
96
- - app/dev/commands/example_command_test.rb
97
- - app/dev/commands/macro_child_command.rb
98
- - app/dev/commands/macro_child_command_test.rb
99
- - app/dev/commands/macro_parent_command.rb
100
- - app/dev/commands/macro_parent_command_test.rb
101
- - app/dev/commands/my_command.rb
102
- - app/dev/commands/my_command_test.rb
98
+ - app/dev/commands/calculator_command.rb
99
+ - app/dev/commands/calculator_command_test.rb
100
+ - app/dev/commands/circle_command.rb
101
+ - app/dev/commands/circle_command_test.rb
102
+ - app/dev/commands/narrative_method_command.rb
103
+ - app/dev/commands/narrative_method_command_test.rb
103
104
  - app/dev/commands/new_command.rb
104
105
  - app/dev/commands/new_command_test.rb
106
+ - app/dev/commands/quadratic_command.rb
107
+ - app/dev/commands/quadratic_command_test.rb
105
108
  - app/dev/generators/bench_generator.rb
109
+ - app/dev/generators/bench_generator/bench.rb.erb
110
+ - app/dev/generators/bench_generator/bench_test.rb.erb
106
111
  - app/dev/generators/bench_generator_test.rb
107
112
  - app/dev/generators/command_generator.rb
113
+ - app/dev/generators/command_generator/command.rb.erb
114
+ - app/dev/generators/command_generator/command_test.rb.erb
108
115
  - app/dev/generators/command_generator_test.rb
109
- - app/dev/generators/model_generator.rb
110
- - app/dev/generators/model_generator_test.rb
116
+ - app/dev/generators/record_generator.rb
117
+ - app/dev/generators/record_generator_test.rb
111
118
  - app/dev/generators/request_generator.rb
112
119
  - app/dev/generators/request_generator_test.rb
113
120
  - app/dev_box.rb
@@ -117,12 +124,12 @@ files:
117
124
  - app/net/databases/redis_db_test.rb
118
125
  - app/net/databases/sqlite_db.rb
119
126
  - app/net/databases/sqlite_db_test.rb
120
- - app/net/models/app_model.rb
121
- - app/net/models/app_model_test.rb
122
- - app/net/models/post_model.rb
123
- - app/net/models/post_model_test.rb
124
- - app/net/models/user_model.rb
125
- - app/net/models/user_model_test.rb
127
+ - app/net/records/app_record.rb
128
+ - app/net/records/app_record_test.rb
129
+ - app/net/records/post_record.rb
130
+ - app/net/records/post_record_test.rb
131
+ - app/net/records/user_record.rb
132
+ - app/net/records/user_record_test.rb
126
133
  - app/net_box.rb
127
134
  - app/web/requests/api_request.rb
128
135
  - app/web/requests/api_request_test.rb
@@ -140,20 +147,25 @@ files:
140
147
  - exe/Gemfile.lock
141
148
  - exe/liza
142
149
  - exe/lizarb
150
+ - exe/lrb
143
151
  - lib/app.rb
144
152
  - lib/dev_system.rb
145
153
  - lib/dev_system/dev/controllers/bench.rb
154
+ - lib/dev_system/dev/controllers/bench/not_found_bench.rb
155
+ - lib/dev_system/dev/controllers/bench/not_found_bench_test.rb
146
156
  - lib/dev_system/dev/controllers/bench_dsl_main_part.rb
147
157
  - lib/dev_system/dev/controllers/bench_test.rb
148
158
  - lib/dev_system/dev/controllers/command.rb
149
159
  - lib/dev_system/dev/controllers/command/bench_command.rb
150
160
  - lib/dev_system/dev/controllers/command/bench_command_test.rb
151
- - lib/dev_system/dev/controllers/command/dev_command.rb
152
- - lib/dev_system/dev/controllers/command/dev_command_test.rb
153
161
  - lib/dev_system/dev/controllers/command/echo_command.rb
154
162
  - lib/dev_system/dev/controllers/command/echo_command_test.rb
155
163
  - lib/dev_system/dev/controllers/command/generate_command.rb
156
164
  - lib/dev_system/dev/controllers/command/generate_command_test.rb
165
+ - lib/dev_system/dev/controllers/command/not_found_command.rb
166
+ - lib/dev_system/dev/controllers/command/not_found_command_test.rb
167
+ - lib/dev_system/dev/controllers/command/terminal_command.rb
168
+ - lib/dev_system/dev/controllers/command/terminal_command_test.rb
157
169
  - lib/dev_system/dev/controllers/command/test_command.rb
158
170
  - lib/dev_system/dev/controllers/command/test_command_test.rb
159
171
  - lib/dev_system/dev/controllers/command/version_command.rb
@@ -164,9 +176,23 @@ files:
164
176
  - lib/dev_system/dev/controllers/generator_test.rb
165
177
  - lib/dev_system/dev/controllers/generators/app_generator.rb
166
178
  - lib/dev_system/dev/controllers/generators/app_generator_test.rb
179
+ - lib/dev_system/dev/controllers/generators/generator_generator.rb
180
+ - lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb
181
+ - lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb
182
+ - lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb
183
+ - lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb
184
+ - lib/dev_system/dev/controllers/generators/generator_generator_test.rb
185
+ - lib/dev_system/dev/controllers/generators/not_found_generator.rb
186
+ - lib/dev_system/dev/controllers/generators/not_found_generator_test.rb
167
187
  - lib/dev_system/dev/controllers/shell.rb
188
+ - lib/dev_system/dev/controllers/shell/bin_shell.rb
189
+ - lib/dev_system/dev/controllers/shell/bin_shell_test.rb
190
+ - lib/dev_system/dev/controllers/shell/dir_shell.rb
191
+ - lib/dev_system/dev/controllers/shell/dir_shell_test.rb
168
192
  - lib/dev_system/dev/controllers/shell/file_shell.rb
169
193
  - lib/dev_system/dev/controllers/shell/file_shell_test.rb
194
+ - lib/dev_system/dev/controllers/shell/text_shell.rb
195
+ - lib/dev_system/dev/controllers/shell/text_shell_test.rb
170
196
  - lib/dev_system/dev/controllers/shell_test.rb
171
197
  - lib/dev_system/dev/controllers/terminal.rb
172
198
  - lib/dev_system/dev/controllers/terminal/irb_terminal.rb
@@ -186,6 +212,7 @@ files:
186
212
  - lib/happy_system/happy/happy_box.rb
187
213
  - lib/happy_system/happy/happy_box_test.rb
188
214
  - lib/happy_system/happy/panels/axo_panel.rb
215
+ - lib/lerb.rb
189
216
  - lib/liza.rb
190
217
  - lib/liza/base/box.rb
191
218
  - lib/liza/base/box_test.rb
@@ -193,21 +220,31 @@ files:
193
220
  - lib/liza/base/controller_test.rb
194
221
  - lib/liza/base/panel.rb
195
222
  - lib/liza/base/panel_test.rb
223
+ - lib/liza/base_parts/controller_renderer_part.rb
224
+ - lib/liza/base_parts/controller_renderer_part_test.rb
196
225
  - lib/liza/meta/part.rb
197
226
  - lib/liza/meta/part_extension.rb
198
227
  - lib/liza/meta/part_test.rb
199
228
  - lib/liza/meta/system.rb
200
229
  - lib/liza/meta/system_test.rb
230
+ - lib/liza/ruby_test.rb
231
+ - lib/liza/ruby_tests/module_test.rb
232
+ - lib/liza/ruby_tests/string_test.rb
201
233
  - lib/liza/test/test.rb
202
234
  - lib/liza/test/test_test.rb
235
+ - lib/liza/test_parts/test_assertions_advanced_part.rb
203
236
  - lib/liza/test_parts/test_assertions_part.rb
204
- - lib/liza/test_parts/test_context_part.rb
205
237
  - lib/liza/test_parts/test_dsl_part.rb
238
+ - lib/liza/test_parts/test_log_part.rb
206
239
  - lib/liza/test_parts/test_subject_part.rb
240
+ - lib/liza/test_parts/test_tree_part.rb
207
241
  - lib/liza/unit.rb
242
+ - lib/liza/unit_parts/unit_procedure_part.rb
243
+ - lib/liza/unit_parts/unit_procedure_part_test.rb
208
244
  - lib/liza/unit_test.rb
209
245
  - lib/lizarb.rb
210
246
  - lib/lizarb/ruby/class.rb
247
+ - lib/lizarb/ruby/module.rb
211
248
  - lib/lizarb/ruby/proc.rb
212
249
  - lib/lizarb/ruby/string.rb
213
250
  - lib/lizarb/ruby/time.rb
@@ -226,8 +263,8 @@ files:
226
263
  - lib/net_system/net/controllers/database/sqlite_db.rb
227
264
  - lib/net_system/net/controllers/database/sqlite_db_test.rb
228
265
  - lib/net_system/net/controllers/database_test.rb
229
- - lib/net_system/net/controllers/model.rb
230
- - lib/net_system/net/controllers/model_test.rb
266
+ - lib/net_system/net/controllers/record.rb
267
+ - lib/net_system/net/controllers/record_test.rb
231
268
  - lib/net_system/net/net_box.rb
232
269
  - lib/net_system/net/net_box_test.rb
233
270
  - lib/net_system/net/panels/client_panel.rb
@@ -235,12 +272,18 @@ files:
235
272
  - lib/net_system/net/panels/database_panel.rb
236
273
  - lib/net_system/net/panels/database_panel_test.rb
237
274
  - lib/web_system.rb
275
+ - lib/web_system/dev/rack_command.rb
276
+ - lib/web_system/dev/request_command.rb
238
277
  - lib/web_system/dev/web_command.rb
278
+ - lib/web_system/web/controllers/rack.rb
279
+ - lib/web_system/web/controllers/rack_test.rb
239
280
  - lib/web_system/web/controllers/request.rb
240
281
  - lib/web_system/web/controllers/request/client_error_request.rb
241
282
  - lib/web_system/web/controllers/request/not_found_request.rb
242
283
  - lib/web_system/web/controllers/request/server_error_request.rb
243
284
  - lib/web_system/web/controllers/request_test.rb
285
+ - lib/web_system/web/panels/rack_panel.rb
286
+ - lib/web_system/web/panels/rack_panel_test.rb
244
287
  - lib/web_system/web/panels/request_panel.rb
245
288
  - lib/web_system/web/panels/request_panel_test.rb
246
289
  - lib/web_system/web/web_box.rb
@@ -266,14 +309,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
309
  requirements:
267
310
  - - ">="
268
311
  - !ruby/object:Gem::Version
269
- version: 3.1.0
312
+ version: 3.2.0
270
313
  required_rubygems_version: !ruby/object:Gem::Requirement
271
314
  requirements:
272
315
  - - ">="
273
316
  - !ruby/object:Gem::Version
274
317
  version: '0'
275
318
  requirements: []
276
- rubygems_version: 3.3.7
319
+ rubygems_version: 3.4.1
277
320
  signing_key:
278
321
  specification_version: 4
279
322
  summary: Application Framework
@@ -1,57 +0,0 @@
1
- class ExampleCommand < AppCommand
2
-
3
- def self.call(args)
4
- log :higher, "Called #{self}.#{__method__} with args #{args}"
5
-
6
- class_helper_method_1(args)
7
- class_helper_method_2(args)
8
- class_helper_method_3(args)
9
-
10
- command = new(args)
11
- command.helper_method_1(args)
12
- command.helper_method_2(args)
13
- command.helper_method_3(args)
14
- end
15
-
16
- #
17
-
18
- def self.class_helper_method_1(args)
19
- log :higher, "Called #{self}.#{__method__} with args #{args}"
20
- 1
21
- end
22
-
23
- def self.class_helper_method_2(args)
24
- log :higher, "Called #{self}.#{__method__} with args #{args}"
25
- 2
26
- end
27
-
28
- def self.class_helper_method_3(args)
29
- log :higher, "Called #{self}.#{__method__} with args #{args}"
30
- 3
31
- end
32
-
33
- #
34
-
35
- def initialize(args)
36
- log :higher, "Called #{self}.#{__method__} with args #{args}"
37
- @init_args = args
38
- end
39
-
40
- #
41
-
42
- def helper_method_1(args)
43
- log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
44
- @init_args[0]
45
- end
46
-
47
- def helper_method_2(args)
48
- log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
49
- @init_args[1]
50
- end
51
-
52
- def helper_method_3(args)
53
- log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
54
- @init_args[2]
55
- end
56
-
57
- end
@@ -1,43 +0,0 @@
1
- class ExampleCommandTest < AppCommandTest
2
-
3
- test :subject_class do
4
- assert subject_class == ExampleCommand
5
- end
6
-
7
- group "class methods" do
8
-
9
- test :class_helper_method_1 do
10
- assert subject_class.class_helper_method_1([]) == 1
11
- end
12
-
13
- test :class_helper_method_2 do
14
- assert subject_class.class_helper_method_2([]) == 2
15
- end
16
-
17
- test :class_helper_method_3 do
18
- assert subject_class.class_helper_method_3([]) == 3
19
- end
20
-
21
- end
22
-
23
- group "instance methods" do
24
-
25
- before do
26
- @subject = subject_class.new([1, 2, 3])
27
- end
28
-
29
- test :helper_method_1 do
30
- assert @subject.helper_method_1([]) == 1
31
- end
32
-
33
- test :helper_method_2 do
34
- assert @subject.helper_method_2([]) == 2
35
- end
36
-
37
- test :helper_method_3 do
38
- assert @subject.helper_method_3([]) == 3
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,32 +0,0 @@
1
- class MacroChildCommand < MacroParentCommand
2
-
3
- class_macro_method_1 :important_thing
4
- class_macro_method_2 :other_thing
5
- class_macro_method_3 :other_important_thing
6
- class_macro_method_4 :ruby_is_awesome
7
-
8
- #
9
-
10
- def call(args)
11
- log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
12
-
13
- if @@class_macro_3
14
- @result << :YES_from_instance_call
15
- else
16
- @result << :NO_from_instance_call
17
- end
18
-
19
- @result << helper_method(args)
20
- end
21
-
22
- def helper_method(args)
23
- log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
24
-
25
- if @@class_macro_4
26
- :Yes_from_helper_method
27
- else
28
- :No_from_helper_method
29
- end
30
- end
31
-
32
- end
@@ -1,7 +0,0 @@
1
- class MacroChildCommandTest < AppCommandTest
2
-
3
- test :subject_class do
4
- assert subject_class == MacroChildCommand
5
- end
6
-
7
- end
@@ -1,70 +0,0 @@
1
- class MacroParentCommand < AppCommand
2
-
3
- def self.class_macro_method_1(arg)
4
- log :higher, "Called #{self}.#{__method__} with arg #{arg}"
5
- @@class_macro_1 = arg
6
- end
7
-
8
- def self.class_macro_method_2(arg)
9
- log :higher, "Called #{self}.#{__method__} with arg #{arg}"
10
- @@class_macro_2 = arg
11
- end
12
-
13
- def self.class_macro_method_3(arg)
14
- log :higher, "Called #{self}.#{__method__} with arg #{arg}"
15
- @@class_macro_3 = arg
16
- end
17
-
18
- def self.class_macro_method_4(arg)
19
- log :higher, "Called #{self}.#{__method__} with arg #{arg}"
20
- @@class_macro_4 = arg
21
- end
22
-
23
- #
24
-
25
- def self.call(args)
26
- log :higher, "Called #{self}.#{__method__} with args #{args}"
27
-
28
- if @@class_macro_1
29
- args << :yes_from_class_call
30
- else
31
- args << :no_from_class_call
32
- end
33
-
34
- command = new(args)
35
- result = command.call(args)
36
-
37
- puts <<-OUTPUT
38
-
39
- self: #{self}
40
- args: #{args}
41
- command: #{command}
42
- result: #{result}
43
-
44
- OUTPUT
45
- end
46
-
47
- #
48
-
49
- attr_reader :result
50
-
51
- def initialize(args)
52
- log :higher, "Called #{self}.#{__method__} with args #{args}"
53
- @init_args = args
54
-
55
- @result = [args]
56
-
57
- if @@class_macro_2
58
- @result << :yes_from_initialize
59
- else
60
- @result << :no_from_initialize
61
- end
62
- end
63
-
64
- #
65
-
66
- def call(args)
67
- raise NotImplementedError, "implement this on MacroChildCommand"
68
- end
69
-
70
- end
@@ -1,7 +0,0 @@
1
- class MacroParentCommandTest < AppCommandTest
2
-
3
- test :subject_class do
4
- assert subject_class == MacroParentCommand
5
- end
6
-
7
- end
@@ -1,7 +0,0 @@
1
- class MyCommand < AppCommand
2
-
3
- def self.call args
4
- log :higher, "Called #{self}.#{__method__} with args #{args}"
5
- end
6
-
7
- end
@@ -1,7 +0,0 @@
1
- class MyCommandTest < AppCommandTest
2
-
3
- test :subject_class do
4
- assert subject_class == MyCommand
5
- end
6
-
7
- end
@@ -1,46 +0,0 @@
1
- class ModelGenerator < Liza::Generator
2
- main_dsl
3
-
4
- FOLDER = "app/net/models"
5
-
6
- generate :controller do
7
- folder FOLDER
8
- filename "#{name}_model.rb"
9
- content model_content name
10
- end
11
-
12
- generate :controller_test do
13
- folder FOLDER
14
- filename "#{name}_model_test.rb"
15
- content model_test_content name
16
- end
17
-
18
- # helper methods
19
-
20
- def model_content name
21
- <<~CODE
22
- class #{name.camelize}Model < AppModel
23
- set :table, :#{name}s
24
-
25
- end
26
- CODE
27
- end
28
-
29
- def model_test_content name
30
- <<~CODE
31
- class #{name.camelize}ModelTest < Liza::ModelTest
32
-
33
- test :subject_class do
34
- assert subject_class == #{name.camelize}Model
35
- end
36
-
37
- test :settings do
38
- assert subject_class.log_level == :normal
39
- assert subject_class.log_color == :red
40
- end
41
-
42
- end
43
- CODE
44
- end
45
-
46
- end
@@ -1,4 +0,0 @@
1
- class PostModel < AppModel
2
- set :table, :posts
3
-
4
- end
@@ -1,4 +0,0 @@
1
- class UserModel < AppModel
2
- set :table, :users
3
-
4
- end
@@ -1,81 +0,0 @@
1
- module Liza
2
- class TestContextPart < Part
3
-
4
- insertion do
5
- def self.context
6
- @context ||= Liza::TestContextPart::Extension.new self
7
- end
8
-
9
- def self.before &block
10
- block_given? || raise(ArgumentError, "No block given")
11
-
12
- context.add_before block
13
- end
14
-
15
- def self.after &block
16
- block_given? || raise(ArgumentError, "No block given")
17
-
18
- context.add_after block
19
- end
20
-
21
- def self.group *_words, &block
22
- block_given? || raise(ArgumentError, "No block given")
23
-
24
- context.open_group
25
- instance_exec &block
26
- context.close_group
27
- end
28
- end
29
-
30
- extension do
31
- # group
32
-
33
- def open_group
34
- befores.push befores.last.dup
35
- afters.push afters.last.dup
36
- end
37
-
38
- def close_group
39
- befores.pop
40
- afters.pop
41
- end
42
-
43
- # before
44
-
45
- def befores
46
- @befores ||= _befores_from_superclass + [[]]
47
- end
48
-
49
- def add_before block
50
- befores.last.push block
51
- end
52
-
53
- def _befores_from_superclass
54
- if solder.superclass.respond_to? :context
55
- solder.superclass.context.befores.dup
56
- else
57
- []
58
- end
59
- end
60
-
61
- # after
62
-
63
- def afters
64
- @afters ||= _afters_from_superclass + [[]]
65
- end
66
-
67
- def add_after block
68
- afters.last.push block
69
- end
70
-
71
- def _afters_from_superclass
72
- if solder.superclass.respond_to? :context
73
- solder.superclass.context.afters.dup
74
- else
75
- []
76
- end
77
- end
78
- end
79
-
80
- end
81
- end
@@ -1,31 +0,0 @@
1
- class NetSystem
2
- class Model < Liza::Controller
3
-
4
- def self.inherited sub
5
- super
6
-
7
- return if sub.name.nil?
8
- return if sub.name.end_with? "Model"
9
- raise "please rename #{sub.name} to #{sub.name}Model"
10
- end
11
-
12
- def self.db database_id = nil
13
- if database_id.nil?
14
- db = get :db
15
- if db
16
- NetBox.databases.get db
17
- else
18
- raise "please set a db to model #{self}"
19
- end
20
- else
21
- valid = NetBox.databases.settings.keys
22
- if valid.include? database_id
23
- set :db, database_id
24
- else
25
- raise "invalid db, valid options are #{valid}"
26
- end
27
- end
28
- end
29
-
30
- end
31
- end