tanuki_emoji 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e7bf9a9abf605fa2e3f868f206d9a0f7377534a6275b9a78b1a448a5c7f849c
4
- data.tar.gz: 804bf6e8b0b050272faad1181d7c745db82ebf0e5801e7dc9f0b64c8b51d7c35
3
+ metadata.gz: 813531e905727359e63b0cc535a5c2e7f4f418536d1aa22c1fc93515f47fbbe9
4
+ data.tar.gz: fa5fe7bbeddee299620bc45ba7fe1fb387ae963b2e0d4f5c9b26d229732631e1
5
5
  SHA512:
6
- metadata.gz: 051257a30fc6814b39022ce66a0cf0cd45918c6fbb4ed37a8e2a2a9b4e260350fb6b48eb8209ee75a671251ca0182a06c4de32d1a651186d45d4a2fefb15f918
7
- data.tar.gz: 9f00f66143cffff45889229472a70f72543d5bf825ae1af5d77ffa2181005cc9eeb1fa850e51b1192adbe1d6dfaa41243cfec0c97e084a0b587e1c2b1709967a
6
+ metadata.gz: 7c0268dbd2f81f2994171dfc6aa42373537824fd7ce4568555a60ee8a5608241ace1386e6f2e063997e7d148261c386174427793d46ef4dd53675c57add48928
7
+ data.tar.gz: 46c771d114d9f0529dfcd47b161988ccf57f1f73674b12253b1d28241ca75445ce1e678aa801cdc96547cbf9a9e37911b0007a45421ddaa25df2d1f7600c3eaa
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 0.9.0 (2023-10-17)
8
+
9
+ ### Added (1 change)
10
+
11
+ - [Added ordering information to to `Character`](gitlab-org/ruby/gems/tanuki_emoji@c618fae04409067a38ddc454d3dfaee4678da520) ([merge request](gitlab-org/ruby/gems/tanuki_emoji!61))
12
+
7
13
  ## 0.8.0 (2023-09-15)
8
14
 
9
15
  ### Changed (1 change)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tanuki_emoji (0.8.0)
4
+ tanuki_emoji (0.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -23,7 +23,7 @@ module TanukiEmoji
23
23
 
24
24
  attr_reader :name, :codepoints, :codepoints_alternates, :alpha_code, :aliases, :ascii_aliases, :description, :category
25
25
 
26
- attr_accessor :unicode_version
26
+ attr_accessor :unicode_version, :sort_key
27
27
 
28
28
  # @param [String] name
29
29
  # @param [String] codepoints
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TanukiEmoji
4
+ module Db
5
+ # Emoji Unicode Ordering database
6
+ class UnicodeOrdering
7
+ DATA_FILE = 'vendor/unicode/emoji-ordering.txt'
8
+
9
+ def self.data_file
10
+ File.expand_path(File.join(__dir__, '../../../', DATA_FILE))
11
+ end
12
+
13
+ attr_reader :data_file
14
+
15
+ def initialize(index:, data_file: nil)
16
+ @data_file = data_file || self.class.data_file
17
+ @index = index
18
+ end
19
+
20
+ def load!
21
+ db = {}
22
+ File.readlines(data_file, mode: 'r:UTF-8').each_with_index do |line, line_number|
23
+ next if line.start_with?('#')
24
+
25
+ tokens = line.split
26
+ semicolon_offset = tokens.index(';')
27
+ next if semicolon_offset.nil?
28
+
29
+ codepoints_array = tokens[0...semicolon_offset].map do |token|
30
+ token[2...token.length].hex
31
+ end
32
+ codepoints = codepoints_array.pack('U*')
33
+
34
+ db[codepoints] = line_number
35
+ end
36
+
37
+ db.each do |codepoints, sort_key|
38
+ emoji = @index.find_by_codepoints(codepoints)
39
+
40
+ next unless emoji
41
+
42
+ emoji.sort_key = sort_key
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -3,6 +3,7 @@
3
3
  module TanukiEmoji
4
4
  module Db
5
5
  autoload :Gemojione, 'tanuki_emoji/db/gemojione'
6
+ autoload :UnicodeOrdering, 'tanuki_emoji/db/unicode_ordering'
6
7
  autoload :UnicodeVersion, 'tanuki_emoji/db/unicode_version'
7
8
  autoload :EmojiData, 'tanuki_emoji/db/emoji_data'
8
9
  autoload :EmojiDataParser, 'tanuki_emoji/db/emoji_data_parser'
@@ -114,6 +114,7 @@ module TanukiEmoji
114
114
  def load_data_files
115
115
  Db::Gemojione.new(index: self).load!
116
116
  Db::UnicodeVersion.new(index: self).load!
117
+ Db::UnicodeOrdering.new(index: self).load!
117
118
  end
118
119
 
119
120
  # Order the codepoints to match the most specific (longest) sequences first,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TanukiEmoji
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end