File tree 3 files changed +51
-35
lines changed
3 files changed +51
-35
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module Build
6
6
#
7
7
# Template object will be passed to badge.svg.erb template.
8
8
#
9
- class Template
9
+ class Template < Badge :: Template
10
10
STATUS_COLOR = {
11
11
success : '#4c1' ,
12
12
failed : '#e05d44' ,
@@ -38,25 +38,9 @@ def value_width
38
38
54
39
39
end
40
40
41
- def key_color
42
- '#555'
43
- end
44
-
45
41
def value_color
46
42
STATUS_COLOR [ @status . to_sym ] || STATUS_COLOR [ :unknown ]
47
43
end
48
-
49
- def key_text_anchor
50
- key_width / 2
51
- end
52
-
53
- def value_text_anchor
54
- key_width + ( value_width / 2 )
55
- end
56
-
57
- def width
58
- key_width + value_width
59
- end
60
44
end
61
45
end
62
46
end
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module Coverage
6
6
#
7
7
# Template object will be passed to badge.svg.erb template.
8
8
#
9
- class Template
9
+ class Template < Badge :: Template
10
10
STATUS_COLOR = {
11
11
good : '#4c1' ,
12
12
acceptable : '#b0c' ,
@@ -36,13 +36,8 @@ def value_width
36
36
@status ? 32 : 58
37
37
end
38
38
39
- def key_color
40
- '#555'
41
- end
42
-
43
39
def value_color
44
40
case @status
45
- when nil then STATUS_COLOR [ :unknown ]
46
41
when 95 ..100 then STATUS_COLOR [ :good ]
47
42
when 90 ..95 then STATUS_COLOR [ :acceptable ]
48
43
when 75 ..90 then STATUS_COLOR [ :medium ]
@@ -51,18 +46,6 @@ def value_color
51
46
STATUS_COLOR [ :unknown ]
52
47
end
53
48
end
54
-
55
- def key_text_anchor
56
- key_width / 2
57
- end
58
-
59
- def value_text_anchor
60
- key_width + ( value_width / 2 )
61
- end
62
-
63
- def width
64
- key_width + value_width
65
- end
66
49
end
67
50
end
68
51
end
Original file line number Diff line number Diff line change
1
+ module Gitlab
2
+ module Badge
3
+ ##
4
+ # Abstract template class for badges
5
+ #
6
+ class Template
7
+ def initialize ( badge )
8
+ @entity = badge . entity
9
+ @status = badge . status
10
+ end
11
+
12
+ def key_text
13
+ raise NotImplementedError
14
+ end
15
+
16
+ def value_text
17
+ raise NotImplementedError
18
+ end
19
+
20
+ def key_width
21
+ raise NotImplementedError
22
+ end
23
+
24
+ def value_width
25
+ raise NotImplementedError
26
+ end
27
+
28
+ def value_color
29
+ raise NotImplementedError
30
+ end
31
+
32
+ def key_color
33
+ '#555'
34
+ end
35
+
36
+ def key_text_anchor
37
+ key_width / 2
38
+ end
39
+
40
+ def value_text_anchor
41
+ key_width + ( value_width / 2 )
42
+ end
43
+
44
+ def width
45
+ key_width + value_width
46
+ end
47
+ end
48
+ end
49
+ end
You can’t perform that action at this time.
0 commit comments