diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-23 11:24:18 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-29 09:01:19 +0200 |
commit | 4cd1b9f4d82efe3ffe810dabf6929a749c36c1bf (patch) | |
tree | 907813709b26f17c94b8a8e9234bea07e0935e4d /lib | |
parent | 63c8a05bf7f18ac4093ece1f08b4b5fd8dba5fac (diff) | |
download | gitlab-ce-4cd1b9f4d82efe3ffe810dabf6929a749c36c1bf.tar.gz |
Refactor builds badge, encapsulate inside a class
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 |