diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /lib/gitlab/badge/coverage/template.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'lib/gitlab/badge/coverage/template.rb')
-rw-r--r-- | lib/gitlab/badge/coverage/template.rb | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/gitlab/badge/coverage/template.rb b/lib/gitlab/badge/coverage/template.rb deleted file mode 100644 index 1b985f83b22..00000000000 --- a/lib/gitlab/badge/coverage/template.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Badge - module Coverage - ## - # Class that represents a coverage badge template. - # - # Template object will be passed to badge.svg.erb template. - # - class Template < Badge::Template - STATUS_COLOR = { - good: '#4c1', - acceptable: '#a3c51c', - medium: '#dfb317', - low: '#e05d44', - unknown: '#9f9f9f' - }.freeze - - def initialize(badge) - @entity = badge.entity - @status = badge.status - @key_text = badge.customization.dig(:key_text) - @key_width = badge.customization.dig(:key_width) - end - - def key_text - if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE - @key_text - else - @entity.to_s - end - end - - def value_text - @status ? ("%.2f%%" % @status) : 'unknown' - end - - def key_width - if @key_width && @key_width.between?(1, MAX_KEY_WIDTH) - @key_width - else - 62 - end - end - - def value_width - @status ? 54 : 58 - end - - def value_color - case @status - when 95..100 then STATUS_COLOR[:good] - when 90..95 then STATUS_COLOR[:acceptable] - when 75..90 then STATUS_COLOR[:medium] - when 0..75 then STATUS_COLOR[:low] - else - STATUS_COLOR[:unknown] - end - end - end - end - end -end |