Skip to content
Snippets Groups Projects
Commit dbb9d6a7 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Extract base abstract template for badges

parent 796efcc7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,7 +6,7 @@ module Gitlab
#
# Template object will be passed to badge.svg.erb template.
#
class Template
class Template < Badge::Template
STATUS_COLOR = {
success: '#4c1',
failed: '#e05d44',
Loading
Loading
@@ -38,25 +38,9 @@ module Gitlab
54
end
 
def key_color
'#555'
end
def value_color
STATUS_COLOR[@status.to_sym] || STATUS_COLOR[:unknown]
end
def key_text_anchor
key_width / 2
end
def value_text_anchor
key_width + (value_width / 2)
end
def width
key_width + value_width
end
end
end
end
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ module Gitlab
#
# Template object will be passed to badge.svg.erb template.
#
class Template
class Template < Badge::Template
STATUS_COLOR = {
good: '#4c1',
acceptable: '#b0c',
Loading
Loading
@@ -36,13 +36,8 @@ module Gitlab
@status ? 32 : 58
end
 
def key_color
'#555'
end
def value_color
case @status
when nil then STATUS_COLOR[:unknown]
when 95..100 then STATUS_COLOR[:good]
when 90..95 then STATUS_COLOR[:acceptable]
when 75..90 then STATUS_COLOR[:medium]
Loading
Loading
@@ -51,18 +46,6 @@ module Gitlab
STATUS_COLOR[:unknown]
end
end
def key_text_anchor
key_width / 2
end
def value_text_anchor
key_width + (value_width / 2)
end
def width
key_width + value_width
end
end
end
end
Loading
Loading
module Gitlab
module Badge
##
# Abstract template class for badges
#
class Template
def initialize(badge)
@entity = badge.entity
@status = badge.status
end
def key_text
raise NotImplementedError
end
def value_text
raise NotImplementedError
end
def key_width
raise NotImplementedError
end
def value_width
raise NotImplementedError
end
def value_color
raise NotImplementedError
end
def key_color
'#555'
end
def key_text_anchor
key_width / 2
end
def value_text_anchor
key_width + (value_width / 2)
end
def width
key_width + value_width
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment