Compare commits

..

4 Commits

Author SHA1 Message Date
Mislav Marohnić
6a39782a46 gemoji 2.0.1 2014-08-02 09:24:58 -07:00
Adam Roben
c6a9db29bd Fix tests 2014-08-02 09:24:09 -07:00
Adam Roben
3ec375d299 Remove incorrect unicode aliases
db/aliases.html now clears out any incorrect aliases it finds.
2014-08-02 09:24:09 -07:00
Adam Roben
34cd8356bb Use the same unicode aliases as Safari 7.0.5 on OS X 10.9.4
Category-Emoji.json contains many code point sequences ending in U+FE0F
VARIATION SELECTOR-16. OS X renders some of these code point sequences
as color emoji even if you strip off VARIATION SELECTOR-16. (And in fact
it even renders some of them as color emoji if you replace VARIATION
SELECTOR-16 with VARIATION SELECTOR-15, even though that is explicitly
requesting a "text" variant of the character).

We used to assume that VARIATION SELECTOR-16 was optional for all emoji.
But this doesn't match OS X's behavior. This could cause problems, e.g.,
if you were to use the unicode_aliases property to detect Unicode emoji
and replace them with images for browsers that don't support emoji
natively.

The Ruby code no longer does anything special with VARIATION SELECTOR-16
other than to remove it from the description of each emoji. The new
db/aliases.html file can be used to determine which the correct Unicode
aliases for each emoji are. That page takes each emoji, generates a set
of variants using VARIATION SELECTOR-16 and VARIATION SELECTOR-15,
and renders each variant into a <canvas> element twice: once with a red
font color, and once with a green font color. If the variant renders the
same way, the OS is rendering the variant as a color emoji, and we add
it to the "unicodes" array for that emoji.

So the new process for generating db/emoji.json is:

1. rake db:dump > tmp
2. mv tmp db/emoji.json
3. open -a Safari db/aliases.html
4. Copy the resulting JSON from Safari
5. pbpaste > db/emoji.json

This ensures that unicode_aliases only contains those code point
sequences which actually render as color emoji on OS X.
2014-08-02 09:24:09 -07:00
891 changed files with 7063 additions and 25763 deletions

6
.gitignore vendored
View File

