OSDN Git Service

1a06a9bb46326a74ea2fece04a6cd3b8f4c1e3eb
[tdcgexplorer/nimono-crawlers.git] / bin / load-arcs.rb
1 #!ruby
2 # encoding: utf-8
3 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4 require 'connection'
5 require 'location'
6 require 'arc'
7 require 'pmd'
8 require 'vmd'
9 require 'x'
10 require 'scrap'
11
12 location_code = ARGV.shift || 'mmd'
13 location = Location.find_by_code(location_code)
14 unless location
15   puts "location not found."
16   exit
17 end
18 scrap = Scrap.find_by_location_code(location.code)
19
20 ent = "/Volumes/uploader/src/#{location.code}/index.html"
21 open(ent) do |f|
22   while line = f.gets
23     if scrap.match(line)
24       name, summary, size, date, origname, locked = scrap.row
25       arc = location.create_arc(name, summary, size, date, origname, locked)
26       arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}")
27       puts
28     end
29   end
30 end