debian-mirror-gitlab/lib/gitlab/usage/docs/value_formatter.rb

29 lines
660 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
module Gitlab
module Usage
module Docs
class ValueFormatter
def self.format(key, value)
2021-04-17 20:07:23 +05:30
return '' unless value.present?
2021-03-11 19:13:27 +05:30
case key
when :key_path
"**`#{value}`**"
when :data_source
value.to_s.capitalize
2021-04-17 20:07:23 +05:30
when :product_group, :product_category, :status
2021-03-11 19:13:27 +05:30
"`#{value}`"
when :introduced_by_url
"[Introduced by](#{value})"
when :distribution, :tier
2021-04-17 20:07:23 +05:30
Array(value).map { |tier| " `#{tier}`" }.join(',')
2021-03-11 19:13:27 +05:30
else
value
end
end
end
end
end
end