Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into skin-tones
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Nov 15, 2022
2 parents a586515 + 9917299 commit d7ca116
Show file tree
Hide file tree
Showing 11 changed files with 6,802 additions and 4,215 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test

on: [push, pull_request]

jobs:
test:
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1"]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true

- name: Run tests
run: bundle exec rake
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ source "https://rubygems.org"

gem "rake", "~> 10.3.2"
gem "minitest", "~> 5.3.5"
gem "i18n", "~> 1.8.5"

gemspec
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
PATH
remote: .
specs:
gemoji (4.0.0.rc3)

GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.1.7)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
minitest (5.3.5)
rake (10.3.2)

PLATFORMS
ruby

DEPENDENCIES
gemoji!
i18n (~> 1.8.5)
minitest (~> 5.3.5)
rake (~> 10.3.2)

BUNDLED WITH
2.0.2
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ namespace :db do
end

file 'vendor/unicode-emoji-test.txt' do |t|
system 'curl', '-fsSL', 'http://unicode.org/Public/emoji/12.0/emoji-test.txt', '-o', t.name
system 'curl', '-fsSL', 'http://unicode.org/Public/emoji/14.0/emoji-test.txt', '-o', t.name
end
19 changes: 12 additions & 7 deletions db/dump.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require "i18n"
require 'emoji'
require 'json'
require_relative './emoji-test-parser'

I18n.config.available_locales = :en
items = []

_, categories = EmojiTestParser.parse(File.expand_path("../../vendor/unicode-emoji-test.txt", __FILE__))
Expand All @@ -14,12 +16,15 @@
for emoji_item in sub_category[:emoji]
raw = emoji_item[:sequences][0]
existing_emoji = Emoji.find_by_unicode(raw) || Emoji.find_by_unicode("#{raw}\u{fe0f}")
# next unless existing_emoji
existing_emoji = nil if seen_existing.key?(existing_emoji)
seen_existing[existing_emoji] = true
if seen_existing.key?(existing_emoji)
existing_emoji = nil
else
seen_existing[existing_emoji] = true
end
description = emoji_item[:description].sub(/^E\d+(\.\d+)? /, '')
output_item = {
emoji: raw,
description: emoji_item[:description],
description: description,
category: category[:name],
}
if existing_emoji
Expand All @@ -31,10 +36,10 @@
)
else
output_item.update(
aliases: [emoji_item[:description].gsub(/\W+/, '_').downcase],
aliases: [I18n.transliterate(description).gsub(/\W+/, '_').downcase],
tags: [],
unicode_version: "12.0",
ios_version: "13.0",
unicode_version: "14.0",
ios_version: "15.4",
)
end
output_item[:skin_tones] = true if emoji_item[:skin_tones]
Expand Down
16 changes: 6 additions & 10 deletions db/emoji-test-parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ module EmojiTestParser
"\u{1F3FE}", # medium-dark skin tone
"\u{1F3FF}", # dark skin tone
]
HAIR_MODIFIERS = [
"\u{1F9B0}", # red-haired
"\u{1F9B1}", # curly-haired
"\u{1F9B2}", # bald
"\u{1F9B3}", # white-haired
]
SKIN_TONES_RE = /(#{SKIN_TONES.join("|")})/o
SKIP_TYPES = ["unqualified", "component"]

module_function

Expand Down Expand Up @@ -52,12 +48,12 @@ def parse_file(io)
else
row, desc = line.split("#", 2)
desc = desc.strip.split(" ", 2)[1]
codepoints, _ = row.split(";", 2)
codepoints, qualification = row.split(";", 2)
next if SKIP_TYPES.include?(qualification.strip)
emoji_raw = codepoints.strip.split.map { |c| c.hex }.pack("U*")
next if HAIR_MODIFIERS.include?(emoji_raw)
emoji_normalized = emoji_raw
.gsub(VARIATION_SELECTOR_16, "")
.gsub(/(#{SKIN_TONES.join("|")})/o, "")
.gsub(SKIN_TONES_RE, "")
emoji_item = emoji_map[emoji_normalized]
if SKIN_TONES.any? { |s| emoji_raw.include?(s) }
emoji_item[:skin_tones] = true if emoji_item
Expand Down Expand Up @@ -91,7 +87,7 @@ def parse_file(io)
html_output = true
end

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

trap(:PIPE) { abort }

Expand Down
Loading

0 comments on commit d7ca116

Please sign in to comment.