| 1 | carriers = %w(kddi softbank docomo) |
|---|
| 2 | perl='/usr/bin/perl' |
|---|
| 3 | |
|---|
| 4 | # ------------------------------------------------------------------------- |
|---|
| 5 | # basic |
|---|
| 6 | |
|---|
| 7 | task :default => ['test'] |
|---|
| 8 | |
|---|
| 9 | task 'test' => ['dat', 'ucm', 'Makefile'] do |
|---|
| 10 | sh 'make test' |
|---|
| 11 | end |
|---|
| 12 | |
|---|
| 13 | file 'Makefile' do |
|---|
| 14 | sh 'perl Makefile.PL' |
|---|
| 15 | end |
|---|
| 16 | |
|---|
| 17 | # ------------------------------------------------------------------------- |
|---|
| 18 | # dat/ |
|---|
| 19 | |
|---|
| 20 | dat_files = [carriers.map{|x| "dat/#{x}-table.yaml"}, carriers.map{|x| "dat/#{x}-table.pl"}, 'dat/convert-map-utf8.yaml', 'dat/convert-map-utf8.yaml'].flatten |
|---|
| 21 | task 'dat' => dat_files |
|---|
| 22 | |
|---|
| 23 | file 'dat/docomo-table.yaml' do |
|---|
| 24 | sh "#{perl} ./tools/docomo-scrape.pl > dat/docomo-table.yaml" |
|---|
| 25 | end |
|---|
| 26 | |
|---|
| 27 | file 'dat/softbank-table.yaml' => ['dat/softbank-unicode2sjis_auto.pl'] do |
|---|
| 28 | sh "#{perl} ./tools/softbank-scrape.pl > dat/softbank-table.yaml" |
|---|
| 29 | sh "#{perl} ./tools/softbank-scrape-name.pl" |
|---|
| 30 | # Update kddi/softbank yaml English names |
|---|
| 31 | sh "#{perl} ./tools/add-names-by-mapping.pl dat/softbank-table.yaml" |
|---|
| 32 | end |
|---|
| 33 | |
|---|
| 34 | file 'dat/softbank-unicode2sjis_auto.pl' |
|---|
| 35 | |
|---|
| 36 | file 'dat/kddi-table.yaml' => ['typeD.pdf'] do |
|---|
| 37 | sh "#{perl} ./tools/kddi-extract.pl typeD.pdf > dat/kddi-table.yaml" |
|---|
| 38 | # Update kddi/softbank yaml English names |
|---|
| 39 | sh "#{perl} ./tools/add-names-by-mapping.pl dat/kddi-table.yaml" |
|---|
| 40 | end |
|---|
| 41 | |
|---|
| 42 | file 'dat/convert-map-utf8.yaml' do |
|---|
| 43 | sh "#{perl} tools/convert-map-scrape.pl > dat/convert-map-utf8.yaml" |
|---|
| 44 | end |
|---|
| 45 | |
|---|
| 46 | [carriers.map {|x| "dat/#{x}-table.pl"}, 'dat/convert-map-utf8.pl'].flatten.each do |f| |
|---|
| 47 | file f => [f.gsub(/\.pl/, '.yaml')] do |
|---|
| 48 | sh "#{perl} ./tools/yaml2perl.pl #{f.gsub(/\.pl/, '.yaml')} #{f}" |
|---|
| 49 | end |
|---|
| 50 | end |
|---|
| 51 | |
|---|
| 52 | # ------------------------------------------------------------------------- |
|---|
| 53 | # ucm/ |
|---|
| 54 | |
|---|
| 55 | encodings = %w(airh docomo kddi-cp932 kddi-auto softbank-auto) |
|---|
| 56 | ucm_files = [encodings.map{|x| "ucm/x-sjis-#{x}-raw.ucm" }, carriers.map{|x| "ucm/x-utf8-#{x}.ucm"}].flatten |
|---|
| 57 | task :ucm => ucm_files |
|---|
| 58 | |
|---|
| 59 | encodings.each do |carrier| |
|---|
| 60 | file "ucm/x-sjis-#{carrier}-raw.ucm" => ['dat/softbank-table.yaml', 'dat/kddi-table.yaml', "tools/make-sjis-ucm.pl", "dat/docomo-table.yaml"] do |
|---|
| 61 | sh "#{perl} ./tools/make-sjis-ucm.pl" |
|---|
| 62 | end |
|---|
| 63 | end |
|---|
| 64 | file 'tools/make-sjis-ucm.pl' |
|---|
| 65 | |
|---|
| 66 | carriers.map{|x|"ucm/x-utf8-#{x}.ucm"}.each { |f| |
|---|
| 67 | file f => ['dat/convert-map-utf8.yaml'] do |
|---|
| 68 | sh "#{perl} ./tools/make-utf8-ucm.pl" |
|---|
| 69 | end |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | # ------------------------------------------------------------------------- |
|---|
| 73 | # carrier pdf |
|---|
| 74 | |
|---|
| 75 | file 'typeD.pdf' do |
|---|
| 76 | sh 'wget http://www.au.kddi.com/ezfactory/tec/spec/pdf/typeD.pdf' |
|---|
| 77 | end |
|---|
| 78 | |
|---|
| 79 | # ------------------------------------------------------------------------- |
|---|
| 80 | |
|---|
| 81 | task :clean do |
|---|
| 82 | sh 'rm typeD.pdf' if File.exist?('typeD.pdf') |
|---|
| 83 | sh "rm #{ucm_files.join(' ')} #{dat_files.join(' ')}" |
|---|
| 84 | end |
|---|
| 85 | |
|---|