File tree Expand file tree Collapse file tree 3 files changed +25
-23
lines changed Expand file tree Collapse file tree 3 files changed +25
-23
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,24 @@ module Spec
116
116
Fail
117
117
Error
118
118
Pending
119
+
120
+ def color : Colorize ::Color
121
+ case self
122
+ in Success then Colorize ::ColorANSI ::Green
123
+ in Fail then Colorize ::ColorANSI ::Red
124
+ in Error then Colorize ::ColorANSI ::Red
125
+ in Pending then Colorize ::ColorANSI ::Yellow
126
+ end
127
+ end
128
+
129
+ def letter : Char
130
+ case self
131
+ in Success then '.'
132
+ in Fail then 'F'
133
+ in Error then 'E'
134
+ in Pending then '*'
135
+ end
136
+ end
119
137
end
120
138
121
139
# :nodoc:
Original file line number Diff line number Diff line change @@ -11,36 +11,20 @@ module Spec
11
11
Comment
12
12
Focus
13
13
Order
14
- end
15
14
16
- private STATUS_COLORS = {
17
- Status ::Success => :green ,
18
- Status ::Fail => :red ,
19
- Status ::Error => :red ,
20
- Status ::Pending => :yellow ,
21
- }
22
-
23
- private INFO_COLORS = {
24
- InfoKind ::Comment => :cyan ,
25
- InfoKind ::Focus => :cyan ,
26
- InfoKind ::Order => :cyan ,
27
- }
28
-
29
- private LETTERS = {
30
- Status ::Success => '.' ,
31
- Status ::Fail => 'F' ,
32
- Status ::Error => 'E' ,
33
- Status ::Pending => '*' ,
34
- }
15
+ def color : Colorize ::Color
16
+ Colorize ::ColorANSI ::Cyan
17
+ end
18
+ end
35
19
36
20
# :nodoc:
37
21
def self.color (str, status : Status )
38
- str.colorize(STATUS_COLORS [ status] )
22
+ str.colorize(status.color )
39
23
end
40
24
41
25
# :nodoc:
42
26
def self.color (str, kind : InfoKind )
43
- str.colorize(INFO_COLORS [ kind] )
27
+ str.colorize(kind.color )
44
28
end
45
29
46
30
# :nodoc:
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ module Spec
38
38
end
39
39
40
40
def report (result )
41
- @io << Spec .color(LETTERS [ result.kind] , result.kind)
41
+ @io << Spec .color(result.kind.letter , result.kind)
42
42
split_lines
43
43
@io .flush
44
44
end
You can’t perform that action at this time.
0 commit comments