1 #ライセンスのjsonファイルを作るサポートツール
\r
4 puts "ls_helper.rb ls.yml [work dir=current dir]"
\r
5 puts "generate to ls.json"
\r
14 lg = YAML.load(open(filename).read)
\r
15 fn = File.basename filename, ".*"
\r
16 wd = ARGV[1] ? File.expand_path(ARGV[1]) : File.dirname(filename)
\r
17 o = wd + '/' + fn + '.json'
\r
21 g['licenses_attributes'].each do |lk, l|
\r
24 puts 'settings to json'
\r
25 l['settings'] = l['settings'].to_json.to_s
\r
27 if l['system_picture_file']
\r
28 fn = File.expand_path(wd + '/' + l['system_picture_file'])
\r
29 puts 'open system picture file ' + fn
\r
30 d = File.open(fn, 'rb').read
\r
31 b = Base64.encode64(d).gsub(/\r/, '').gsub(/\n/, '')
\r
32 l['system_picture_id'] = {"text" => b}
\r
33 l.delete 'system_picture_file'
\r
35 if l['credit_pictures']
\r
36 credit_pictures = {}
\r
37 l['credit_pictures'].each do |n, v|
\r
38 fn = File.expand_path(wd + '/' + v)
\r
39 puts 'open system picture file ' + fn
\r
40 d = File.open(fn, 'rb').read
\r
41 b = Base64.encode64(d).gsub(/\r/, '').gsub(/\n/, '')
\r
42 credit_pictures[n] = {"text" => b}
\r
44 l['credit_pictures'] = credit_pictures
\r
48 puts "generating " + o
\r
49 File.open(o, 'wb') do |f|
\r
50 f.write lg.to_json.to_s
\r