OSDN Git Service

fixed mmd3dcu site
[tdcgexplorer/nimono.git] / bin / load-arcs.rb
1 #!ruby
2 # vim: fileencoding=utf-8
3
4 location_code = ARGV.shift || 'mmd'
5 location = Location.find_by_code(location_code)
6 unless location
7   puts "location not found."
8   exit
9 end
10
11 while line = gets
12   case location.code
13   when 'mmd'
14     name, summary, size, date, mime, origname, with_key, with_password = line.chomp.split(/\t/)
15   when 'mmdfile', 'mmdacc1', 'mmdacc2'
16     name, summary, size, date, origname = line.chomp.split(/\t/)
17   end
18   md = /\.(.+)\z/.match(name)
19   extname = md[1]
20   code = File.basename(name, '.' + extname)
21   case location.code
22   when 'mmd'
23     #
24   when 'mmdfile'
25     code = 'file%04d' % code.to_i
26   when 'mmdacc1'
27     code = 'mini%04d' % code.to_i
28   when 'mmdacc2'
29     code = code[3..-1]
30   end
31   puts [ code, extname ].join(' ')
32   Arc.create(:code => code, :extname => extname, :location => location, :summary => summary, :origname => origname)
33 end