@@ -1,6 +1,2 @@
/bin/*
.bundle
.ruby-version
Gemfile.lock
vendor/*
!vendor/unicode-emoji-test.txt
db/NamesList.txt

View File

@@ -1,12 +1,5 @@
sudo: false
script: script/test
rvm:
- 1.9.3
- '2.1'
- '2.2'
- '2.3'
- '2.4'
- '2.5'
- '2.6'
- 2.1.2
notifications:
email: false

View File

@@ -1,31 +0,0 @@
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
Some useful tools in development are:
```
script/bootstrap
```
Sets up the development environment. The prerequisites are:
* Ruby 1.9+
* Bundler
```
script/test
```
Runs the test suite.
```
script/console
```
Opens `irb` console with gemoji library preloded for experimentation.
```
script/release
```
For maintainers only: after the gemspec has been edited, this commits the
change, tags a release, and pushes it to both GitHub and RubyGems.org.

View File

@@ -1,6 +1,6 @@
source "https://rubygems.org"
gem "rake", "~> 10.3.2"
gem "minitest", "~> 5.3.5"
gem "rake"
gem "minitest"
gemspec

18
Gemfile.lock Normal file
View File

@@ -0,0 +1,18 @@
PATH
remote: .
specs:
gemoji (2.0.1)
GEM
remote: https://rubygems.org/
specs:
minitest (5.3.5)
rake (10.3.2)
PLATFORMS
ruby
DEPENDENCIES
gemoji!
minitest
rake

19
LICENSE
View File

@@ -1,4 +1,21 @@
Copyright (c) 2019 GitHub, Inc.
octocat, squirrel, shipit
Copyright (c) 2013 GitHub Inc. All rights reserved.
bowtie, neckbeard, fu
Copyright (c) 2013 37signals, LLC. All rights reserved.
feelsgood, finnadie, goberserk, godmode, hurtrealbad, rage 1-4, suspect
Copyright (c) 2013 id Software. All rights reserved.
trollface
Copyright (c) 2013 whynne@deviantart. All rights reserved.
All other images
Copyright (c) 2013 Apple Inc. All rights reserved.
Source code:
Copyright (c) 2013 GitHub, Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

27
MAINTAINING.md Normal file
View File

@@ -0,0 +1,27 @@
# Maintainers
## Releasing a new gem
If you are just adding new emoji or making a small fix, only increment the patch level "1.0.x". If you need to rename a ton of emojis or making any other radical (but still mostly backwards compatible changes), bump the minor version "1.x.x".
### Make a release commit
To prepare the release commit, edit the [gemoji.gemspec](https://github.com/github/gemoji/blob/master/gemoji.gemspec) `version` value. Then make a single commit with the description as "Gemoji 1.x.x". Finally, tag the commit with `v1.x.x`.
Example commit https://github.com/github/gemoji/commit/v1.0.0
```
$ git ci -m "Gemoji 1.0.0"
$ git tag v1.0.0
$ git push
$ git push --tags
```
### Publish the gem
Build and push the new gem with
```
$ gem build gemoji.gemspec
$ gem push gemoji-1.0.0.gem
```

View File

@@ -1,7 +1,7 @@
gemoji
======
This library contains character information about native emojis.
Emoji images and names. See the LICENSE for copyright information.
Installation
@@ -13,6 +13,37 @@ Add `gemoji` to your Gemfile.
gem 'gemoji'
```
**Sync images**
Images can be copied to your public directory with `rake emoji` in your app. This is the recommended approach since the images will be available at a consistent location. This works best with cached formatted user content generated by tools like [html-pipeline](https://github.com/jch/html-pipeline).
``` ruby
# Rakefile
load 'tasks/emoji.rake'
```
```
$ rake emoji
```
**Assets Precompiling**
If you must, you can manually add all the images to your asset load path.
``` ruby
# config/application.rb
config.assets.paths << Emoji.images_path
```
Then have them compiled to public on deploy.
``` ruby
# config/application.rb
config.assets.precompile << "emoji/**/*.png"
```
**WARNING** Since there are a ton of images, just adding the path may slow down other lookups if you aren't using it. Compiling all the emojis on deploy will add overhead to your deploy if even the images haven't changed. Theres just so many more superfluous files to iterate over. Also, the urls will be fingerprinted which may not be ideal for referencing from cached content.
Example Rails Helper
--------------------
@@ -25,8 +56,8 @@ See the [Emoji cheat sheet](http://www.emoji-cheat-sheet.com) for more examples.
module EmojiHelper
def emojify(content)
h(content).to_str.gsub(/:([\w+-]+):/) do |match|
if emoji = Emoji.find_by_alias($1)
%(<img alt="#$1" src="#{image_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
if emoji = Emoji.find_by_alias($1) { nil }
%(<img alt="#$1" src="#{asset_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
else
match
end
@@ -76,14 +107,6 @@ emoji.image_filename #=> "music.png"
As you create new emoji, you must ensure that you also create and put the images
they reference by their `image_filename` to your assets directory.
You can customize `image_filename` with:
```ruby
emoji = Emoji.create("music") do |char|
char.image_filename = "subdirectory/my_emoji.gif"
end
```
For existing emojis, you can edit the list of aliases or add new tags in an edit block:
```ruby

View File

@@ -9,9 +9,7 @@ end
namespace :db do
desc %(Generate Emoji data files needed for development)
task :generate => [
'vendor/unicode-emoji-test.txt',
]
task :generate => ['db/Category-Emoji.json', 'db/NamesList.txt']
desc %(Dump a list of supported Emoji with Unicode descriptions and aliases)
task :dump => :generate do
@@ -19,6 +17,13 @@ namespace :db do
end
end
file 'vendor/unicode-emoji-test.txt' do |t|
system 'curl', '-fsSL', 'http://unicode.org/Public/emoji/13.0/emoji-test.txt', '-o', t.name
emoji_plist = '/System/Library/Input Methods/CharacterPalette.app/Contents/Resources/Category-Emoji.plist'
nameslist_url = 'http://www.unicode.org/Public/6.3.0/ucd/NamesList.txt'
task 'db/Category-Emoji.json' do |t|
system "plutil -convert json -r '#{emoji_plist}' -o '#{t.name}'"
end
file 'db/NamesList.txt' do |t|
system "curl -fsSL '#{nameslist_url}' -o '#{t.name}'"
end

