Sha256: 402d55f44038df2ba2a32110766e61e75fedb28cfd950df07406601151daeff8

Contents?: true

Size: 879 Bytes

Versions: 10

Compression:

Stored size: 879 Bytes

Contents

module Danger
  class EmojiMapper
    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

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

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

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

    private

    attr_reader :template
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
danger-9.1.0 lib/danger/helpers/emoji_mapper.rb
danger-9.0.0 lib/danger/helpers/emoji_mapper.rb
danger-8.6.1 lib/danger/helpers/emoji_mapper.rb
danger-8.6.0 lib/danger/helpers/emoji_mapper.rb
danger-8.5.0 lib/danger/helpers/emoji_mapper.rb
danger-8.4.5 lib/danger/helpers/emoji_mapper.rb
danger-8.4.4 lib/danger/helpers/emoji_mapper.rb
danger-8.4.3 lib/danger/helpers/emoji_mapper.rb
danger-8.4.2 lib/danger/helpers/emoji_mapper.rb
danger-8.4.1 lib/danger/helpers/emoji_mapper.rb