1 #フキダシテンプレートを作るサポートツール
\r
3 puts "sbt_helper.rb -Ku input.json output.json [work dir=input dir]"
\r
10 wd = ARGV[2] ? File.expand_path(ARGV[2]) : File.dirname(inputfile)
\r
11 outputfile = wd + '/' + ARGV[1]
\r
13 puts "#{inputfile} to #{outputfile}"
\r
14 def replace_system_picture attr, wd
\r
15 attr.each do |name, value|
\r
17 if value['system_picture_file']
\r
18 fn = File.expand_path(wd + '/' + value['system_picture_file'])
\r
19 puts 'open system picture file ' + fn
\r
20 d = File.open(fn, 'rb').read
\r
21 b = Base64.encode64(d).gsub(/\r/, '').gsub(/\n/, '')
\r
22 value['system_picture_id'] = {"text" => b}
\r
23 value.delete 'system_picture_file'
\r
25 replace_system_picture value, wd
\r
30 json = JSON.parse(open(inputfile).read)
\r
31 replace_system_picture json, wd
\r
33 puts "generating " + outputfile
\r
34 File.open(outputfile, 'w') do |f|
\r
35 f.write json.to_json.to_s
\r