47
db/Category-Emoji.json Normal file
View File

@@ -0,0 +1,47 @@
{
"EmojiDataArray" : [
{
"CVDataTitle" : "EmojiCategory-People",
"CVCategoryImage" : "Emoji-HumanImage",
"CVCategoryData" : {
"CVSkipNullGlyphs" : true,
"Data" : "😄,😃,😀,😊,☺️,😉,😍,😘,😚,😗,😙,😜,😝,😛,😳,😁,😔,😌,😒,😞,😣,😢,😂,😭,😪,😥,😰,😅,😓,😩,😫,😨,😱,😠,😡,😤,😖,😆,😋,😷,😎,😴,😵,😲,😟,😦,😧,😈,👿,😮,😬,😐,😕,😯,😶,😇,😏,😑,👲,👳,👮,👷,💂,👶,👦,👧,👨,👩,👴,👵,👱,👼,👸,😺,😸,😻,😽,😼,🙀,😿,😹,😾,👹,👺,🙈,🙉,🙊,💀,👽,💩,🔥,✨,🌟,💫,💥,💢,💦,💧,💤,💨,👂,👀,👃,👅,👄,👍,👎,👌,👊,✊,✌️,👋,✋,👐,👆,👇,👉,👈,🙌,🙏,☝️,👏,💪,🚶,🏃,💃,👫,👪,👬,👭,💏,💑,👯,🙆,🙅,💁,🙋,💆,💇,💅,👰,🙎,🙍,🙇,🎩,👑,👒,👟,👞,👡,👠,👢,👕,👔,👚,👗,🎽,👖,👘,👙,💼,👜,👝,👛,👓,🎀,🌂,💄,💛,💙,💜,💚,❤️,💔,💗,💓,💕,💖,💞,💘,💌,💋,💍,💎,👤,👥,💬,👣,💭"
}
},
{
"CVDataTitle" : "EmojiCategory-Nature",
"CVCategoryImage" : "Emoji-NatureImage",
"CVCategoryData" : {
"CVSkipNullGlyphs" : true,
"Data" : "🐶,🐺,🐱,🐭,🐹,🐰,🐸,🐯,🐨,🐻,🐷,🐽,🐮,🐗,🐵,🐒,🐴,🐑,🐘,🐼,🐧,🐦,🐤,🐥,🐣,🐔,🐍,🐢,🐛,🐝,🐜,🐞,🐌,🐙,🐚,🐠,🐟,🐬,🐳,🐋,🐄,🐏,🐀,🐃,🐅,🐇,🐉,🐎,🐐,🐓,🐕,🐖,🐁,🐂,🐲,🐡,🐊,🐫,🐪,🐆,🐈,🐩,🐾,💐,🌸,🌷,🍀,🌹,🌻,🌺,🍁,🍃,🍂,🌿,🌾,🍄,🌵,🌴,🌲,🌳,🌰,🌱,🌼,🌐,🌞,🌝,🌚,🌑,🌒,🌓,🌔,🌕,🌖,🌗,🌘,🌜,🌛,🌙,🌍,🌎,🌏,🌋,🌌,🌠,⭐️,☀️,⛅️,☁️,⚡️,☔️,❄️,⛄️,🌀,🌁,🌈,🌊"
}
},
{
"CVDataTitle" : "EmojiCategory-Objects",
"CVCategoryImage" : "Emoji-ObjectsImage",
"CVCategoryData" : {
"CVSkipNullGlyphs" : true,
"Data" : "🎍,💝,🎎,🎒,🎓,🎏,🎆,🎇,🎐,🎑,🎃,👻,🎅,🎄,🎁,🎋,🎉,🎊,🎈,🎌,🔮,🎥,📷,📹,📼,💿,📀,💽,💾,💻,📱,☎️,📞,📟,📠,📡,📺,📻,🔊,🔉,🔈,🔇,🔔,🔕,📢,📣,⏳,⌛️,⏰,⌚️,🔓,🔒,🔏,🔐,🔑,🔎,💡,🔦,🔆,🔅,🔌,🔋,🔍,🛁,🛀,🚿,🚽,🔧,🔩,🔨,🚪,🚬,💣,🔫,🔪,💊,💉,💰,💴,💵,💷,💶,💳,💸,📲,📧,📥,📤,✉️,📩,📨,📯,📫,📪,📬,📭,📮,📦,📝,📄,📃,📑,📊,📈,📉,📜,📋,📅,📆,📇,📁,📂,✂️,📌,📎,✒️,✏️,📏,📐,📕,📗,📘,📙,📓,📔,📒,📚,📖,🔖,📛,🔬,🔭,📰,🎨,🎬,🎤,🎧,🎼,🎵,🎶,🎹,🎻,🎺,🎷,🎸,👾,🎮,🃏,🎴,🀄️,🎲,🎯,🏈,🏀,⚽️,⚾️,🎾,🎱,🏉,🎳,⛳️,🚵,🚴,🏁,🏇,🏆,🎿,🏂,🏊,🏄,🎣,☕️,🍵,🍶,🍼,🍺,🍻,🍸,🍹,🍷,🍴,🍕,🍔,🍟,🍗,🍖,🍝,🍛,🍤,🍱,🍣,🍥,🍙,🍘,🍚,🍜,🍲,🍢,🍡,🍳,🍞,🍩,🍮,🍦,🍨,🍧,🎂,🍰,🍪,🍫,🍬,🍭,🍯,🍎,🍏,🍊,🍋,🍒,🍇,🍉,🍓,🍑,🍈,🍌,🍐,🍍,🍠,🍆,🍅,🌽"
}
},
{
"CVDataTitle" : "EmojiCategory-Places",
"CVCategoryImage" : "Emoji-PlacesImage",
"CVCategoryData" : {
"CVSkipNullGlyphs" : true,
"Data" : "🏠,🏡,🏫,🏢,🏣,🏥,🏦,🏪,🏩,🏨,💒,⛪️,🏬,🏤,🌇,🌆,🏯,🏰,⛺️,🏭,🗼,🗾,🗻,🌄,🌅,🌃,🗽,🌉,🎠,🎡,⛲️,🎢,🚢,⛵️,🚤,🚣,⚓️,🚀,✈️,💺,🚁,🚂,🚊,🚉,🚞,🚆,🚄,🚅,🚈,🚇,🚝,🚋,🚃,🚎,🚌,🚍,🚙,🚘,🚗,🚕,🚖,🚛,🚚,🚨,🚓,🚔,🚒,🚑,🚐,🚲,🚡,🚟,🚠,🚜,💈,🚏,🎫,🚦,🚥,⚠️,🚧,🔰,⛽️,🏮,🎰,♨️,🗿,🎪,🎭,📍,🚩,🇯🇵,🇰🇷,🇩🇪,🇨🇳,🇺🇸,🇫🇷,🇪🇸,🇮🇹,🇷🇺,🇬🇧"
}
},
{
"CVDataTitle" : "EmojiCategory-Symbols",
"CVCategoryImage" : "Emoji-SymbolImage",
"CVCategoryData" : {
"CVSkipNullGlyphs" : true,
"Data" : "1⃣,2⃣,3⃣,4⃣,5⃣,6⃣,7⃣,8⃣,9⃣,0⃣,🔟,🔢,#️⃣,🔣,⬆️,⬇️,⬅️,➡️,🔠,🔡,🔤,↗️,↖️,↘️,↙️,↔️,↕️,🔄,◀️,▶️,🔼,🔽,↩️,↪️,,⏪,⏩,⏫,⏬,⤵️,⤴️,🆗,🔀,🔁,🔂,🆕,🆙,🆒,🆓,🆖,📶,🎦,🈁,🈯️,🈳,🈵,🈴,🈲,🉐,🈹,🈺,🈶,🈚️,🚻,🚹,🚺,🚼,🚾,🚰,🚮,🅿️,♿️,🚭,🈷,🈸,🈂,Ⓜ️,🛂,🛄,🛅,🛃,🉑,㊙️,㊗️,🆑,🆘,🆔,🚫,🔞,📵,🚯,🚱,🚳,🚷,🚸,⛔️,✳️,❇️,❎,✅,✴️,💟,🆚,📳,📴,🅰,🅱,🆎,🅾,💠,➿,♻️,♈️,♉️,♊️,♋️,♌️,♍️,♎️,♏️,♐️,♑️,♒️,♓️,⛎,🔯,🏧,💹,💲,💱,©,®,™,❌,‼️,⁉️,❗️,❓,❕,❔,⭕️,🔝,🔚,🔙,🔛,🔜,🔃,🕛,🕧,🕐,🕜,🕑,🕝,🕒,🕞,🕓,🕟,🕔,🕠,🕕,🕖,🕗,🕘,🕙,🕚,🕡,🕢,🕣,🕤,🕥,🕦,✖️,,,➗,♠️,♥️,♣️,♦️,💮,💯,✔️,☑️,🔘,🔗,➰,〰,〽️,🔱,◼️,◻️,◾️,◽️,▪️,▫️,🔺,🔲,🔳,⚫️,⚪️,🔴,🔵,🔻,⬜️,⬛️,🔶,🔷,🔸,🔹"
}
}
],
"CVViewFontList" : [
"AppleColorEmoji"
]
}

