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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-23 13:24:18 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-29 10:01:19 +0300
commit4cd1b9f4d82efe3ffe810dabf6929a749c36c1bf (patch)
tree907813709b26f17c94b8a8e9234bea07e0935e4d /lib/gitlab/badge
parent63c8a05bf7f18ac4093ece1f08b4b5fd8dba5fac (diff)
Refactor builds badge, encapsulate inside a class
Diffstat (limited to 'lib/gitlab/badge')
-rw-r--r--lib/gitlab/badge/build.rb24
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