diff options
| author | Robert Speicher <robert@gitlab.com> | 2016-03-30 15:42:26 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2016-03-30 15:42:26 +0000 |
| commit | 489165e3438c8f0fbbdb4bb0f08f2406f7cafb0c (patch) | |
| tree | 41835ac836e911be2729c83827fcf4614e1f34bd /lib | |
| parent | 8718acdf80f5dcc70fdd625dfb0d073924132628 (diff) | |
| parent | d6097ca402d78fb23383fee2afc91e7bafc604c3 (diff) | |
| download | gitlab-ce-489165e3438c8f0fbbdb4bb0f08f2406f7cafb0c.tar.gz | |
Merge branch 'refactor/project-badges-interface' into 'master'
Refactor builds badge, encapsulate inside a class
This merge requests attempts to introduce interface for all badges.
Currently we only have a build badge, but other badges are in plans,
like coverage badge.
See merge request !3403
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/badge/build.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/gitlab/badge/build.rb b/lib/gitlab/badge/build.rb new file mode 100644 index 00000000000..28a2391dbf8 --- /dev/null +++ b/lib/gitlab/badge/build.rb @@ -0,0 +1,24 @@ +module Gitlab + module Badge + ## + # Build badge + # + class Build + def initialize(project, ref) + @image = ::Ci::ImageForBuildService.new.execute(project, ref: ref) + end + + def to_s + @image[:name].sub(/\.svg$/, '') + end + + def type + 'image/svg+xml' + end + + def data + File.read(@image[:path]) + end + end + end +end |