87
db/aliases.html Normal file
View File

@@ -0,0 +1,87 @@
<!DOCTYPE html>
<title>Emoji alias detection</title>
<style>
textarea {
font-family: monospace;
}
</style>
<p>Save the following as <tt>emoji.json</tt>:</p>
<textarea id="output" rows="50" cols="80"></textarea>
<script>
const VARIATION_SELECTOR_15 = String.fromCharCode(0xfe0e);
const VARIATION_SELECTOR_16 = String.fromCharCode(0xfe0f);
function detectAliases(db) {
for (var i = 0; i < db.length; ++i) {
var emoji = db[i];
var raw = emoji.emoji;
if (!raw) {
continue;
}
var candidates = [];
if (raw.length === 1) {
candidates.push(raw + VARIATION_SELECTOR_15);
candidates.push(raw + VARIATION_SELECTOR_16);
} else if (raw[raw.length - 1] === VARIATION_SELECTOR_16) {
var base = raw.substr(0, raw.length - 1);
candidates.push(base);
candidates.push(base + VARIATION_SELECTOR_15);
}
var aliases = candidates.filter(isColorEmoji);
if (aliases.length) {
emoji.unicodes = aliases;
} else {
delete emoji.unicodes;
}
}
dump(db);
}
function isColorEmoji(candidate) {
// Draw the emoji twice using a different color each time. If the emoji
// draws as the same color regardless of what color we set, it's a color
// emoji.
return color(candidate, "#f00") === color(candidate, "#0f0");
}
var canvas = document.createElement("canvas");
function color(emoji, rgb) {
var context = canvas.getContext("2d");
context.clearRect(0, 0, 32, 32);
context.fillStyle = rgb;
context.textBaseline = "top";
context.font = "32px Arial";
context.fillText(emoji, 0, 0);
var data = context.getImageData(0, 0, 32, 32).data;
for (var i = 0; i < data.length; i += 4) {
if (data[i] === 0 && data[i + 1] === 0 && data[i + 2] === 0) {
continue;
}
return data[i].toString(16)
+ data[i + 1].toString(16)
+ data[i + 2].toString(16);
}
return "no colored pixel found";
}
function dump(db) {
var json = JSON.stringify(db, null, " ")
.replace(/^( +)(.+)\[\](,?)$/mg, "$1$2[\n$1]$3")
.replace(/,\n( *) /g, "\n$1, ");
document.getElementById("output").value = json + "\n";
}
var xhr = new XMLHttpRequest;
xhr.onload = function() {
detectAliases(JSON.parse(this.responseText));
};
xhr.open("GET", "emoji.json", false);
xhr.send(null);
</script>

