tanuki_emoji 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab/CODEOWNERS +1 -1
- data/.rubocop.yml +23 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +117 -82
- data/lib/tanuki_emoji/character.rb +27 -16
- data/lib/tanuki_emoji/db/additional_aliases.rb +1 -1
- data/lib/tanuki_emoji/db/emoji_data.rb +1 -1
- data/lib/tanuki_emoji/db/emoji_data_parser.rb +1 -1
- data/lib/tanuki_emoji/db/emoji_test_parser.rb +13 -7
- data/lib/tanuki_emoji/db/gemojione.rb +26 -2
- data/lib/tanuki_emoji/db/unicode_ordering.rb +1 -1
- data/lib/tanuki_emoji/errors.rb +3 -3
- data/lib/tanuki_emoji/index.rb +4 -2
- data/lib/tanuki_emoji/version.rb +1 -1
- data/lib/tanuki_emoji.rb +4 -4
- data/tanuki_emoji.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cd69298cf8929ea174ffe7bbd233d4c109ea8718be551f5360d6fc5780de7aa
|
4
|
+
data.tar.gz: 9ebc786c9887e0653d970a201863030a7d1b6db7a8321ffa7a5aa71e45217b2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074d89b94fb55ff415bc373a3a93c328c88a25a2d3ddb4f9c55f17531c8d666231c830aef305163159e62f1494969e995b4c8ea13204672a07d17811cd27c952
|
7
|
+
data.tar.gz: 66727db990cce5221e0c9008fb19ec033fed3ad47ddcc00c52ecbee3b7c52237d00d8c69cf05125463ff527d31859af3b341cdca2be16a139beee1a2cbbc81d6
|
data/.gitlab/CODEOWNERS
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
[Maintainers]
|
2
|
-
* @brodock @
|
2
|
+
* @brodock @mwoolf @kerrizor @brytannia @splattael @digitalmoksha @smcgivern @jlear
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
gitlab-styles:
|
3
|
+
- rubocop-bundler.yml
|
4
|
+
- rubocop-gemspec.yml
|
5
|
+
- rubocop-layout.yml
|
6
|
+
- rubocop-lint.yml
|
7
|
+
- rubocop-metrics.yml
|
8
|
+
- rubocop-naming.yml
|
9
|
+
- rubocop-performance.yml
|
10
|
+
- rubocop-rspec.yml
|
11
|
+
- rubocop-security.yml
|
12
|
+
- rubocop-style.yml
|
13
|
+
|
1
14
|
AllCops:
|
15
|
+
NewCops: enable
|
2
16
|
TargetRubyVersion: 3.0
|
3
17
|
Exclude:
|
4
18
|
- '*.gemspec'
|
@@ -17,3 +31,12 @@ Layout/LineLength:
|
|
17
31
|
|
18
32
|
Metrics:
|
19
33
|
Enabled: false
|
34
|
+
|
35
|
+
RSpec/BeEq:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
InternalAffairs/MissingCopDepartment:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
RSpec/MultipleMemoizedHelpers:
|
42
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ 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.12.0 (2024-10-22)
|
8
|
+
|
9
|
+
### Fixed (2 changes)
|
10
|
+
|
11
|
+
- [Make the gemojione codes primary over Unicode codes](https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/commit/03c59b5ea12e67290c4078c47148ddfa87a2940d) ([merge request](https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/merge_requests/73))
|
12
|
+
- [Remove trailing underscaore from emoji names](https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/commit/82e9574c2b58e37937baaf8c4a6099001b3cd455) ([merge request](https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/merge_requests/72))
|
13
|
+
|
7
14
|
## 0.11.0 (2024-10-02)
|
8
15
|
|
9
16
|
### Added (1 change)
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tanuki_emoji (0.
|
4
|
+
tanuki_emoji (0.12.0)
|
5
5
|
i18n (~> 1.14)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
10
|
+
activesupport (7.1.4)
|
11
|
+
base64
|
12
|
+
bigdecimal
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
connection_pool (>= 2.2.5)
|
15
|
+
drb
|
16
|
+
i18n (>= 1.6, < 2)
|
17
|
+
minitest (>= 5.1)
|
18
|
+
mutex_m
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
addressable (2.8.7)
|
21
|
+
public_suffix (>= 2.0.2, < 7.0)
|
12
22
|
ast (2.4.2)
|
23
|
+
base64 (0.2.0)
|
24
|
+
bigdecimal (3.1.8)
|
13
25
|
byebug (11.1.3)
|
14
26
|
claide (1.1.0)
|
15
27
|
claide-plugins (0.9.2)
|
@@ -19,137 +31,159 @@ GEM
|
|
19
31
|
coderay (1.1.3)
|
20
32
|
colored2 (3.1.2)
|
21
33
|
concurrent-ruby (1.3.4)
|
34
|
+
connection_pool (2.4.1)
|
22
35
|
cork (0.3.0)
|
23
36
|
colored2 (~> 3.1)
|
24
|
-
|
37
|
+
csv (3.3.0)
|
38
|
+
danger (9.5.0)
|
25
39
|
claide (~> 1.0)
|
26
40
|
claide-plugins (>= 0.9.2)
|
27
41
|
colored2 (~> 3.1)
|
28
42
|
cork (~> 0.1)
|
29
|
-
faraday (>= 0.9.0, <
|
43
|
+
faraday (>= 0.9.0, < 3.0)
|
30
44
|
faraday-http-cache (~> 2.0)
|
31
|
-
git (~> 1.
|
45
|
+
git (~> 1.13)
|
32
46
|
kramdown (~> 2.3)
|
33
47
|
kramdown-parser-gfm (~> 1.0)
|
34
|
-
|
35
|
-
octokit (~> 4.7)
|
48
|
+
octokit (>= 4.0)
|
36
49
|
terminal-table (>= 1, < 4)
|
37
50
|
danger-gitlab (8.0.0)
|
38
51
|
danger
|
39
52
|
gitlab (~> 4.2, >= 4.2.0)
|
40
|
-
diff-lcs (1.
|
41
|
-
docile (1.4.
|
42
|
-
|
43
|
-
|
44
|
-
faraday-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
faraday-net_http (~> 1.0)
|
49
|
-
faraday-net_http_persistent (~> 1.0)
|
50
|
-
faraday-patron (~> 1.0)
|
51
|
-
faraday-rack (~> 1.0)
|
52
|
-
faraday-retry (~> 1.0)
|
53
|
-
ruby2_keywords (>= 0.0.4)
|
54
|
-
faraday-em_http (1.0.0)
|
55
|
-
faraday-em_synchrony (1.0.0)
|
56
|
-
faraday-excon (1.1.0)
|
57
|
-
faraday-http-cache (2.2.0)
|
53
|
+
diff-lcs (1.5.1)
|
54
|
+
docile (1.4.1)
|
55
|
+
drb (2.2.1)
|
56
|
+
faraday (2.12.0)
|
57
|
+
faraday-net_http (>= 2.0, < 3.4)
|
58
|
+
json
|
59
|
+
logger
|
60
|
+
faraday-http-cache (2.5.1)
|
58
61
|
faraday (>= 0.8)
|
59
|
-
faraday-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
faraday-net_http_persistent (1.2.0)
|
64
|
-
faraday-patron (1.0.0)
|
65
|
-
faraday-rack (1.0.0)
|
66
|
-
faraday-retry (1.0.3)
|
67
|
-
git (1.10.2)
|
62
|
+
faraday-net_http (3.3.0)
|
63
|
+
net-http
|
64
|
+
git (1.19.1)
|
65
|
+
addressable (~> 2.8)
|
68
66
|
rchardet (~> 1.8)
|
69
|
-
gitlab (4.
|
70
|
-
httparty (~> 0.
|
67
|
+
gitlab (4.20.1)
|
68
|
+
httparty (~> 0.20)
|
71
69
|
terminal-table (>= 1.5.1)
|
72
70
|
gitlab-dangerfiles (2.11.0)
|
73
71
|
danger (>= 8.4.5)
|
74
72
|
danger-gitlab (>= 8.0.0)
|
75
|
-
|
76
|
-
|
73
|
+
gitlab-styles (12.0.1)
|
74
|
+
rubocop (~> 1.62.1)
|
75
|
+
rubocop-factory_bot (~> 2.25.1)
|
76
|
+
rubocop-graphql (~> 1.5.0)
|
77
|
+
rubocop-performance (~> 1.20.2)
|
78
|
+
rubocop-rails (~> 2.24.0)
|
79
|
+
rubocop-rspec (~> 2.27.1)
|
80
|
+
httparty (0.22.0)
|
81
|
+
csv
|
82
|
+
mini_mime (>= 1.0.0)
|
77
83
|
multi_xml (>= 0.5.2)
|
78
84
|
i18n (1.14.6)
|
79
85
|
concurrent-ruby (~> 1.0)
|
80
|
-
|
86
|
+
json (2.7.2)
|
87
|
+
kramdown (2.4.0)
|
81
88
|
rexml
|
82
89
|
kramdown-parser-gfm (1.1.0)
|
83
90
|
kramdown (~> 2.0)
|
91
|
+
language_server-protocol (3.17.0.3)
|
92
|
+
logger (1.6.1)
|
84
93
|
method_source (1.1.0)
|
85
|
-
|
86
|
-
|
87
|
-
mime-types-data (3.2022.0105)
|
94
|
+
mini_mime (1.1.5)
|
95
|
+
minitest (5.25.1)
|
88
96
|
multi_xml (0.6.0)
|
89
|
-
|
97
|
+
mutex_m (0.2.0)
|
90
98
|
nap (1.1.0)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
99
|
+
net-http (0.4.1)
|
100
|
+
uri
|
101
|
+
octokit (9.1.0)
|
102
|
+
faraday (>= 1, < 3)
|
103
|
+
sawyer (~> 0.9)
|
95
104
|
open4 (1.3.4)
|
96
|
-
parallel (1.
|
97
|
-
parser (3.
|
105
|
+
parallel (1.26.3)
|
106
|
+
parser (3.3.5.0)
|
98
107
|
ast (~> 2.4.1)
|
108
|
+
racc
|
99
109
|
pry (0.14.2)
|
100
110
|
coderay (~> 1.1)
|
101
111
|
method_source (~> 1.0)
|
102
112
|
pry-byebug (3.10.1)
|
103
113
|
byebug (~> 11.0)
|
104
114
|
pry (>= 0.13, < 0.15)
|
105
|
-
public_suffix (
|
106
|
-
|
107
|
-
|
115
|
+
public_suffix (6.0.1)
|
116
|
+
racc (1.8.1)
|
117
|
+
rack (3.1.7)
|
118
|
+
rainbow (3.1.1)
|
119
|
+
rake (13.2.1)
|
108
120
|
rchardet (1.8.0)
|
109
|
-
regexp_parser (2.
|
110
|
-
rexml (3.
|
111
|
-
rspec (3.
|
112
|
-
rspec-core (~> 3.
|
113
|
-
rspec-expectations (~> 3.
|
114
|
-
rspec-mocks (~> 3.
|
115
|
-
rspec-core (3.
|
116
|
-
rspec-support (~> 3.
|
117
|
-
rspec-expectations (3.
|
121
|
+
regexp_parser (2.9.2)
|
122
|
+
rexml (3.3.8)
|
123
|
+
rspec (3.13.0)
|
124
|
+
rspec-core (~> 3.13.0)
|
125
|
+
rspec-expectations (~> 3.13.0)
|
126
|
+
rspec-mocks (~> 3.13.0)
|
127
|
+
rspec-core (3.13.1)
|
128
|
+
rspec-support (~> 3.13.0)
|
129
|
+
rspec-expectations (3.13.3)
|
118
130
|
diff-lcs (>= 1.2.0, < 2.0)
|
119
|
-
rspec-support (~> 3.
|
120
|
-
rspec-mocks (3.
|
131
|
+
rspec-support (~> 3.13.0)
|
132
|
+
rspec-mocks (3.13.2)
|
121
133
|
diff-lcs (>= 1.2.0, < 2.0)
|
122
|
-
rspec-support (~> 3.
|
123
|
-
rspec-support (3.
|
134
|
+
rspec-support (~> 3.13.0)
|
135
|
+
rspec-support (3.13.1)
|
124
136
|
rspec_junit_formatter (0.4.1)
|
125
137
|
rspec-core (>= 2, < 4, != 2.12.0)
|
126
|
-
rubocop (1.
|
138
|
+
rubocop (1.62.1)
|
139
|
+
json (~> 2.3)
|
140
|
+
language_server-protocol (>= 3.17.0)
|
127
141
|
parallel (~> 1.10)
|
128
|
-
parser (>= 3.
|
142
|
+
parser (>= 3.3.0.2)
|
129
143
|
rainbow (>= 2.2.2, < 4.0)
|
130
144
|
regexp_parser (>= 1.8, < 3.0)
|
131
|
-
rexml
|
132
|
-
rubocop-ast (>= 1.
|
145
|
+
rexml (>= 3.2.5, < 4.0)
|
146
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
133
147
|
ruby-progressbar (~> 1.7)
|
134
|
-
unicode-display_width (>=
|
135
|
-
rubocop-ast (1.
|
136
|
-
parser (>= 3.
|
137
|
-
|
138
|
-
|
139
|
-
|
148
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
149
|
+
rubocop-ast (1.32.3)
|
150
|
+
parser (>= 3.3.1.0)
|
151
|
+
rubocop-capybara (2.21.0)
|
152
|
+
rubocop (~> 1.41)
|
153
|
+
rubocop-factory_bot (2.25.1)
|
154
|
+
rubocop (~> 1.41)
|
155
|
+
rubocop-graphql (1.5.4)
|
156
|
+
rubocop (>= 1.50, < 2)
|
157
|
+
rubocop-performance (1.20.2)
|
158
|
+
rubocop (>= 1.48.1, < 2.0)
|
159
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
160
|
+
rubocop-rails (2.24.1)
|
161
|
+
activesupport (>= 4.2.0)
|
162
|
+
rack (>= 1.1)
|
163
|
+
rubocop (>= 1.33.0, < 2.0)
|
164
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
165
|
+
rubocop-rspec (2.27.1)
|
166
|
+
rubocop (~> 1.40)
|
167
|
+
rubocop-capybara (~> 2.17)
|
168
|
+
rubocop-factory_bot (~> 2.22)
|
169
|
+
ruby-progressbar (1.13.0)
|
170
|
+
sawyer (0.9.2)
|
140
171
|
addressable (>= 2.3.5)
|
141
|
-
faraday (
|
142
|
-
simplecov (0.
|
172
|
+
faraday (>= 0.17.3, < 3)
|
173
|
+
simplecov (0.22.0)
|
143
174
|
docile (~> 1.1)
|
144
175
|
simplecov-html (~> 0.11)
|
145
176
|
simplecov_json_formatter (~> 0.1)
|
146
177
|
simplecov-cobertura (1.4.2)
|
147
178
|
simplecov (~> 0.8)
|
148
|
-
simplecov-html (0.
|
149
|
-
simplecov_json_formatter (0.1.
|
179
|
+
simplecov-html (0.13.1)
|
180
|
+
simplecov_json_formatter (0.1.4)
|
150
181
|
terminal-table (3.0.2)
|
151
182
|
unicode-display_width (>= 1.1.1, < 3)
|
152
|
-
|
183
|
+
tzinfo (2.0.6)
|
184
|
+
concurrent-ruby (~> 1.0)
|
185
|
+
unicode-display_width (2.6.0)
|
186
|
+
uri (0.13.1)
|
153
187
|
|
154
188
|
PLATFORMS
|
155
189
|
ruby
|
@@ -158,11 +192,12 @@ PLATFORMS
|
|
158
192
|
|
159
193
|
DEPENDENCIES
|
160
194
|
gitlab-dangerfiles (~> 2.11.0)
|
195
|
+
gitlab-styles (~> 12.0)
|
161
196
|
pry-byebug
|
162
197
|
rake (~> 13.0)
|
163
198
|
rspec (~> 3.0)
|
164
199
|
rspec_junit_formatter (~> 0.4.0)
|
165
|
-
rubocop (~> 1.
|
200
|
+
rubocop (~> 1.62)
|
166
201
|
simplecov
|
167
202
|
simplecov-cobertura (~> 1.4.2)
|
168
203
|
tanuki_emoji!
|
@@ -25,6 +25,20 @@ module TanukiEmoji
|
|
25
25
|
|
26
26
|
attr_accessor :unicode_version, :sort_key, :noto_image
|
27
27
|
|
28
|
+
# Ensure alpha code is formatted with colons
|
29
|
+
#
|
30
|
+
# @param [String] alpha_code
|
31
|
+
# @return [String] formatted alpha code
|
32
|
+
def self.format_alpha_code(alpha_code)
|
33
|
+
alpha_code.to_s.match?(ALPHA_CODE_REGEXP) ? alpha_code.to_s : ":#{alpha_code}:"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.format_name(raw_name)
|
37
|
+
matched = raw_name.match(ALPHA_CODE_REGEXP)
|
38
|
+
|
39
|
+
matched ? matched['alpha_text'] : raw_name
|
40
|
+
end
|
41
|
+
|
28
42
|
# @param [String] name
|
29
43
|
# @param [String] codepoints
|
30
44
|
# @param [String] alpha_code
|
@@ -72,6 +86,18 @@ module TanukiEmoji
|
|
72
86
|
ascii_aliases << ascii_string
|
73
87
|
end
|
74
88
|
|
89
|
+
# Replace the current alpha_code
|
90
|
+
#
|
91
|
+
# @param [String] alpha_code
|
92
|
+
def replace_alpha_code(alpha_code)
|
93
|
+
formatted_code = self.class.format_alpha_code(alpha_code)
|
94
|
+
|
95
|
+
aliases.delete(formatted_code)
|
96
|
+
|
97
|
+
@name = self.class.format_name(alpha_code)
|
98
|
+
@alpha_code = formatted_code
|
99
|
+
end
|
100
|
+
|
75
101
|
# Return a Hex formatted version of the Unicode code points
|
76
102
|
#
|
77
103
|
# @return [String] Hex formatted version of the unicode
|
@@ -92,8 +118,7 @@ module TanukiEmoji
|
|
92
118
|
name = noto_image
|
93
119
|
|
94
120
|
unless name
|
95
|
-
|
96
|
-
aliases.each do |item|
|
121
|
+
([alpha_code] + aliases).each do |item|
|
97
122
|
name = item.tr(':', '').sub('flag_', '')
|
98
123
|
break if name.length == 2
|
99
124
|
end
|
@@ -131,20 +156,6 @@ module TanukiEmoji
|
|
131
156
|
description == other.description
|
132
157
|
end
|
133
158
|
|
134
|
-
# Ensure alpha code is formatted with colons
|
135
|
-
#
|
136
|
-
# @param [String] alpha_code
|
137
|
-
# @return [String] formatted alpha code
|
138
|
-
def self.format_alpha_code(alpha_code)
|
139
|
-
alpha_code.to_s.match?(ALPHA_CODE_REGEXP) ? alpha_code.to_s : ":#{alpha_code}:"
|
140
|
-
end
|
141
|
-
|
142
|
-
def self.format_name(raw_name)
|
143
|
-
matched = raw_name.match(ALPHA_CODE_REGEXP)
|
144
|
-
|
145
|
-
matched ? matched['alpha_text'] : raw_name
|
146
|
-
end
|
147
|
-
|
148
159
|
private
|
149
160
|
|
150
161
|
# Return each codepoint converted to its hex value as string
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module TanukiEmoji
|
4
4
|
module Db
|
5
5
|
UNICODE_VERSION = '15.1'
|
6
|
-
UNICODE_DATA_DIR = "vendor/unicode/#{UNICODE_VERSION}"
|
6
|
+
UNICODE_DATA_DIR = "vendor/unicode/#{UNICODE_VERSION}".freeze
|
7
7
|
|
8
8
|
EmojiData = Struct.new(:codepoints, :property, :version, :range_size, :examples, :description)
|
9
9
|
EmojiTestData = Struct.new(:codepoints, :qualification, :emoji, :version, :description, :group_category)
|
@@ -8,7 +8,7 @@ module TanukiEmoji
|
|
8
8
|
module Db
|
9
9
|
# Reads and extract content from emoji-data.txt and its metadata
|
10
10
|
class EmojiDataParser
|
11
|
-
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-data.txt"
|
11
|
+
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-data.txt".freeze
|
12
12
|
PROPERTIES = {
|
13
13
|
'Emoji' => :emoji,
|
14
14
|
'Emoji_Presentation' => :emoji_presentation,
|
@@ -10,7 +10,7 @@ module TanukiEmoji
|
|
10
10
|
module Db
|
11
11
|
# Reads and extract content from emoji-test.txt
|
12
12
|
class EmojiTestParser
|
13
|
-
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-test.txt"
|
13
|
+
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-test.txt".freeze
|
14
14
|
|
15
15
|
# https://www.unicode.org/reports/tr51/#Versioning
|
16
16
|
EMOJI_UNICODE_VERSION = {
|
@@ -72,11 +72,17 @@ module TanukiEmoji
|
|
72
72
|
|
73
73
|
data.each do |emoji_data|
|
74
74
|
I18n.with_locale(:en) do
|
75
|
-
alpha_code = I18n.transliterate(emoji_data.description)
|
75
|
+
alpha_code = I18n.transliterate(emoji_data.description)
|
76
|
+
.gsub(/[^a-zA-Z#*\d]+/, '_')
|
77
|
+
.downcase
|
78
|
+
.chomp('_')
|
76
79
|
end
|
77
80
|
|
81
|
+
alpha_code = 'keycap_asterisk' if alpha_code == 'keycap_*'
|
82
|
+
alpha_code = 'keycap_hash' if alpha_code == 'keycap_#'
|
83
|
+
|
78
84
|
# This might be a different qualified version, basically same emoji but slightly different
|
79
|
-
#
|
85
|
+
# code point. Search on the alpha code and pull that. If found, add as alternate code point.
|
80
86
|
# "smiling face" is one example.
|
81
87
|
emoji = @index.find_by_alpha_code(alpha_code)
|
82
88
|
|
@@ -87,10 +93,10 @@ module TanukiEmoji
|
|
87
93
|
else
|
88
94
|
# not found, add a new emoji
|
89
95
|
emoji = Character.new(alpha_code,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
96
|
+
codepoints: emoji_data.codepoints,
|
97
|
+
alpha_code: alpha_code,
|
98
|
+
description: emoji_data.description,
|
99
|
+
category: emoji_data.group_category)
|
94
100
|
|
95
101
|
emoji.unicode_version = emoji_data.version
|
96
102
|
|
@@ -5,9 +5,26 @@ require 'json'
|
|
5
5
|
module TanukiEmoji
|
6
6
|
module Db
|
7
7
|
# Gemojione Emoji database
|
8
|
+
# In order to maintain compatibility with alpha_codes that have been
|
9
|
+
# stored in a DB originally using the gemojione codes, we change the original
|
10
|
+
# gemojione code to be the primary and make the unicode version to be an alias.
|
11
|
+
# So instead of the alpha code being `thumbs_up` based on the unicode naming,
|
12
|
+
# it's `thumbsup`, with an alias of `thumbs_up`
|
8
13
|
class Gemojione
|
9
14
|
DATA_FILE = 'vendor/gemojione/index-3.3.0.json'
|
10
15
|
|
16
|
+
# rubocop:disable Style/AsciiComments
|
17
|
+
# These are specific gemojione whos alpha codes map slightly differently.
|
18
|
+
# For example, :cow: in gemojione is 🐮, while in Unicode it is 🐄,
|
19
|
+
# which is :cow2: in gemojione. Now :cow_face: will give 🐮.
|
20
|
+
# See https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/merge_requests/65#note_2113986561
|
21
|
+
EMOJI_DIFFERENCES =
|
22
|
+
{
|
23
|
+
unicode: %w[📅 🐪 🐈 🐄 🐕 🐎 🐁 ✏️ 🐖 🐇 🛰️ ☃️ 🐅 🚆 ☂️ 🐋],
|
24
|
+
gemojione: %w[📆 🐫 🐱 🐮 🐶 🐴 🐭 📝 🐷 🐰 📡 ⛄ 🐯 🚋 ☔ 🐳]
|
25
|
+
}.freeze
|
26
|
+
# rubocop:enable Style/AsciiComments
|
27
|
+
|
11
28
|
def self.data_file
|
12
29
|
File.expand_path(File.join(__dir__, '../../../', DATA_FILE))
|
13
30
|
end
|
@@ -24,14 +41,21 @@ module TanukiEmoji
|
|
24
41
|
JSON.parse(file.read, symbolize_names: true)
|
25
42
|
end
|
26
43
|
|
27
|
-
db.
|
44
|
+
db.each_value do |emoji_data|
|
28
45
|
emoji = @index.find_by_codepoints(emoji_data[:moji])
|
29
46
|
|
30
47
|
# if it's not found, don't try to add something that isn't in the
|
31
48
|
# Unicode set.
|
32
49
|
next unless emoji
|
33
50
|
|
34
|
-
|
51
|
+
if emoji.alpha_code != emoji_data[:shortname]
|
52
|
+
org_alpha_code = emoji.alpha_code
|
53
|
+
emoji.replace_alpha_code(emoji_data[:shortname])
|
54
|
+
|
55
|
+
# add the unicode alias back only if it's not a different emoji
|
56
|
+
emoji.add_alias(org_alpha_code) unless EMOJI_DIFFERENCES[:unicode].include?(emoji.codepoints)
|
57
|
+
end
|
58
|
+
|
35
59
|
add_emoji_data(emoji, emoji_data)
|
36
60
|
|
37
61
|
@index.update(emoji)
|
@@ -6,7 +6,7 @@ module TanukiEmoji
|
|
6
6
|
module Db
|
7
7
|
# Emoji Unicode Ordering database
|
8
8
|
class UnicodeOrdering
|
9
|
-
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-ordering.txt"
|
9
|
+
DATA_FILE = "#{::TanukiEmoji::Db::UNICODE_DATA_DIR}/emoji-ordering.txt".freeze
|
10
10
|
|
11
11
|
def self.data_file
|
12
12
|
File.expand_path(File.join(__dir__, '../../../', DATA_FILE))
|
data/lib/tanuki_emoji/errors.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module TanukiEmoji
|
4
|
-
|
4
|
+
Error = Class.new(StandardError)
|
5
5
|
|
6
6
|
# Error: An Emoji with the same alpha code has been previously indexed
|
7
7
|
class AlphaCodeAlreadyIndexedError < Error
|
@@ -14,7 +14,7 @@ module TanukiEmoji
|
|
14
14
|
@alpha_code = alpha_code
|
15
15
|
|
16
16
|
message = "Cannot index Emoji '#{name}' with alpha code '#{alpha_code}'. " \
|
17
|
-
|
17
|
+
"An Emoji with that alpha code has already been indexed."
|
18
18
|
|
19
19
|
super(message)
|
20
20
|
end
|
@@ -31,7 +31,7 @@ module TanukiEmoji
|
|
31
31
|
@codepoint = codepoint
|
32
32
|
|
33
33
|
message = "Cannot index '#{name}' Emoji with codepoint: '#{codepoint}'. " \
|
34
|
-
|
34
|
+
"An Emoji with that codepoint has already been indexed."
|
35
35
|
|
36
36
|
super(message)
|
37
37
|
end
|
data/lib/tanuki_emoji/index.rb
CHANGED
@@ -82,7 +82,7 @@ module TanukiEmoji
|
|
82
82
|
# @return [Regexp] regular expression that matches indexed `:alpha_code:`
|
83
83
|
def alpha_code_pattern
|
84
84
|
/(?<=[^[:alnum:]:]|\n|^)
|
85
|
-
:(#{@name_index.keys.map { |name| Regexp.escape(name) }.join(
|
85
|
+
:(#{@name_index.keys.map { |name| Regexp.escape(name) }.join("|")}):
|
86
86
|
(?=[^[:alnum:]:]|$)/x
|
87
87
|
end
|
88
88
|
|
@@ -93,18 +93,20 @@ module TanukiEmoji
|
|
93
93
|
def codepoints_pattern(exclude_text_presentation: false)
|
94
94
|
possible_codepoints = sorted_codepoints.map { |moji, _| Regexp.escape(moji) }.join('|')
|
95
95
|
variation_selector = ""
|
96
|
-
variation_selector = /(?!#{TanukiEmoji::Character::PLAIN_VARIATION_SELECTOR_STRING})/ if exclude_text_presentation
|
96
|
+
variation_selector = /(?!#{TanukiEmoji::Character::PLAIN_VARIATION_SELECTOR_STRING})/o if exclude_text_presentation
|
97
97
|
|
98
98
|
/(#{possible_codepoints})#{variation_selector}/
|
99
99
|
end
|
100
100
|
|
101
101
|
private
|
102
102
|
|
103
|
+
# rubocop:disable Layout/ClassStructure
|
103
104
|
def initialize
|
104
105
|
@all = []
|
105
106
|
|
106
107
|
load_data_files
|
107
108
|
end
|
109
|
+
# rubocop:enable Layout/ClassStructure
|
108
110
|
|
109
111
|
def insertion_mutex
|
110
112
|
@insertion_mutex ||= Mutex.new
|
data/lib/tanuki_emoji/version.rb
CHANGED
data/lib/tanuki_emoji.rb
CHANGED
@@ -43,10 +43,10 @@ module TanukiEmoji
|
|
43
43
|
# @return [TanukiEmoji::Character]
|
44
44
|
def self.add(name, codepoints:, alpha_code:, description:, category:)
|
45
45
|
emoji = Character.new(name,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
codepoints: codepoints,
|
47
|
+
alpha_code: alpha_code,
|
48
|
+
description: description,
|
49
|
+
category: category)
|
50
50
|
|
51
51
|
index.add(emoji)
|
52
52
|
end
|
data/tanuki_emoji.gemspec
CHANGED
@@ -32,11 +32,12 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency 'i18n', '~> 1.14'
|
33
33
|
|
34
34
|
spec.add_development_dependency 'gitlab-dangerfiles', '~> 2.11.0'
|
35
|
+
spec.add_development_dependency 'gitlab-styles', '~> 12.0'
|
35
36
|
spec.add_development_dependency 'pry-byebug'
|
36
37
|
spec.add_development_dependency 'rake', '~> 13.0'
|
37
38
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
39
|
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.0'
|
39
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
40
|
+
spec.add_development_dependency 'rubocop', '~> 1.62'
|
40
41
|
spec.add_development_dependency 'simplecov'
|
41
42
|
spec.add_development_dependency 'simplecov-cobertura', '~> 1.4.2'
|
42
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanuki_emoji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Mazetto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.11.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gitlab-styles
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pry-byebug
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +114,14 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
117
|
+
version: '1.62'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
124
|
+
version: '1.62'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: simplecov
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|