Add `script/regenerate` to rebuild `db/emoji.json` database

Uses AppleScript to open Safari and filter the emojis by whether they
render as actual emoji on OS X or not.
This commit is contained in:
Mislav Marohnić 2014-08-05 23:25:35 -07:00
Родитель 680d1bc59b
Коммит 584939127e
2 изменённых файлов: 33 добавлений и 0 удалений

Двоичные данные
db/aliases.scpt Normal file

Двоичный файл не отображается.

33
script/regenerate Executable file
Просмотреть файл

@ -0,0 +1,33 @@
#!/bin/bash
# Usage: script/regenerate
#
# Note: only usable on OS X
#
# Combines `rake db:dump` and `db/aliases.html` filter to regenerate the
# `db/emoji.json` file using only emoji that are guaranteed to not render as
# ordinary characters on OS X.
set -e
case "$1" in
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
exit 0
;;
esac
if [ "$(uname -s)" != "Darwin" ]; then
echo "Error: this script must be run under Mac OS X." >&2
exit 1
fi
bundle exec rake db:dump > db/emoji2.json
mv db/emoji2.json db/emoji.json
open -g -a Safari db/aliases.html
osascript db/aliases.scpt | sed '/^$/d' > db/emoji2.json
mv db/emoji2.json db/emoji.json
if git diff --exit-code --stat -- db/emoji.json; then
echo "Done. The file \`db/emoji.json\` remains unchanged."
fi