Alpha Chen 7 months ago
parent 1bb8fecc33
commit 3ee0723d9f
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -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,26 +11,20 @@ end
task :rebuild => "build" do
rm Dir["build/*.json"]
Emoji.all.each do |emoji|
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({
alfredsnippet: {
snippet: emoji.raw,
dontautoexpand: true,
uid: uuid,
name: "#{emoji.raw} #{keywords.join(", ")}",
keyword: emoji.name,
},
}))
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
File.write("build/#{emoji} [#{uuid}].json", JSON.dump({
alfredsnippet: {
snippet: emoji,
dontautoexpand: true,
uid: uuid,
name: "#{emoji} #{name}",
keyword: name.split.map { _1.gsub(":", "") },
},
}))
end
end
end
task :default => :rebuild

Loading…
Cancel
Save