tanuki_emoji 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b93addc91c6826e225b3660af5aadd15826f27dc62f93ca3add700fcaf98ba8b
4
- data.tar.gz: 7c4c9d5776e1d15a9b739bf128afe42d1c0a48470a5bb0d9ae8e0fd44b8c9d4c
3
+ metadata.gz: 03a9c7c072edee70643369a71de1b6bb85ecf044c4030ff355cc0caab71b081c
4
+ data.tar.gz: e697dfff9b354990fa2a6ef0c52cf368d968690008ffee415de66e010c9cf9ce
5
5
  SHA512:
6
- metadata.gz: 0dacfb4eb67fc787977c59d308f893e5a3d6bf46ea831cc95e89c0dd3f9da31bcc5f2920c3c2341a811018c14d023ae867fd18092981cd4ea9fc0c5df9fa6736
7
- data.tar.gz: ed2af612050f9273739879bba8768eacc4140da6dcc7779b2df989be274cf87bcc3bc4ed5e8c0b7e96a684d7346b754639847f5f308954f4b570fc950d6be643
6
+ metadata.gz: 4c1b8e5c498364ece688325c25f568d585cab71682380a56d58717f8f7e961bcac557f23b84b4126b34e9592515f26c30d48c9742f1affcaecbde7ba6bd11143
7
+ data.tar.gz: 64782dcf6b3b024f6d496b00e0265689fbffbaf4c4b8811b051a75eac8f9804bb4df6dd866f84cf1ec95c0c80c379e3122b7913fb9ddfb10786278c86e707f62
data/.gitignore CHANGED
@@ -11,6 +11,8 @@
11
11
  /*.gem
12
12
  /app/assets/**/*
13
13
  .DS_Store
14
+ /pages/_data/emojis.json
15
+ /pages/_site/**/*
14
16
 
15
17
  # rspec failure tracking
16
18
  .rspec_status
data/.gitlab/CODEOWNERS CHANGED
@@ -1,2 +1,2 @@
1
1
  [Maintainers]
2
- * @brodock @cablett @mwoolf @kerrizor @brytannia @splattael @digitalmoksha @smcgivern @jlear
2
+ * @brodock @mwoolf @kerrizor @brytannia @splattael @digitalmoksha @smcgivern @jlear
data/.gitlab-ci.yml CHANGED
@@ -102,3 +102,20 @@ update-changelog:
102
102
  version=$(ruby -e "print Gem::Specification.load('${GEMSPEC_FILE}').version")
103
103
  [ -n "${version}" ] || (echo "VERSION could not be parsed in ${GEMSPEC_FILE}!" && exit 1)
104
104
  - 'curl --fail --request POST --header "PRIVATE-TOKEN: ${GITLAB_API_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/changelog?version=${version}&branch=${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"'
105
+
106
+ pages:
107
+ stage: deploy
108
+ image: ruby:3.2
109
+ script:
110
+ - echo "The site will be deployed to $CI_PAGES_URL"
111
+ - gem install bundler
112
+ - cd pages
113
+ - bundle install
114
+ - bundle exec rake generate
115
+ - bundle exec jekyll build
116
+ artifacts:
117
+ paths:
118
+ - pages
119
+ publish: pages/_site
120
+ rules:
121
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
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,19 @@ 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.13.0 (2024-10-25)
8
+
9
+ ### Fixed (1 change)
10
+
11
+ - [Ensure no Unicode aliases collide with gemojione](https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/commit/e26557d826947b78733f1c9522f73918cf86d7c1) ([merge request](https://gitlab.com/gitlab-org/ruby/gems/tanuki_emoji/-/merge_requests/75))
12
+
13
+ ## 0.12.0 (2024-10-22)
14
+
15
+ ### Fixed (2 changes)
16
+
17
+ - [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))
18
+ - [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))
19
+
7
20
  ## 0.11.0 (2024-10-02)
