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 "json"
require "securerandom" require "securerandom"
require "gemoji"
# https://github.com/PurpleBooth/alfred-emoji-snippet-pack/blob/main/bin/generate # 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 file "build" do
mkdir "build" mkdir "build"
end end
@ -25,26 +11,20 @@ end
task :rebuild => "build" do task :rebuild => "build" do
rm Dir["build/*.json"] rm Dir["build/*.json"]
Emoji.all.each do |emoji| URI.open("https://www.unicode.org/emoji/charts/emoji-ordering.txt") do |f|
uuid = SecureRandom.uuid f.read.scan(/(?:[^\n])#\s+(\S+)\s+(.*)$/).each do |emoji, name|
keywords = [emoji.description] uuid = SecureRandom.uuid
keywords.concat( File.write("build/#{emoji} [#{uuid}].json", JSON.dump({
emoji.aliases alfredsnippet: {
.map { _1.gsub(?_, " ") } snippet: emoji,
.reject { str_match(emoji.description, _1) } dontautoexpand: true,
) uid: uuid,
keywords.concat(emoji.tags) name: "#{emoji} #{name}",
keyword: name.split.map { _1.gsub(":", "") },
File.write("build/#{emoji.name} [#{uuid}].json", JSON.dump({ },
alfredsnippet: { }))
snippet: emoji.raw, end
dontautoexpand: true,
uid: uuid,
name: "#{emoji.raw} #{keywords.join(", ")}",
keyword: emoji.name,
},
}))
end end
end end
task :default => :rebuild task :default => :rebuild

Loading…
Cancel
Save