|
|
|
@ -1,23 +1,9 @@
|
|
|
|
|
require "open-uri"
|
|
|
|
|
require "json"
|
|
|
|
|
require "securerandom"
|
|
|
|
|
|
|
|
|
|
require "gemoji"
|
|
|
|
|
|
|
|
|
|
# https://github.com/PurpleBooth/alfred-emoji-snippet-pack/blob/main/bin/generate
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
light_skin_tone: ["🏻", "Light Skin Tone"],
|
|
|
|
|
medium_light_skin_tone: ["🏼", "Medium-Light Skin Tone"],
|
|
|
|
|
medium_skin_tone: ["🏽", "Medium Skin Tone"],
|
|
|
|
|
medium_dark_skin_tone: ["🏾", "Medium-Dark Skin Tone"],
|
|
|
|
|
dark_skin_tone: ["🏿", "Dark Skin Tone"],
|
|
|
|
|
}.each do |key, (unicode_alias, desc)|
|
|
|
|
|
Emoji.create(key.to_s) do |char|
|
|
|
|
|
char.add_unicode_alias unicode_alias
|
|
|
|
|
char.description = desc
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
file "build" do
|
|
|
|
|
mkdir "build"
|
|
|
|
|
end
|
|
|
|
@ -25,28 +11,22 @@ end
|
|
|
|
|
task :rebuild => "build" do
|
|
|
|
|
rm Dir["build/*.json"]
|
|
|
|
|
|
|
|
|
|
Emoji.all.each do |emoji|
|
|
|
|
|
URI.open("https://www.unicode.org/emoji/charts/emoji-ordering.txt") do |f|
|
|
|
|
|
f.read.scan(/(?:[^\n])#\s+(\S+)\s+(.*)$/).each do |emoji, name|
|
|
|
|
|
uuid = SecureRandom.uuid
|
|
|
|
|
keywords = [emoji.description]
|
|
|
|
|
|
|
|
|
|
keywords.concat(
|
|
|
|
|
emoji.aliases
|
|
|
|
|
.map { _1.gsub(?_, " ") }
|
|
|
|
|
.reject { str_match(emoji.description, _1) }
|
|
|
|
|
)
|
|
|
|
|
keywords.concat(emoji.tags)
|
|
|
|
|
|
|
|
|
|
File.write("build/#{emoji.name} [#{uuid}].json", JSON.dump({
|
|
|
|
|
File.write("build/#{emoji} [#{uuid}].json", JSON.dump({
|
|
|
|
|
alfredsnippet: {
|
|
|
|
|
snippet: emoji.raw,
|
|
|
|
|
snippet: emoji,
|
|
|
|
|
dontautoexpand: true,
|
|
|
|
|
uid: uuid,
|
|
|
|
|
name: "#{emoji.raw} #{keywords.join(", ")}",
|
|
|
|
|
keyword: emoji.name,
|
|
|
|
|
name: "#{emoji} #{name}",
|
|
|
|
|
keyword: name.split.map { _1.gsub(":", "") },
|
|
|
|
|
},
|
|
|
|
|
}))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
task :default => :rebuild
|
|
|
|
|
|
|
|
|
|
def str_match(a, b)
|
|
|
|
|