data/generate_constants.rb in unicode-emoji-3.1.0 vs data/generate_constants.rb in unicode-emoji-3.1.1

- old
+ new

@@ -13,11 +13,13 @@ def write_regex(const_name, regex, dirpath) filename = const_name.to_s.downcase filepath = File.join(dirpath, "#{filename}.rb") File.write(filepath, <<~CONTENT) - # This file was generated. Please, do not edit this file by hand. + # This file was generated by a script, please do not edit it by hand. + # See `$ rake generate_constants` and data/generate_constants.rb for more info. + module Unicode module Emoji #{const_name} = #{regex.inspect} end end @@ -113,17 +115,20 @@ emoji_modifier_sequence, non_component_emoji_presentation_sequence, emoji_well_formed_flag_sequence, ) + # Sort to make sure complex sequences match first emoji_rgi_tag_sequence = \ - pack_and_join(RECOMMENDED_SUBDIVISION_FLAGS) + pack_and_join(RECOMMENDED_SUBDIVISION_FLAGS.sort_by(&:length).reverse) emoji_valid_tag_sequence = \ "(?:" + pack(EMOJI_TAG_BASE_FLAG) + - "(?:" + VALID_SUBDIVISIONS.map{ |sd| Regexp.escape(sd.tr("\u{20}-\u{7E}", "\u{E0020}-\u{E007E}"))}.join("|") + ")" + + "(?:" + VALID_SUBDIVISIONS.sort_by(&:length).reverse.map{ |sd| + Regexp.escape(sd.tr("\u{20}-\u{7E}", "\u{E0020}-\u{E007E}")) + }.join("|") + ")" + pack(CANCEL_TAG) + ")" emoji_well_formed_tag_sequence = \ "(?:" + @@ -133,11 +138,12 @@ ) + pack_and_join(TAGS) + "+" + pack(CANCEL_TAG) + ")" + # Sort to make sure complex sequences match first emoji_rgi_zwj_sequence = \ - pack_and_join(RECOMMENDED_ZWJ_SEQUENCES) + pack_and_join(RECOMMENDED_ZWJ_SEQUENCES.sort_by(&:length).reverse) emoji_valid_zwj_element = \ join( emoji_modifier_sequence, emoji_presentation_sequence,