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,12 +1,10 @@
1
- module Liza
2
- class BoxTest < UnitTest
3
- test :subject_class do
4
- assert subject_class == Liza::Box
5
- end
1
+ class Liza::BoxTest < Liza::UnitTest
2
+ test :subject_class do
3
+ assert subject_class == Liza::Box
4
+ end
6
5
 
7
- test :settings do
8
- assert subject_class.log_level == :normal
9
- assert subject_class.log_color == :white
10
- end
6
+ test :settings do
7
+ assert subject_class.log_level == :normal
8
+ assert subject_class.log_color == :white
11
9
  end
12
10
  end
@@ -1,27 +1,27 @@
1
- module Liza
2
- class Controller < Unit
3
- inherited_explicitly_sets_system
1
+ class Liza::Controller < Liza::Unit
2
+ part :controller_renderer
4
3
 
5
- def self.on_connected box_klass, panel
6
- set :box, box_klass
7
- set :panel, panel
8
- end
4
+ inherited_explicitly_sets_system
9
5
 
10
- def self.box
11
- get :box
12
- end
6
+ def self.on_connected box_klass, panel
7
+ set :box, box_klass
8
+ set :panel, panel
9
+ end
13
10
 
14
- def self.panel
15
- get :panel
16
- end
11
+ def self.box
12
+ get :box
13
+ end
17
14
 
18
- def box
19
- self.class.box
20
- end
15
+ def self.panel
16
+ get :panel
17
+ end
21
18
 
22
- def panel
23
- self.class.panel
24
- end
19
+ def box
20
+ self.class.box
21
+ end
25
22
 
23
+ def panel
24
+ self.class.panel
26
25
  end
26
+
27
27
  end
@@ -1,12 +1,10 @@
1
- module Liza
2
- class ControllerTest < UnitTest
3
- test :subject_class do
4
- assert subject_class == Liza::Controller
5
- end
1
+ class Liza::ControllerTest < Liza::UnitTest
2
+ test :subject_class do
3
+ assert subject_class == Liza::Controller
4
+ end
6
5
 
7
- test :settings do
8
- assert subject_class.log_level == :normal
9
- assert subject_class.log_color == :white
10
- end
6
+ test :settings do
7
+ assert subject_class.log_level == :normal
8
+ assert subject_class.log_color == :white
11
9
  end
12
10
  end
@@ -1,38 +1,54 @@
1
- module Liza
2
- class Panel < Unit
3
- inherited_explicitly_sets_system
1
+ class Liza::Panel < Liza::Unit
2
+ inherited_explicitly_sets_system
4
3
 
5
- def self.on_connected box_klass
6
- set :box, box_klass
7
- end
4
+ def self.on_connected box_klass
5
+ set :box, box_klass
6
+ end
8
7
 
9
- def self.box
10
- get :box
11
- end
8
+ def self.box
9
+ get :box
10
+ end
12
11
 
13
- def box
14
- self.class.box
15
- end
12
+ def box
13
+ self.class.box
14
+ end
16
15
 
17
- def initialize name
18
- @name = name
19
- end
16
+ def initialize key
17
+ @key = key
18
+ @blocks = []
19
+ @unstarted = true
20
+ end
20
21
 
21
- def log string
22
- source = box.to_s
22
+ def push block
23
+ @unstarted = true
24
+ @blocks.push block
25
+ end
23
26
 
24
- x = source.size
27
+ def started
28
+ return self unless defined? @unstarted
29
+ remove_instance_variable :@unstarted
25
30
 
26
- source = source.bold.colorize log_color
31
+ @blocks.each { |bl| instance_eval &bl }
32
+ @blocks.clear
27
33
 
28
- y = source.size
34
+ self
35
+ end
36
+
37
+ def log log_level = :normal, string
38
+ raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
39
+ return unless log_level? log_level
29
40
 
30
- source = "#{source}.#{@name}".ljust(LOG_JUST+y-x)
41
+ source = box.to_s
31
42
 
32
- string = "#{source} #{string}"
43
+ x = source.size
44
+ source = source.bold.colorize log_color
33
45
 
34
- super string
35
- end
46
+ y = source.size
47
+ source = "#{source}[:#{@key}]".ljust(LOG_JUST+y-x)
36
48
 
