lib/prawn/emoji/index.rb in prawn-emoji-2.1.1 vs lib/prawn/emoji/index.rb in prawn-emoji-3.0.0

- old
+ new

@@ -3,37 +3,23 @@ require_relative 'unicode' module Prawn module Emoji class Index - EXCLUSION_CHARS = '1234567890#*'.freeze - attr_reader :codepoints def initialize @codepoints = load_emoji_codepoints end - def to_regexp - @regexp ||= build_regexp + def include?(codepoint) + codepoints.include?(codepoint) end private - def build_regexp - emojis = codepoints.map { |codepoint| unicode(codepoint) } - variation_selectors = Emoji::Unicode::VARIATION_SELECTORS.values - - Regexp.new("(#{emojis.join('|')})[#{variation_selectors.join}]?") - end - def load_emoji_codepoints - codepoints = YAML.load_file(Emoji.root.join('emoji', 'index.yml')) - codepoints.reject { |codepoint| /#{unicode(codepoint)}/ =~ EXCLUSION_CHARS } - end - - def unicode(codepoint) - "\\u{#{codepoint.split('-').join(' ')}}" + YAML.load_file(Emoji.root.join('emoji', 'index.yml')) end end end end