View File

@@ -1,67 +1,79 @@
# frozen_string_literal: true
require 'emoji'
require 'json'
require_relative './emoji-test-parser'
items = []
names_list = File.expand_path('../NamesList.txt', __FILE__)
_, categories = EmojiTestParser.parse(File.expand_path("../../vendor/unicode-emoji-test.txt", __FILE__))
seen_existing = {}
class UnicodeCharacter
attr_reader :code, :description, :aliases
for category in categories
for sub_category in category[:emoji]
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}")
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: description,
category: category[:name],
}
if existing_emoji
output_item.update(
aliases: existing_emoji.aliases,
tags: existing_emoji.tags,
unicode_version: existing_emoji.unicode_version,
ios_version: existing_emoji.ios_version,
)
else
output_item.update(
aliases: [description.gsub(/\W+/, '_').downcase],
tags: [],
unicode_version: "13.0",
ios_version: "14.0",
)
end
output_item[:skin_tones] = true if emoji_item[:skin_tones]
items << output_item
@index = {}
class << self
attr_reader :index
def fetch(code, *args, &block)
code = code.to_s(16).rjust(4, '0') if code.is_a?(Integer)
index.fetch(code, *args, &block)
end
end
def initialize(code, description)
@code = code.downcase
@description = description.downcase
@aliases = []
@references = []
self.class.index[@code] = self
end
def add_alias(string)
@aliases.concat string.split(/\s*,\s*/)
end
def add_reference(code)
@references << code.downcase
end
end
missing_emoji = Emoji.all.reject { |e| e.custom? || seen_existing.key?(e) }
if missing_emoji.any?
$stderr.puts "Error: these `emoji.json` entries were not matched:"
$stderr.puts missing_emoji.map { |e| "%s (%s)" % [e.hex_inspect, e.name] }
exit 1
end
char = nil
for emoji in Emoji.all.select(&:custom?)
items << {
aliases: emoji.aliases,
tags: emoji.tags,
}
File.foreach(names_list) do |line|
case line
when /^[A-F0-9]{4,5}\t/
code, desc = line.chomp.split("\t", 2)
codepoint = code.hex
char = UnicodeCharacter.new(code, desc)
when /^\t= /
char.add_alias($')
when /^\tx .+ - ([A-F0-9]{4,5})\)$/
char.add_reference($1)
end
end
trap(:PIPE) { abort }
items = []
variation = "\u{fe0f}".freeze
for emoji in Emoji.all
unicodes = emoji.unicode_aliases.dup
item = {}
unless emoji.custom?
variation_codepoint = variation.codepoints[0]
chars = emoji.raw.codepoints.map { |code| UnicodeCharacter.fetch(code) unless code == variation_codepoint }.compact
item[:emoji] = unicodes.shift
item[:unicodes] = unicodes if unicodes.any?
item[:description] = chars.map(&:description).join(' + ')
end
item[:aliases] = emoji.aliases
item[:tags] = emoji.tags
items << item
end
puts JSON.pretty_generate(items)
.gsub("\n\n", "\n")
.gsub(/,\n( +)/) { "\n%s, " % $1[2..-1] }