49
+ string = "#{source} #{string}"
50
+
51
+ DevBox[:log].call string
37
52
  end
53
+
38
54
  end
@@ -1,16 +1,14 @@
1
- module Liza
2
- class PanelTest < UnitTest
3
- test :subject_class do
4
- assert subject_class == Liza::Panel
5
- end
1
+ class Liza::PanelTest < Liza::UnitTest
2
+ test :subject_class do
3
+ assert subject_class == Liza::Panel
4
+ end
6
5
 
7
- def subject
8
- subject_class.new "name"
9
- end
6
+ def subject
7
+ subject_class.new "name"
8
+ end
10
9
 
11
- test :settings do
12
- assert subject_class.log_level == :normal
13
- assert subject_class.log_color == :white
14
- end
10
+ test :settings do
11
+ assert subject_class.log_level == :normal
12
+ assert subject_class.log_color == :white
15
13
  end
16
14
  end
@@ -0,0 +1,140 @@
1
+ class Liza::ControllerRendererPart < Liza::Part
2
+
3
+ class Error < Liza::Error; end
4
+ class RendererNotFound < Error; end
5
+ class EmptyRenderStack < Error; end
6
+
7
+ EMPTY_RENDER_STACK_MESSAGE = <<~STRING
8
+ You called render without ERB keys,
9
+ but the render stack is empty.
10
+ Did you forget to add ERB keys?
11
+ STRING
12
+
13
+ insertion do
14
+ # EXTENSION
15
+
16
+ def self.renderer
17
+ Liza::ControllerRendererPart::Extension
18
+ end
19
+
20
+ def renderer
21
+ @renderer ||= self.class.renderer.new self
22
+ end
23
+
24
+ # CLASS
25
+
26
+ def self.controller_ancestors
27
+ ancestors.take_while { |k| k != Liza::Controller }
28
+ end
29
+
30
+ def self.render_paths
31
+ @render_paths ||= controller_ancestors.map &:source_location_radical
32
+ end
33
+
34
+ def render_paths
35
+ self.class.render_paths
36
+ end
37
+
38
+ def self.renderers
39
+ @renderers ||=
40
+ LERB.load(source_location_radical)
41
+ .map { |lerb| [lerb.key, lerb] }
42
+ .to_h
43
+ end
44
+
45
+ # INSTANCE
46
+
47
+ def render *keys
48
+ if keys.any?
49
+ _log_render_in keys
50
+ renderer.render keys, binding, self
51
+ elsif renderer.stack.any?
52
+ renderer.stack.pop
53
+ else
54
+ raise EmptyRenderStack, EMPTY_RENDER_STACK_MESSAGE, caller
55
+ end
56
+ end
57
+
58
+ def _log_render_in keys
59
+ if renderer.stack.any?
60
+ log "render ↓ #{keys.join ", "}"
61
+ else
62
+ log "render #{"→ " * keys.size}#{keys.join ", "}"
63
+ end
64
+ end
65
+ end
66
+
67
+ extension do
68
+ # CLASS
69
+
70
+ def self.log(...)
71
+ solder.log(...)
72
+ end
73
+
74
+ # INSTANCE
75
+
76
+ def log(...)
77
+ self.class.log(...)
78
+ end
79
+
80
+ def erb_lists
81
+ @erb_lists ||= []
82
+ end
83
+
84
+ def stack
85
+ @stack ||= []
86
+ end
87
+
88
+ def render keys, the_binding, receiver
89
+ erbs = find_erbs_for(keys).to_a
90
+
91
+ erbs.reverse.each do |key, erb|
92
+ t = Time.now
93
+ s = erb.result the_binding, receiver
94
+ _log_render_out key, s.length, t.diff
95
+ s = wrap_comment_tags s, erb if App.mode == :code && erb.tags?
96
+ stack.push s.strip
97
+ end
98
+
99
+ stack.pop
100
+ end
101
+
102
+ def find_erbs_for keys
103
+ ret = {}
104
+ keys.each do |key|
105
+ key = "#{key}.erb"
106
+
107
+ controller = solder.class.controller_ancestors.
108
+ find { |controller| controller.renderers.has_key? key }
109
+
110
+ if controller
111
+ ret[key] = controller.renderers[key]
112
+ else
113
+ raise_renderer_not_found key
114
+ end
115
+ end
116
+
117
+ ret
118
+ end
119
+
120
+ def raise_renderer_not_found key
121
+ render_paths = solder.render_paths.map { |s| " #{s}/#{"#{key}".red}" }.join
122
+ raise RendererNotFound, %|Failed to find ERB #{key}
123
+ Failed to find ERB #{"#{key}".red} in #{solder.class}.render_paths
124
+ #{render_paths}|
125
+ end
126
+
127
+ def _log_render_out key, length, t
128
+ if stack.any?
129
+ log "render #{"↑ #{key}".ljust_blanks 20} with #{length.to_s.rjust_blanks 4} characters in #{t}s"
130
+ else
131
+ log "render #{"← #{key}".ljust_blanks 20} with #{length.to_s.rjust_blanks 4} characters in #{t}s"
132
+ end
133
+ end
134
+
135
+ def wrap_comment_tags s, erb
136
+ "<!-- #{erb.filename.split("/").last}:#{erb.lineno} -->\n#{s}\n<!-- #{erb.filename.split("/").last} -->"
137
+ end
138
+
139
+ end
140
+ end
@@ -0,0 +1,16 @@
1
+ class Liza::ControllerRendererPartTest < Liza::Test
2
+
3
+ test :subject_class do
4
+ assert subject_class == Liza::ControllerRendererPart
5
+ end
6
+
7
+ test :settings do
8
+ assert subject_class.get(:log_level) == :normal
9
+ assert subject_class.get(:log_color) == :white
10
+ assert subject_class.log_level == :normal
11
+ assert subject_class.log_color == :white
12
+
13
+ assert subject_class.settings == {}
14
+ end
15
+
16
+ end
@@ -1,19 +1,17 @@
1
- module Liza
2
- class Part < Unit
3
- def self.insertion &block
4
- if block_given?
5
- @insertion = block
6
- else
7
- @insertion
8
- end
1
+ class Liza::Part < Liza::Unit
2
+ def self.insertion &block
3
+ if block_given?
4
+ @insertion = block
5
+ else
6
+ @insertion
9
7
  end
8
+ end
10
9
 
11
- def self.extension &block
12
- if block_given?
13
- @extension = block
14
- else
15
- @extension
16
- end
10
+ def self.extension &block
11
+ if block_given?
12
+ @extension = block
13
+ else
14
+ @extension
17
15
  end
18
16
  end
19
17
  end
@@ -1,13 +1,16 @@
1
- module Liza
2
- class PartExtension
3
- def self.solder
4
- @solder ||= Liza.const first_namespace
5
- end
6
-
7
- def initialize solder
8
- @solder = solder
9
- end
1
+ class Liza::PartExtension
2
+ def self.solder
3
+ @solder ||=
4
+ if first_namespace == "Liza"
5
+ Liza.const_get last_namespace[0..-12]
6
+ else
7
+ Object.const_get name[0..-12]
8
+ end
9
+ end
10
10
 
11
- attr_reader :solder
11
+ def initialize solder
12
+ @solder = solder
12
13
  end
13
- end
14
+
15
+ attr_reader :solder
16
+ end
@@ -1,8 +1,6 @@
1
- module Liza
2
- class PartTest < Test
3
- test :subject_class do
4
- assert subject_class == Liza::Part
5
- end
6
-
1
+ class Liza::PartTest < Liza::Test
2
+ test :subject_class do
3
+ assert subject_class == Liza::Part
7
4
  end
5
+
8
6
  end
@@ -1,20 +1,18 @@
1
- module Liza
2
- class System < Unit
1
+ class Liza::System < Liza::Unit
3
2
 
4
- def self.const name
5
- const_get name.to_s.camelize
6
- end
3
+ def self.const name
4
+ const_get name.to_s.camelize
5
+ end
7
6
 
8
- def self.insertion key, &block
9
- if block_given?
10
- registrar[:"insertion_#{key}"] = block
11
- else
12
- registrar[:"insertion_#{key}"]
13
- end
7
+ def self.insertion key, &block
8
+ if block_given?
9
+ registrar[:"insertion_#{key}"] = block
10
+ else
11
+ registrar[:"insertion_#{key}"]
14
12
  end
13
+ end
15
14
 
16
- def self.registrar
17
- @registrar ||= {}
18
- end
15
+ def self.registrar
16
+ @registrar ||= {}
19
17
  end
20
18
  end
@@ -1,13 +1,11 @@
1
- module Liza
2
- class SystemTest < UnitTest
3
- test :subject_class do
4
- assert subject_class == Liza::System
5
- end
6
-
7
- test :settings do
8
- assert subject_class.log_level == :normal
9
- assert subject_class.log_color == :white
10
- end
1
+ class Liza::SystemTest < Liza::UnitTest
2
+ test :subject_class do
3
+ assert subject_class == Liza::System
4
+ end
11
5
 
6
+ test :settings do
7
+ assert subject_class.log_level == :normal
8
+ assert subject_class.log_color == :white
12
9
  end
10
+
13
11
  end
@@ -0,0 +1,7 @@
1
+ class Liza::RubyTest < Liza::Test
2
+
3
+ def self.subject_class
4
+ @subject_class ||= Object.const_get last_namespace[0..-5]
5
+ end
6
+
7
+ end
@@ -0,0 +1,21 @@
1
+ class Liza::ModuleTest < Liza::RubyTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == Module
5
+ end
6
+
7
+ test :source_location do
8
+ assert Object.source_location == []
9
+
10
+ assert Liza::Command.source_location[1] == 1
11
+ assert AppCommand.source_location[1] == 1
12
+ end
13
+
14
+ test :source_location_radical do
15
+ assert Object.source_location_radical == nil
16
+
17
+ assert Liza::Command.source_location_radical.end_with? "/lib/dev_system/dev/controllers/command"
18
+ assert AppCommand.source_location_radical.end_with? "/app/dev/commands/app_command"
19
+ end
20
+
21
+ end
@@ -0,0 +1,59 @@
1
+ class Liza::StringTest < Liza::RubyTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == String
5
+ end
6
+
7
+ test :initializers do
8
+ s0 = String.new
9
+ s1 = ''
10
+ s2 = ""
11
+
12
+ assert s0.class == String
13
+ assert s1.class == String
14
+ assert s2.class == String
15
+ end
16
+
17
+ test :lpartition do
18
+ todo "write examples"
19
+ end
20
+
21
+ test :rpartition do
22
+ todo "write examples"
23
+ end
24
+
25
+ test :camelcase do
26
+ assert "" == "".camelcase
27
+ assert "A" == "a".camelcase
28
+ assert "Ab" == "ab".camelcase
29
+ assert "AbC" == "ab_c".camelcase
30
+ assert "AbCd" == "ab_cd".camelcase
31
+ assert "Ab" == "ab_".camelcase
32
+ assert "Cd" == "_cd".camelcase
33
+ end
34
+
35
+ test :snakecase do
36
+ assert "" == "".snakecase
37
+ assert "a" == "A".snakecase
38
+ assert "ab" == "Ab".snakecase
39
+ assert "ab_c" == "AbC".snakecase
40
+ assert "ab_cd" == "AbCd".snakecase
41
+ end
42
+
43
+ test :rjust_blanks do
44
+ todo "write examples"
45
+ end
46
+
47
+ test :rjust_zeroes do
48
+ todo "write examples"
49
+ end
50
+
51
+ test :ljust_blanks do
52
+ todo "write examples"
53
+ end
54
+
55
+ test :ljust_zeroes do
56
+ todo "write examples"
57
+ end
58
+
59
+ end
@@ -1,11 +1,10 @@
1
- module Liza
2
- class Test < Unit
1
+ class Liza::Test < Liza::Unit
3
2
 
4
- part :test_assertions
5
- part :test_dsl
6
- part :test_context
7
- part :test_subject
3
+ part :test_assertions
4
+ part :test_assertions_advanced
5
+ part :test_dsl
6
+ part :test_log
7
+ part :test_subject
8
+ part :test_tree
8
9
 
9
- end
10
10
  end
11
-