diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-28 16:30:05 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-28 16:30:05 +0300 |
commit | 503c44ee2a66e3e160a9ca9c02aba14a8aa7e310 (patch) | |
tree | 475d91040aad41847c33c3ad363b7acb9693d8e0 /lib/gitlab/badge | |
parent | 0c4fa8619ca477c0a78c825df8dd38cd2a109644 (diff) |
Add badge template class to use with SVG ERB template
Diffstat (limited to 'lib/gitlab/badge')
-rw-r--r-- | lib/gitlab/badge/build/template.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/gitlab/badge/build/template.rb b/lib/gitlab/badge/build/template.rb new file mode 100644 index 00000000000..a7c2e176935 --- /dev/null +++ b/lib/gitlab/badge/build/template.rb @@ -0,0 +1,63 @@ +module Gitlab + module Badge + class Build + ## + # Abstract class for build badge template. + # + # Template object will be passed to badge.svg.erb template. + # + class Template + STATUS_COLOR = { + success: '#4c1', + failed: '#e05d44', + running: '#dfb317', + pending: '#dfb317', + canceled: '#9f9f9f', + skipped: '#9f9f9f', + unknown: '#9f9f9f' + } + + def initialize(status) + @status = status + end + + def key_text + 'build' + end + + def value_text + @status + end + + def key_width + 38 + end + + def value_width + 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 +end |