View File

@@ -1,117 +0,0 @@
# frozen_string_literal: true
module EmojiTestParser
VARIATION_SELECTOR_16 = "\u{fe0f}"
SKIN_TONES = [
"\u{1F3FB}", # light skin tone
"\u{1F3FC}", # medium-light skin tone
"\u{1F3FD}", # medium skin tone
"\u{1F3FE}", # medium-dark skin tone
"\u{1F3FF}", # dark skin tone
]
SKIN_TONES_RE = /(#{SKIN_TONES.join("|")})/o
SKIP_TYPES = ["unqualified", "component"]
module_function
def parse(filename)
File.open(filename, "r:UTF-8") do |file|
parse_file(file)
end
end
def parse_file(io)
data = []
emoji_map = {}
category = nil
sub_category = nil
io.each do |line|
begin
if line.start_with?("# group: ")
_, group_name = line.split(":", 2)
category = {
name: group_name.strip,
emoji: [],
}
data << category
sub_category = nil
elsif line.start_with?("# subgroup: ")
_, group_name = line.split(":", 2)
sub_category = {
name: group_name.strip,
emoji: [],
}
category[:emoji] << sub_category
elsif line.start_with?("#") || line.strip.empty?
next
else
row, desc = line.split("#", 2)
desc = desc.strip.split(" ", 2)[1]
codepoints, qualification = row.split(";", 2)
next if SKIP_TYPES.include?(qualification.strip)
emoji_raw = codepoints.strip.split.map { |c| c.hex }.pack("U*")
emoji_normalized = emoji_raw
.gsub(VARIATION_SELECTOR_16, "")
.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
next
end
if emoji_item
emoji_item[:sequences] << emoji_raw
else
emoji_item = {
sequences: [emoji_raw],
description: desc,
}
emoji_map[emoji_normalized] = emoji_item
sub_category[:emoji] << emoji_item
end
end
rescue
warn "line: %p" % line
raise
end
end
[emoji_map, data]
end
end
if $0 == __FILE__
html_output = false
if ARGV[0] == "--html"
ARGV.shift
html_output = true
end
_, categories = EmojiTestParser.parse(File.expand_path("../../vendor/unicode-emoji-test.txt", __FILE__))
trap(:PIPE) { abort }
if html_output
puts "<!doctype html>"
puts "<meta charset=utf-8>"
for category in categories
puts "<h2>#{category[:name]}</h2>"
for sub_category in category[:emoji]
puts "<h3>#{sub_category[:name]}</h3>"
puts "<ol>"
for char in sub_category[:emoji]
puts "<li>"
for sequence in char[:sequences]
codepoints = sequence.unpack("U*").map { |c| c.to_s(16).upcase }.join(" ")
printf '<span class=emoji title="%s">%s</span> ', codepoints, sequence
end
puts "#{char[:description]}</li>"
end
puts "</ol>"
end
end
else
require "json"
puts JSON.pretty_generate(categories)
end
end

View File

File diff suppressed because it is too large Load Diff

View File

@@ -66,7 +66,7 @@ li > span {
if (emoji.emoji) els[0].textContent = emoji.emoji
else {
var img = document.createElement('img')
img.src = "../images/" + emoji.aliases[0] + ".png"
img.src = "../images/emoji/" + emoji.aliases[0] + ".png"
els[0].appendChild(img)
}
els[1].textContent = emoji.description || ''

View File

@@ -1,8 +1,8 @@
Gem::Specification.new do |s|
s.name = "gemoji"
s.version = "4.0.0.rc2"
s.summary = "Unicode emoji library"
s.description = "Character information and metadata for Unicode emoji."
s.version = "2.0.1"
s.summary = "Emoji conversion and image assets"
s.description = "Image assets and character information for emoji."
s.required_ruby_version = '> 1.9'
@@ -13,8 +13,9 @@ Gem::Specification.new do |s|
s.files = Dir[
"README.md",
"LICENSE",
"images/**/*.png",
"db/emoji.json",
"lib/**/*.rb",
"lib/tasks/*.rake"
]
end

BIN
images/emoji/bowtie.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
images/emoji/feelsgood.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/emoji/finnadie.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/emoji/fu.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
images/emoji/goberserk.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/emoji/godmode.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/emoji/metal.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
images/emoji/neckbeard.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
images/emoji/octocat.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
images/emoji/rage1.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/emoji/rage2.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/emoji/rage3.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/emoji/rage4.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/emoji/shipit.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
images/emoji/suspect.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
images/emoji/trollface.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Some files were not shown because too many files have changed in this diff Show More