8
21
 
9
22
  ### Added (1 change)
data/Gemfile.lock CHANGED
@@ -1,15 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tanuki_emoji (0.11.0)
4
+ tanuki_emoji (0.13.0)
5
5
  i18n (~> 1.14)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.8.0)
11
- public_suffix (>= 2.0.2, < 5.0)
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
- danger (8.4.5)
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, < 2.0)
43
+ faraday (>= 0.9.0, < 3.0)
30
44
  faraday-http-cache (~> 2.0)
31
- git (~> 1.7)
45
+ git (~> 1.13)
32
46
  kramdown (~> 2.3)
33
47
  kramdown-parser-gfm (~> 1.0)
34
- no_proxy_fix
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.4.4)
41
- docile (1.4.0)
42
- faraday (1.10.0)
43
- faraday-em_http (~> 1.0)
44
- faraday-em_synchrony (~> 1.0)
45
- faraday-excon (~> 1.1)
46
- faraday-httpclient (~> 1.0)
47
- faraday-multipart (~> 1.0)
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-httpclient (1.0.1)
60
- faraday-multipart (1.0.3)
61
- multipart-post (>= 1.2, < 3)
62
- faraday-net_http (1.0.1)
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.18.0)
70
- httparty (~> 0.18)
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
- httparty (0.20.0)
76
- mime-types (~> 3.0)
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
- kramdown (2.3.1)
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
- mime-types (3.4.1)
86
- mime-types-data (~> 3.2015)
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
- multipart-post (2.1.1)
97
+ mutex_m (0.2.0)
90
98
  nap (1.1.0)
91
- no_proxy_fix (0.1.2)
92
- octokit (4.22.0)
93
- faraday (>= 0.9)
94
- sawyer (~> 0.8.0, >= 0.5.3)
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.20.1)
97
- parser (3.0.2.0)
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 (4.0.6)
106
- rainbow (3.0.0)
107
- rake (13.0.6)
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.1.1)
110
- rexml (3.2.5)
111
- rspec (3.10.0)
112
- rspec-core (~> 3.10.0)
113
- rspec-expectations (~> 3.10.0)
114
- rspec-mocks (~> 3.10.0)
115
- rspec-core (3.10.1)
116
- rspec-support (~> 3.10.0)
117
- rspec-expectations (3.10.1)
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.10.0)
120
- rspec-mocks (3.10.2)
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.10.0)
123
- rspec-support (3.10.2)
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.18.4)
138
+ rubocop (1.62.1)
139
+ json (~> 2.3)
140
+ language_server-protocol (>= 3.17.0)
127
141
  parallel (~> 1.10)
128
- parser (>= 3.0.0.0)
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.8.0, < 2.0)
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 (>= 1.4.0, < 3.0)
135
- rubocop-ast (1.8.0)
136
- parser (>= 3.0.1.1)
137
- ruby-progressbar (1.11.0)
138
- ruby2_keywords (0.0.5)
139
- sawyer (0.8.2)
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 (> 0.8, < 2.0)
142
- simplecov (0.21.2)
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.12.3)
149
- simplecov_json_formatter (0.1.3)
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
- unicode-display_width (2.1.0)
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.7)
200
+ rubocop (~> 1.62)
166
201
  simplecov
167
202
  simplecov-cobertura (~> 1.4.2)
168
203
  tanuki_emoji!
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bundler/setup"
3
4
  require "bundler/gem_tasks"
4
5
  require "rspec/core/rake_task"
5
6
  require "rubocop/rake_task"
@@ -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
- # The two character code is only found in the aliases
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
@@ -118,7 +143,9 @@ module TanukiEmoji
118
143
  end
119
144
 
120
145
  def inspect
121
- "#<#{self.class.name}: #{codepoints} (#{hex}) #{alpha_code} aliases: #{aliases}>"
146
+ # rubocop:disable Layout/LineLength
147
+ %(#<#{self.class.name}: #{codepoints} (#{hex}), alpha_code: "#{alpha_code}", aliases: #{aliases}, name: "#{name}", description: "#{description}">)
148
+ # rubocop:enable Layout/LineLength
122
149
  end
123
150
 
124
151
  def ==(other)
@@ -131,20 +158,6 @@ module TanukiEmoji
131
158
  description == other.description
132
159
  end
133
160
 
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
161
  private
149
162
 
150
163
  # Return each codepoint converted to its hex value as string
@@ -24,7 +24,7 @@ module TanukiEmoji
24
24
  JSON.parse(file.read, symbolize_names: true)
25
25
  end
26
26
 
27
- db.each do |_alpha_code, emoji_data|
27
+ db.each_value do |emoji_data|
28
28
  emoji = @index.find_by_codepoints(emoji_data[:emoji])
29
29
 
30
30
  next unless emoji
@@ -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).gsub(/[^a-zA-Z#*\d]+/, '_').downcase
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
- # codepoint. Search on the alpha code and pull that. If found, add as alternate codepoint.
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
- codepoints: emoji_data.codepoints,
91
- alpha_code: alpha_code,
92
- description: emoji_data.description,
93
- category: emoji_data.group_category)
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,28 @@ module TanukiEmoji
24
41
  JSON.parse(file.read, symbolize_names: true)
25
42
  end
26
43
 
27
- db.each do |_emoji_name, emoji_data|
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
- emoji.add_alias(emoji_data[:shortname]) if emoji.alpha_code != emoji_data[:shortname]
51
+ if emoji.alpha_code != emoji_data[:shortname]
52
+ org_alpha_code = emoji.alpha_code
53
+ org_alpha_code_sym = TanukiEmoji::Character.format_name(org_alpha_code).to_sym
54
+ emoji.replace_alpha_code(emoji_data[:shortname])
55
+
56
+ # rubocop:disable Style/AsciiComments
57
+ # Ensure that we're not adding an alias that is part of the gemonione data.
58
+ # For example, Unicode uses `sunglasses` for 🕶️, which is `dark_sunglasses` in gemojione.
59
+ # `sunglasses` is 😎 which is `smiling_face_with_sunglasses` in Unicode.
60
+ # We don't want `sunglasses` to be added as an alias of `dark_sunglasses`, because that
61
+ # would interfere with `sunglasses` being the primary code for `smiling_face_with_sunglasses`
62
+ # rubocop:enable Style/AsciiComments
63
+ emoji.add_alias(org_alpha_code) unless db.key?(org_alpha_code_sym) || EMOJI_DIFFERENCES[:unicode].include?(emoji.codepoints)
64
+ end
65
+
35
66
  add_emoji_data(emoji, emoji_data)
36
67
 
37
68
  @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))
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TanukiEmoji
4
- class Error < StandardError; end
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
- "An Emoji with that alpha code has already been indexed."
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
- "An Emoji with that codepoint has already been indexed."
34
+ "An Emoji with that codepoint has already been indexed."
35
35
 
36
36
  super(message)
37
37
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TanukiEmoji
4
- VERSION = "0.11.0"
4
+ VERSION = '0.13.0'
5
5
  end
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
- codepoints: codepoints,
47
- alpha_code: alpha_code,
48
- description: description,
49
- category: category)
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
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
24
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
- git_files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|bin)/}) }
25
+ git_files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|bin|pages)/}) }
26
26
  asset_files = Dir.glob('app/assets/**/*').reject { |f| f.match(%r{\.DS_Store}) }
27
27
 
28
28
  git_files + asset_files
@@ -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.7'
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.11.0
4
+ version: 0.13.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-02 00:00:00.000000000 Z
11
+ date: 2024-10-29 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.7'
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.7'
124
+ version: '1.62'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: simplecov
113
127
  requirement: !ruby/object:Gem::Requirement