Skip to content

Commit

Permalink
Vendor emoji-test.txt from Unicode.org so it can be used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed May 4, 2019
1 parent 444ad5b commit e55d145
Show file tree
Hide file tree
Showing 6 changed files with 3,803 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.bundle
.ruby-version
Gemfile.lock
db/emoji-test.txt
images/unicode/*.png
vendor/
vendor/*
!vendor/unicode-emoji-test.txt
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end
namespace :db do
desc %(Generate Emoji data files needed for development)
task :generate => [
'db/emoji-test.txt',
'vendor/unicode-emoji-test.txt',
]

desc %(Dump a list of supported Emoji with Unicode descriptions and aliases)
Expand All @@ -19,7 +19,7 @@ namespace :db do
end
end

file 'db/emoji-test.txt' do |t|
file 'vendor/unicode-emoji-test.txt' do |t|
system 'curl', '-fsSL', 'http://unicode.org/Public/emoji/11.0/emoji-test.txt', '-o', t.name
end

Expand Down
4 changes: 2 additions & 2 deletions db/dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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

items = []

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

for category in categories
Expand Down
4 changes: 2 additions & 2 deletions db/emoji-test.rb → db/emoji-test-parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module EmojiTestParser

module_function

def parse
File.open(File.expand_path("../emoji-test.txt", __FILE__), "r:utf-8") do |file|
def parse(filename)
File.open(filename, "r:UTF-8") do |file|
parse_file(file)
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/emoji_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'test_helper'
require_relative '../db/emoji-test'
require_relative '../db/emoji-test-parser'

class EmojiTest < TestCase
test "fetching all emoji" do
Expand Down Expand Up @@ -89,7 +89,7 @@ class EmojiTest < TestCase
end

test "missing or incorrect unicodes" do
emoji_map, _ = EmojiTestParser.parse
emoji_map, _ = EmojiTestParser.parse(File.expand_path("../../vendor/unicode-emoji-test.txt", __FILE__))
source_unicode_emoji = emoji_map.values
supported_sequences = Emoji.all.flat_map(&:unicode_aliases)
text_glyphs = Emoji.const_get(:TEXT_GLYPHS)
Expand Down
Loading

0 comments on commit e55d145

Please # to comment.