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-08-11 14:58:57 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-08-15 15:39:46 +0300
commit7b840c8483e2fe17a6c04474323cfb57c3c8a7d3 (patch)
tree5c1ead65acae60d69b24550821b5b88c0271c978 /lib/gitlab/badge
parentcdb0caaf320a67f193a7ab9faac9271a625d8b98 (diff)
Add coverage report badge metadata class
Diffstat (limited to 'lib/gitlab/badge')
-rw-r--r--lib/gitlab/badge/coverage/metadata.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/gitlab/badge/coverage/metadata.rb b/lib/gitlab/badge/coverage/metadata.rb
new file mode 100644
index 00000000000..ae9e5e84051
--- /dev/null
+++ b/lib/gitlab/badge/coverage/metadata.rb
@@ -0,0 +1,38 @@
+module Gitlab
+ module Badge
+ module Coverage
+ ##
+ # Class that describes coverage badge metadata
+ #
+ class Metadata
+ include Gitlab::Application.routes.url_helpers
+ include ActionView::Helpers::AssetTagHelper
+ include ActionView::Helpers::UrlHelper
+
+ def initialize(badge)
+ @project = badge.project
+ @ref = badge.ref
+ @job = badge.job
+ end
+
+ def to_html
+ link_to(image_tag(image_url, alt: 'coverage report'), link_url)
+ end
+
+ def to_markdown
+ "[![coverage report](#{image_url})](#{link_url})"
+ end
+
+ def image_url
+ coverage_namespace_project_badges_url(@project.namespace,
+ @project, @ref,
+ format: :svg)
+ end
+
+ def link_url
+ namespace_project_commits_url(@project.namespace, @project, id: @ref)
+ end
+ end
+ end
+ end
+end