BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
dbb9d6a7
Commit
dbb9d6a7
authored
Aug 11, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract base abstract template for badges
parent
796efcc7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
35 deletions
+51
-35
template.rb
lib/gitlab/badge/build/template.rb
+1
-17
template.rb
lib/gitlab/badge/coverage/template.rb
+1
-18
template.rb
lib/gitlab/badge/template.rb
+49
-0
No files found.
lib/gitlab/badge/build/template.rb
View file @
dbb9d6a7
...
...
@@ -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'
,
...
...
@@ -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
...
...
lib/gitlab/badge/coverage/template.rb
View file @
dbb9d6a7
...
...
@@ -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'
,
...
...
@@ -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
]
...
...
@@ -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
...
...
lib/gitlab/badge/template.rb
0 → 100644
View file @
dbb9d6a7
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment