Skip to content

Commit d7ca116

Browse files
committed
Merge remote-tracking branch 'origin' into skin-tones
2 parents a586515 + 9917299 commit d7ca116

File tree

11 files changed

+6802
-4215
lines changed

11 files changed

+6802
-4215
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
ruby: ["2.7", "3.0", "3.1"]
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Set up Ruby
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: ${{matrix.ruby}}
21+
bundler-cache: true
22+
23+
- name: Run tests
24+
run: bundle exec rake

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ source "https://rubygems.org"
22

33
gem "rake", "~> 10.3.2"
44
gem "minitest", "~> 5.3.5"
5+
gem "i18n", "~> 1.8.5"
56

67
gemspec

Gemfile.lock

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
PATH
2+
remote: .
3+
specs:
4+
gemoji (4.0.0.rc3)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
concurrent-ruby (1.1.7)
10+
i18n (1.8.5)
11+
concurrent-ruby (~> 1.0)
12+
minitest (5.3.5)
13+
rake (10.3.2)
14+
15+
PLATFORMS
16+
ruby
17+
18+
DEPENDENCIES
19+
gemoji!
20+
i18n (~> 1.8.5)
21+
minitest (~> 5.3.5)
22+
rake (~> 10.3.2)
23+
24+
BUNDLED WITH
25+
2.0.2

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ namespace :db do
2020
end
2121

2222
file 'vendor/unicode-emoji-test.txt' do |t|
23-
system 'curl', '-fsSL', 'http://unicode.org/Public/emoji/12.0/emoji-test.txt', '-o', t.name
23+
system 'curl', '-fsSL', 'http://unicode.org/Public/emoji/14.0/emoji-test.txt', '-o', t.name
2424
end

db/dump.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# frozen_string_literal: true
22

3+
require "i18n"
34
require 'emoji'
45
require 'json'
56
require_relative './emoji-test-parser'
67

8+
I18n.config.available_locales = :en
79
items = []
810

911
_, categories = EmojiTestParser.parse(File.expand_path("../../vendor/unicode-emoji-test.txt", __FILE__))
@@ -14,12 +16,15 @@
1416
for emoji_item in sub_category[:emoji]
1517
raw = emoji_item[:sequences][0]
1618
existing_emoji = Emoji.find_by_unicode(raw) || Emoji.find_by_unicode("#{raw}\u{fe0f}")
17-
# next unless existing_emoji
18-
existing_emoji = nil if seen_existing.key?(existing_emoji)
19-
seen_existing[existing_emoji] = true
19+
if seen_existing.key?(existing_emoji)
20+
existing_emoji = nil
21+
else
22+
seen_existing[existing_emoji] = true
23+
end
24+
description = emoji_item[:description].sub(/^E\d+(\.\d+)? /, '')
2025
output_item = {
2126
emoji: raw,
22-
description: emoji_item[:description],
27+
description: description,
2328
category: category[:name],
2429
}
2530
if existing_emoji
@@ -31,10 +36,10 @@
3136
)
3237
else
3338
output_item.update(
34-
aliases: [emoji_item[:description].gsub(/\W+/, '_').downcase],
39+
aliases: [I18n.transliterate(description).gsub(/\W+/, '_').downcase],
3540
tags: [],
36-
unicode_version: "12.0",
37-
ios_version: "13.0",
41+
unicode_version: "14.0",
42+
ios_version: "15.4",
3843
)
3944
end
4045
output_item[:skin_tones] = true if emoji_item[:skin_tones]

db/emoji-test-parser.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ module EmojiTestParser
99
"\u{1F3FE}", # medium-dark skin tone
1010
"\u{1F3FF}", # dark skin tone
1111
]
12-
HAIR_MODIFIERS = [
13-
"\u{1F9B0}", # red-haired
14-
"\u{1F9B1}", # curly-haired
15-
"\u{1F9B2}", # bald
16-
"\u{1F9B3}", # white-haired
17-
]
12+
SKIN_TONES_RE = /(#{SKIN_TONES.join("|")})/o
13+
SKIP_TYPES = ["unqualified", "component"]
1814

1915
module_function
2016

@@ -52,12 +48,12 @@ def parse_file(io)
5248
else
5349
row, desc = line.split("#", 2)
5450
desc = desc.strip.split(" ", 2)[1]
55-
codepoints, _ = row.split(";", 2)
51+
codepoints, qualification = row.split(";", 2)
52+
next if SKIP_TYPES.include?(qualification.strip)
5653
emoji_raw = codepoints.strip.split.map { |c| c.hex }.pack("U*")
57-
next if HAIR_MODIFIERS.include?(emoji_raw)
5854
emoji_normalized = emoji_raw
5955
.gsub(VARIATION_SELECTOR_16, "")
60-
.gsub(/(#{SKIN_TONES.join("|")})/o, "")
56+
.gsub(SKIN_TONES_RE, "")
6157
emoji_item = emoji_map[emoji_normalized]
6258
if SKIN_TONES.any? { |s| emoji_raw.include?(s) }
6359
emoji_item[:skin_tones] = true if emoji_item
@@ -91,7 +87,7 @@ def parse_file(io)
9187
html_output = true
9288
end
9389

94-
_, categories = EmojiTestParser.parse
90+
_, categories = EmojiTestParser.parse(File.expand_path("../../vendor/unicode-emoji-test.txt", __FILE__))
9591

9692
trap(:PIPE) { abort }
9793

0 commit comments

Comments
 (0)