diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-11 14:08:27 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-15 14:39:46 +0200 |
commit | cc244160c5e2ecda2818348cb6b909f1dcb96e44 (patch) | |
tree | e4ac983c20b6caaddd8c6afd069a93a644c04104 /lib/gitlab/badge/metadata.rb | |
parent | 7b840c8483e2fe17a6c04474323cfb57c3c8a7d3 (diff) | |
download | gitlab-ce-cc244160c5e2ecda2818348cb6b909f1dcb96e44.tar.gz |
Extract the abstract base class of badge metadata
Diffstat (limited to 'lib/gitlab/badge/metadata.rb')
-rw-r--r-- | lib/gitlab/badge/metadata.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/gitlab/badge/metadata.rb b/lib/gitlab/badge/metadata.rb new file mode 100644 index 00000000000..548f85b78bb --- /dev/null +++ b/lib/gitlab/badge/metadata.rb @@ -0,0 +1,36 @@ +module Gitlab + module Badge + ## + # Abstract class for badge metadata + # + class Metadata + include Gitlab::Application.routes.url_helpers + include ActionView::Helpers::AssetTagHelper + include ActionView::Helpers::UrlHelper + + def initialize(badge) + @badge = badge + end + + def to_html + link_to(image_tag(image_url, alt: title), link_url) + end + + def to_markdown + "[![#{title}](#{image_url})](#{link_url})" + end + + def title + raise NotImplementedError + end + + def image_url + raise NotImplementedError + end + + def link_url + raise NotImplementedError + end + end + end +end |