lizarb 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -13
- data/Rakefile +38 -0
- data/app/dev_box.rb +26 -4
- data/app/happy_box.rb +2 -2
- data/app/net/databases/sqlite_db_test.rb +5 -5
- data/app/net/records/app_record_test.rb +1 -1
- data/app/net/records/post_record_test.rb +1 -1
- data/app/net/records/user_record_test.rb +1 -1
- data/app/net_box.rb +9 -9
- data/app/web_box.rb +4 -4
- data/app.rb +6 -7
- data/{exe/Gemfile → app_global.gemfile.rb} +2 -0
- data/app_global.gemfile.rb.lock +19 -0
- data/app_global.rb +4 -0
- data/{app → app_new}/dev/benches/loops_bench.rb +3 -2
- data/{app/dev/generators/bench_generator_test.rb → app_new/dev/benches/loops_bench_test.rb} +2 -2
- data/app_new/dev/benches/objects_bench.rb +83 -0
- data/{app/dev/generators/record_generator_test.rb → app_new/dev/benches/objects_bench_test.rb} +2 -2
- data/app_new/dev/benches/sorted_bench.rb +54 -0
- data/app_new/dev/benches/sorted_bench_test.rb +12 -0
- data/app_new/dev/benches/variables_bench.rb +55 -0
- data/{app/dev/generators/command_generator_test.rb → app_new/dev/benches/variables_bench_test.rb} +2 -2
- data/{app → app_new}/dev/commands/calculator_command.rb +1 -1
- data/{app → app_new}/dev/commands/circle_command.rb +1 -1
- data/{app → app_new}/dev/commands/narrative_method_command.rb +5 -7
- data/{app → app_new}/dev/commands/quadratic_command.rb +1 -1
- data/app_new/dev_box.rb +14 -0
- data/app_new.rb +15 -0
- data/exe/lizarb +9 -1
- data/lib/app.rb +27 -95
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +23 -18
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
- data/lib/dev_system/dev/controllers/bench.rb +1 -9
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +19 -22
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +5 -31
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/new_command.rb +9 -0
- data/lib/dev_system/dev/controllers/command/new_command_test.rb +7 -0
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +37 -18
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command.rb +9 -15
- data/lib/dev_system/dev/controllers/command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generator.rb +5 -7
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +33 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/{app/dev/generators/bench_generator/bench.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller.rb.erb} +1 -2
- data/{app/dev/generators/bench_generator/bench_test.rb.erb → lib/dev_system/dev/controllers/generators/bench_generator/controller_test.rb.erb} +2 -2
- data/lib/dev_system/dev/controllers/generators/bench_generator.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/bench_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/command_generator/controller.rb.erb +41 -0
- data/{app/dev/generators/command_generator/command_test.rb.erb → lib/dev_system/dev/controllers/generators/command_generator/controller_test.rb.erb} +2 -2
- data/lib/dev_system/dev/controllers/generators/command_generator.rb +19 -0
- data/lib/dev_system/dev/controllers/generators/command_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/controller_generator.rb +97 -0
- data/lib/dev_system/dev/controllers/generators/controller_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +1 -1
- data/lib/dev_system/dev/controllers/generators/new_generator.rb +117 -0
- data/lib/dev_system/dev/controllers/generators/new_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -17
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
- data/{app/dev → lib/dev_system/dev/controllers}/generators/record_generator.rb +1 -1
- data/lib/dev_system/dev/controllers/generators/record_generator_test.rb +12 -0
- data/{app/dev → lib/dev_system/dev/controllers}/generators/request_generator.rb +2 -2
- data/lib/dev_system/dev/controllers/generators/request_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/log.rb +3 -0
- data/{app/dev/generators/request_generator_test.rb → lib/dev_system/dev/controllers/log_test.rb} +2 -2
- data/lib/dev_system/dev/controllers/shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell_test.rb +25 -0
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +15 -11
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
- data/lib/dev_system/dev/dev_box.rb +27 -16
- data/lib/dev_system/dev/dev_box_test.rb +12 -14
- data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
- data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/command_panel.rb +59 -18
- data/lib/dev_system/dev/panels/command_panel_test.rb +43 -20
- data/lib/dev_system/dev/panels/generator_panel.rb +73 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +46 -0
- data/lib/dev_system/dev/panels/log_panel.rb +9 -6
- data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
- data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
- data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
- data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
- data/lib/happy_system/happy/controllers/axo.rb +4 -5
- data/lib/happy_system/happy/happy_box.rb +5 -9
- data/lib/happy_system/happy/happy_box_test.rb +11 -13
- data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
- data/lib/lerb.rb +95 -49
- data/lib/liza/base/box.rb +76 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -21
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +40 -27
- data/lib/liza/base/panel_test.rb +36 -12
- data/lib/liza/base_parts/controller_renderer_part.rb +1 -1
- data/lib/liza/meta/part.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -16
- data/lib/liza/meta/part_test.rb +4 -6
- data/lib/liza/meta/system.rb +12 -14
- data/lib/liza/meta/system_test.rb +8 -10
- data/lib/liza/ruby_test.rb +4 -6
- data/lib/liza/ruby_tests/module_test.rb +3 -3
- data/lib/liza/test/test.rb +7 -10
- data/lib/liza/test/test_test.rb +160 -157
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
- data/lib/liza/test_parts/test_assertions_part.rb +81 -83
- data/lib/liza/test_parts/test_dsl_part.rb +47 -49
- data/lib/liza/test_parts/test_log_part.rb +88 -90
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +73 -120
- data/lib/liza/unit.rb +105 -107
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +9 -9
- data/lib/liza/unit_parts/unit_settings_part.rb +76 -0
- data/lib/liza/unit_parts/unit_settings_part_test.rb +3 -0
- data/lib/liza/unit_test.rb +80 -71
- data/lib/liza.rb +10 -1
- data/lib/lizarb/ruby/module.rb +1 -1
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +247 -23
- data/lib/net_system/dev/net_command.rb +15 -17
- data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
- data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
- data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client.rb +1 -3
- data/lib/net_system/net/controllers/client_test.rb +8 -10
- data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
- data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database.rb +21 -23
- data/lib/net_system/net/controllers/database_test.rb +8 -10
- data/lib/net_system/net/controllers/record.rb +21 -23
- data/lib/net_system/net/controllers/record_test.rb +8 -10
- data/lib/net_system/net/net_box.rb +9 -16
- data/lib/net_system/net/net_box_test.rb +12 -14
- data/lib/net_system/net/panels/client_panel.rb +1 -3
- data/lib/net_system/net/panels/client_panel_test.rb +11 -13
- data/lib/net_system/net/panels/database_panel.rb +6 -8
- data/lib/net_system/net/panels/database_panel_test.rb +11 -13
- data/lib/web_system/dev/rack_command.rb +20 -18
- data/lib/web_system/dev/request_command.rb +8 -22
- data/lib/web_system/dev/web_command.rb +6 -8
- data/lib/web_system/web/controllers/rack.rb +4 -6
- data/lib/web_system/web/controllers/rack_test.rb +11 -13
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
- data/lib/web_system/web/controllers/request.rb +1 -3
- data/lib/web_system/web/controllers/request_test.rb +11 -13
- data/lib/web_system/web/panels/rack_panel.rb +37 -39
- data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
- data/lib/web_system/web/panels/request_panel.rb +53 -57
- data/lib/web_system/web/panels/request_panel_test.rb +1 -1
- data/lib/web_system/web/web_box.rb +12 -18
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +1 -1
- metadata +54 -44
- data/.ruby-version +0 -1
- data/app/dev/benches/app_bench.rb +0 -5
- data/app/dev/benches/app_bench_test.rb +0 -7
- data/app/dev/benches/loops_bench_test.rb +0 -11
- data/app/dev/commands/app_command.rb +0 -5
- data/app/dev/commands/app_command_test.rb +0 -7
- data/app/dev/commands/new_command.rb +0 -9
- data/app/dev/commands/new_command_test.rb +0 -7
- data/app/dev/generators/bench_generator.rb +0 -18
- data/app/dev/generators/command_generator/command.rb.erb +0 -26
- data/app/dev/generators/command_generator.rb +0 -18
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/exe/Gemfile.lock +0 -13
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +0 -60
- data/lib/dev_system/dev/controllers/command/echo_command.rb +0 -11
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +0 -14
- data/lib/dev_system/dev/controllers/command/version_command.rb +0 -9
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +0 -14
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +0 -96
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +0 -14
- /data/{app → app_new}/dev/commands/calculator_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/circle_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/narrative_method_command_test.rb +0 -0
- /data/{app → app_new}/dev/commands/quadratic_command_test.rb +0 -0
@@ -1,139 +1,92 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@test_node = previous
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.test *words, &block
|
26
|
-
raise ArgumentError, "No block given" unless block_given?
|
27
|
-
test_node.add_test words, &block
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.before &block
|
31
|
-
raise ArgumentError, "No block given" unless block_given?
|
32
|
-
test_node.add_before &block
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.after &block
|
36
|
-
raise ArgumentError, "No block given" unless block_given?
|
37
|
-
test_node.add_after &block
|
38
|
-
end
|
39
|
-
|
1
|
+
class Liza::TestTreePart < Liza::Part
|
2
|
+
|
3
|
+
insertion do
|
4
|
+
|
5
|
+
@before_stack = []
|
6
|
+
@after_stack = []
|
7
|
+
|
8
|
+
def self.before_stack; @before_stack ||= superclass.before_stack.dup end
|
9
|
+
def self.after_stack; @after_stack ||= superclass.after_stack.dup end
|
10
|
+
|
11
|
+
def self.test_node; @test_node ||= test_tree end
|
12
|
+
def self.test_tree; @test_tree ||= Liza::TestTreePart::Extension.new nil, before_stack, after_stack end
|
13
|
+
|
14
|
+
#
|
15
|
+
|
16
|
+
def self.group *words, &block
|
17
|
+
raise ArgumentError, "No block given" unless block_given?
|
18
|
+
previous = test_node
|
19
|
+
@test_node = test_node.branch_out words
|
20
|
+
instance_exec(&block)
|
21
|
+
@test_node = previous
|
40
22
|
end
|
41
23
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def log_test_building?
|
49
|
-
Liza::Test.log_test_building?
|
50
|
-
end
|
51
|
-
|
52
|
-
attr_reader :tests, :parent, :children, :before_stack, :after_stack
|
53
|
-
|
54
|
-
def initialize parent, before_stack, after_stack
|
55
|
-
@parent = parent || self
|
56
|
-
|
57
|
-
@children, @tests = [], []
|
58
|
-
@before_top, @after_top = [], []
|
59
|
-
|
60
|
-
@before_stack = before_stack.push @before_top
|
61
|
-
@after_stack = after_stack.unshift @after_top
|
62
|
-
|
63
|
-
@parent.children << self if @parent != self
|
64
|
-
end
|
65
|
-
|
66
|
-
def initialize parent, before_stack, after_stack
|
67
|
-
@parent = parent || self
|
68
|
-
|
69
|
-
@children, @tests, @before_top, @after_top = [], [], [], []
|
70
|
-
|
71
|
-
@before_stack = before_stack.push @before_top
|
72
|
-
@after_stack = after_stack.unshift @after_top
|
73
|
-
|
74
|
-
@parent.children << self if @parent != self
|
75
|
-
end
|
24
|
+
def self.test *words, &block
|
25
|
+
raise ArgumentError, "No block given" unless block_given?
|
26
|
+
test_node.add_test words, &block
|
27
|
+
end
|
76
28
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
29
|
+
def self.before &block
|
30
|
+
raise ArgumentError, "No block given" unless block_given?
|
31
|
+
test_node.add_before(&block)
|
32
|
+
end
|
81
33
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
34
|
+
def self.after &block
|
35
|
+
raise ArgumentError, "No block given" unless block_given?
|
36
|
+
test_node.add_after(&block)
|
37
|
+
end
|
86
38
|
|
87
|
-
|
88
|
-
@tests = []
|
39
|
+
end
|
89
40
|
|
90
|
-
|
91
|
-
|
92
|
-
|
41
|
+
extension do
|
42
|
+
|
43
|
+
def log *args
|
44
|
+
self.class.solder.log(*args)
|
45
|
+
end
|
93
46
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
47
|
+
def log_test_building?
|
48
|
+
Liza::Test.log_test_building?
|
49
|
+
end
|
98
50
|
|
99
|
-
|
100
|
-
@tests = []
|
101
|
-
initialize_parenting parent
|
102
|
-
initialize_filters before_stack, after_stack
|
103
|
-
end
|
51
|
+
attr_reader :tests, :parent, :children, :before_stack, :after_stack
|
104
52
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
53
|
+
def initialize parent, before_stack, after_stack
|
54
|
+
@tests = []
|
55
|
+
initialize_parenting parent
|
56
|
+
initialize_filters before_stack, after_stack
|
57
|
+
end
|
110
58
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
59
|
+
def initialize_parenting parent
|
60
|
+
@parent = parent || self
|
61
|
+
@children = []
|
62
|
+
@parent.children << self if @parent != self
|
63
|
+
end
|
116
64
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
65
|
+
def initialize_filters before_stack, after_stack
|
66
|
+
@before_top, @after_top = [], []
|
67
|
+
@before_stack = before_stack.push @before_top
|
68
|
+
@after_stack = after_stack.unshift @after_top
|
69
|
+
end
|
121
70
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
71
|
+
def add_before &block
|
72
|
+
log "add_before to ##{object_id} #{block}" if log_test_building?
|
73
|
+
@before_top.push block
|
74
|
+
end
|
126
75
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
76
|
+
def add_test words, &block
|
77
|
+
log "add_test to ##{object_id} #{words} #{block}" if log_test_building?
|
78
|
+
tests << [words, block]
|
79
|
+
end
|
131
80
|
|
132
|
-
|
133
|
-
|
134
|
-
|
81
|
+
def add_after &block
|
82
|
+
log "add_after to ##{object_id} #{block}" if log_test_building?
|
83
|
+
@after_top.push block
|
84
|
+
end
|
135
85
|
|
86
|
+
def branch_out words, &block
|
87
|
+
self.class.new self, before_stack.dup, after_stack.dup
|
136
88
|
end
|
137
89
|
|
138
90
|
end
|
91
|
+
|
139
92
|
end
|
data/lib/liza/unit.rb
CHANGED
@@ -1,151 +1,149 @@
|
|
1
|
-
|
2
|
-
class Unit
|
1
|
+
class Liza::Unit
|
3
2
|
|
4
|
-
|
3
|
+
# PARTS
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def self.part key, system: nil
|
6
|
+
App.connect_part self, key, system
|
7
|
+
end
|
9
8
|
|
10
|
-
|
9
|
+
# CONST MISSING
|
11
10
|
|
12
|
-
|
11
|
+
if Lizarb.ruby_supports_raise_cause?
|
13
12
|
|
14
|
-
def self.
|
15
|
-
|
13
|
+
def self.const_missing name
|
14
|
+
Liza.const name
|
15
|
+
rescue Liza::ConstNotFound
|
16
|
+
raise NameError, "uninitialized constant #{name}", caller[1..], cause: nil
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
return settings[key] if settings.has_key? key
|
19
|
+
else
|
20
20
|
|
21
|
-
|
21
|
+
def self.const_missing name
|
22
|
+
Liza.const name
|
23
|
+
rescue Liza::ConstNotFound
|
24
|
+
raise NameError, "uninitialized constant #{name}", caller[1..]
|
25
|
+
end
|
22
26
|
|
23
|
-
|
24
|
-
break unless klass.respond_to? :settings
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
part :unit_procedure
|
30
|
+
part :unit_settings
|
28
31
|
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
+
# LOG
|
32
33
|
|
33
|
-
|
34
|
+
LOG_LEVELS = {
|
35
|
+
:higher => 2,
|
36
|
+
:high => 1,
|
37
|
+
:normal => 0,
|
38
|
+
:low => -1,
|
39
|
+
:lower => -2,
|
40
|
+
}
|
34
41
|
|
35
|
-
|
36
|
-
|
42
|
+
set :log_level, :normal
|
43
|
+
set :log_color, :white
|
37
44
|
|
38
|
-
|
39
|
-
settings[key] = value
|
40
|
-
value
|
41
|
-
end
|
45
|
+
# NOTE: improve logs performance and readability
|
42
46
|
|
43
|
-
|
44
|
-
if key
|
45
|
-
fetch(list) { Hash.new }[key] = value
|
46
|
-
else
|
47
|
-
fetch(list) { Set.new } << value
|
48
|
-
end
|
49
|
-
end
|
47
|
+
LOG_JUST = 60
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
49
|
+
def self.build_log_sidebar_for source, method_key, method_sep, panel_key: nil
|
50
|
+
source = (source.is_a? Class) ? source : source.class
|
51
|
+
source_color = source.log_color
|
52
|
+
source = source.to_s
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
return settings[key] if settings.has_key? key
|
63
|
-
|
64
|
-
self.class.get key
|
65
|
-
end
|
54
|
+
s = source.bold.colorize(source_color)
|
55
|
+
s << "[:#{panel_key}]" if panel_key
|
56
|
+
s << "#{method_sep}#{method_key}"
|
57
|
+
s.ljust(LOG_JUST)
|
58
|
+
end
|
66
59
|
|
67
|
-
|
68
|
-
|
69
|
-
|
60
|
+
# NOTE: This code needs to be optimized.
|
61
|
+
def self._log_extract_method_name kaller
|
62
|
+
kaller.each do |s|
|
63
|
+
t = s.match(/`(.*)'/)[1]
|
70
64
|
|
71
|
-
|
72
|
-
if
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
65
|
+
next if t.include? " in <class:"
|
66
|
+
return t.split(" ").last if t.include? " in "
|
67
|
+
|
68
|
+
next if t == "log"
|
69
|
+
next if t == "each"
|
70
|
+
next if t == "map"
|
71
|
+
next if t == "with_index"
|
72
|
+
next if t == "instance_exec"
|
73
|
+
next if t.start_with? "_"
|
74
|
+
return t
|
77
75
|
end
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
x ||= set key, eval(&block)
|
82
|
-
x
|
83
|
-
end
|
84
|
-
|
85
|
-
# LOG
|
86
|
-
|
87
|
-
LOG_LEVELS = {
|
88
|
-
:higher => 2,
|
89
|
-
:high => 1,
|
90
|
-
:normal => 0,
|
91
|
-
:low => -1,
|
92
|
-
:lower => -2,
|
93
|
-
}
|
77
|
+
raise "there's something wrong with kaller"
|
78
|
+
end
|
94
79
|
|
95
|
-
|
96
|
-
|
80
|
+
def _log_extract_method_name kaller
|
81
|
+
self.class._log_extract_method_name kaller
|
82
|
+
end
|
97
83
|
|
98
|
-
|
84
|
+
def self.log log_level = :normal, string, kaller: caller
|
85
|
+
raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
|
86
|
+
return unless log_level? log_level
|
99
87
|
|
100
|
-
|
88
|
+
method_key = _log_extract_method_name kaller
|
89
|
+
source = Liza::Unit.build_log_sidebar_for self, method_key, ":"
|
101
90
|
|
102
|
-
|
103
|
-
|
104
|
-
return unless log_level? log_level
|
91
|
+
DevBox[:log].call "#{source} #{string}"
|
92
|
+
end
|
105
93
|
|
106
|
-
|
107
|
-
|
94
|
+
def log log_level = :normal, string, kaller: caller
|
95
|
+
raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
|
96
|
+
return unless log_level? log_level
|
108
97
|
|
109
|
-
|
98
|
+
method_key = _log_extract_method_name kaller
|
110
99
|
|
111
|
-
|
100
|
+
case self
|
101
|
+
when Liza::Panel
|
102
|
+
source = Liza::Unit.build_log_sidebar_for box, method_key, ".", panel_key: @key
|
103
|
+
when Liza::UnitTest
|
104
|
+
source = Liza::Unit.build_log_sidebar_for self, " ", " "
|
105
|
+
else
|
106
|
+
source = Liza::Unit.build_log_sidebar_for self, method_key, "#"
|
112
107
|
end
|
113
108
|
|
114
|
-
|
115
|
-
|
116
|
-
end
|
109
|
+
DevBox[:log].call "#{source} #{string}"
|
110
|
+
end
|
117
111
|
|
118
|
-
|
119
|
-
# TODO
|
120
|
-
true
|
121
|
-
end
|
112
|
+
#
|
122
113
|
|
123
|
-
|
124
|
-
|
125
|
-
|
114
|
+
def self.log_level
|
115
|
+
get(:log_level) || :normal
|
116
|
+
end
|
126
117
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
def log_level?(...)= self.class.log_level?(...)
|
132
|
-
def log_color(...)= self.class.log_color(...)
|
118
|
+
def self.log_level? log_level = :normal
|
119
|
+
# TODO
|
120
|
+
true
|
121
|
+
end
|
133
122
|
|
134
|
-
|
123
|
+
def self.log_color
|
124
|
+
(get(:system) || self).get :log_color
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.log?(log_level = :normal)= log_level? log_level
|
128
|
+
def log_level(...)= self.class.log_level(...)
|
129
|
+
def log?(...)= self.class.log?(...)
|
130
|
+
def log_level?(...)= self.class.log_level?(...)
|
131
|
+
def log_color(...)= self.class.log_color(...)
|
135
132
|
|
136
|
-
|
133
|
+
# SYSTEM
|
137
134
|
|
138
|
-
|
139
|
-
super
|
135
|
+
def self.inherited_explicitly_sets_system
|
140
136
|
|
141
|
-
|
137
|
+
def self.inherited sub
|
138
|
+
super
|
142
139
|
|
143
|
-
|
140
|
+
return unless sub.name.to_s.include? "::"
|
144
141
|
|
145
|
-
|
146
|
-
end
|
142
|
+
system = Object.const_get sub.first_namespace
|
147
143
|
|
144
|
+
sub.set :system, system
|
148
145
|
end
|
149
146
|
|
150
147
|
end
|
148
|
+
|
151
149
|
end
|
@@ -7,7 +7,6 @@ class Liza::UnitProcedurePartTest < Liza::UnitTest
|
|
7
7
|
procedure "creates a new scope" do
|
8
8
|
@a = 1
|
9
9
|
b = 2
|
10
|
-
c = 3
|
11
10
|
assert true
|
12
11
|
|
13
12
|
proceed if true
|
@@ -21,7 +20,6 @@ class Liza::UnitProcedurePartTest < Liza::UnitTest
|
|
21
20
|
procedure "asserts old scope is not accessible" do
|
22
21
|
assert instance_variables.include? :@a
|
23
22
|
assert local_variables.include? :b
|
24
|
-
refute local_variables.include? :c
|
25
23
|
|
26
24
|
assert @a == 1
|
27
25
|
assert b == 2
|
@@ -32,13 +30,15 @@ class Liza::UnitProcedurePartTest < Liza::UnitTest
|
|
32
30
|
|
33
31
|
assert x == 100
|
34
32
|
|
35
|
-
y =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
33
|
+
y = procedure "asserts proceed calls can be lazy" do
|
34
|
+
proceed do
|
35
|
+
puts "slow operation"
|
36
|
+
200
|
37
|
+
end if true
|
38
|
+
raise "did not get here"
|
39
|
+
end
|
40
|
+
|
41
|
+
assert y == 200
|
42
42
|
end
|
43
43
|
|
44
44
|
test :procedure_rescue_and_ensure do
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class Liza::UnitSettingsPart < Liza::Part
|
2
|
+
|
3
|
+
insertion do
|
4
|
+
def self.settings
|
5
|
+
@settings ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.get key
|
9
|
+
return settings[key] if settings.has_key? key
|
10
|
+
|
11
|
+
found = nil
|
12
|
+
|
13
|
+
for klass in ancestors
|
14
|
+
break unless klass.respond_to? :settings
|
15
|
+
|
16
|
+
if klass.settings.has_key? key
|
17
|
+
found = klass.settings[key]
|
18
|
+
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
found = settings[key] = found.dup if found.is_a? Enumerable
|
24
|
+
|
25
|
+
found
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.set key, value
|
29
|
+
settings[key] = value
|
30
|
+
value
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.add list, key = nil, value
|
34
|
+
if key
|
35
|
+
fetch(list) { Hash.new }[key] = value
|
36
|
+
else
|
37
|
+
fetch(list) { Set.new } << value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.fetch key, &block
|
42
|
+
x = get key
|
43
|
+
x ||= set key, instance_eval(&block)
|
44
|
+
x
|
45
|
+
end
|
46
|
+
|
47
|
+
def settings
|
48
|
+
@settings ||= {}
|
49
|
+
end
|
50
|
+
|
51
|
+
def get key
|
52
|
+
return settings[key] if settings.has_key? key
|
53
|
+
|
54
|
+
self.class.get key
|
55
|
+
end
|
56
|
+
|
57
|
+
def set key, value
|
58
|
+
settings[key] = value
|
59
|
+
end
|
60
|
+
|
61
|
+
def add list, key = nil, value
|
62
|
+
if key
|
63
|
+
fetch(list) { Hash.new }[key] = value
|
64
|
+
else
|
65
|
+
fetch(list) { Set.new } << value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch key, &block
|
70
|
+
x = get key
|
71
|
+
x ||= set key, eval(&block)
|
72
|
+
x
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|