Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/badge')
-rw-r--r--lib/gitlab/ci/badge/coverage/template.rb16
-rw-r--r--lib/gitlab/ci/badge/pipeline/template.rb16
-rw-r--r--lib/gitlab/ci/badge/template.rb13
3 files changed, 11 insertions, 34 deletions
diff --git a/lib/gitlab/ci/badge/coverage/template.rb b/lib/gitlab/ci/badge/coverage/template.rb
index 7589fa5ff8b..96702420e9d 100644
--- a/lib/gitlab/ci/badge/coverage/template.rb
+++ b/lib/gitlab/ci/badge/coverage/template.rb
@@ -24,26 +24,10 @@ module Gitlab::Ci
@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
diff --git a/lib/gitlab/ci/badge/pipeline/template.rb b/lib/gitlab/ci/badge/pipeline/template.rb
index 8430b01fc9a..c39f96e4a34 100644
--- a/lib/gitlab/ci/badge/pipeline/template.rb
+++ b/lib/gitlab/ci/badge/pipeline/template.rb
@@ -28,26 +28,10 @@ module Gitlab::Ci
@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_RENAME[@status.to_s] || @status.to_s
end
- def key_width
- if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
- @key_width
- else
- 62
- end
- end
-
def value_width
54
end
diff --git a/lib/gitlab/ci/badge/template.rb b/lib/gitlab/ci/badge/template.rb
index 0580dad72ba..d514a8577bd 100644
--- a/lib/gitlab/ci/badge/template.rb
+++ b/lib/gitlab/ci/badge/template.rb
@@ -8,6 +8,7 @@ module Gitlab::Ci
class Template
MAX_KEY_TEXT_SIZE = 64
MAX_KEY_WIDTH = 512
+ DEFAULT_KEY_WIDTH = 62
def initialize(badge)
@entity = badge.entity
@@ -15,7 +16,11 @@ module Gitlab::Ci
end
def key_text
- raise NotImplementedError
+ if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
+ @key_text
+ else
+ @entity.to_s
+ end
end
def value_text
@@ -23,7 +28,11 @@ module Gitlab::Ci
end
def key_width
- raise NotImplementedError
+ if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
+ @key_width
+ else
+ DEFAULT_KEY_WIDTH
+ end
end
def value_width