-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgenerate_jisyo.rb
executable file
·52 lines (41 loc) · 1.01 KB
/
generate_jisyo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
require 'time'
require 'bundler'
require 'optparse'
Bundler.require
prefix = ''
opt = OptionParser.new
opt.on('-p VAL', '--prefix=VAL') do |p| prefix = p end
opt.parse ARGV
Entry = Struct.new(:name, :raw) do
def <=>(that)
name <=> that.name
end
end
entries = Emoji.all.flat_map do |emoji|
emoji.aliases.map do |name|
Entry.new(name, emoji.raw)
end
end
entries.sort!
gemoji_version = Bundler.load.specs.find do |spec|
spec.name == 'gemoji'
end.version.to_s
jisyo_path = File.join(__dir__, 'SKK-JISYO.emoji.utf8')
license_path = File.join(__dir__, 'LICENSE')
File.open(jisyo_path, 'w') do |f|
f << DATA.read.gsub(/%VERSION%/, gemoji_version)
f << File.read(license_path).gsub(/^/, ";; ")
f << ";;\n"
f << ";; okuri-ari entries.\n"
f << ";; okuri-nasi entries.\n"
entries.each do |entry|
f << "#{prefix}#{entry.name} /#{entry.raw}/\n"
end
end
__END__
;; -*- fundamental -*- ; coding: utf-8 -*-
;; Emoji dictionary for SKK system
;;
;; Generated using gemoji %VERSION%
;;