Class: Danger::EmojiMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/danger/helpers/emoji_mapper.rb

Constant Summary collapse

DATA =
{
  "github" => {
    "no_entry_sign"    => "🚫",
    "warning"          => "⚠️",
    "book"             => "📖",
    "white_check_mark" => ""
  },
  "bitbucket_server" => {
    "no_entry_sign"    => ":no_entry_sign:",
    "warning"          => ":warning:",
    "book"             => ":blue_book:",
    "white_check_mark" => ":white_check_mark:"
  }
}.freeze
TYPE_TO_EMOJI =
{
  error: "no_entry_sign",
  warning: "warning",
  message: "book"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ EmojiMapper

Returns a new instance of EmojiMapper.



24
25
26
# File 'lib/danger/helpers/emoji_mapper.rb', line 24

def initialize(template)
  @template = DATA.has_key?(template) ? template : "github"
end

Instance Method Details

#from_type(type) ⇒ Object



33
34
35
# File 'lib/danger/helpers/emoji_mapper.rb', line 33

def from_type(type)
  map(TYPE_TO_EMOJI[type])
end

#map(emoji) ⇒ Object



28
29
30
31
# File 'lib/danger/helpers/emoji_mapper.rb', line 28

def map(emoji)
  emoji&.delete! ":"
  DATA[template][emoji]
end