OSDN Git Service

arc.create_zip_entries
[tdcgexplorer/nimono-crawlers.git] / bin / load-entries.rb
1 #!ruby
2 # vim: fileencoding=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(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, = scrap.row
25       code, extname = location.generate_arc_code_and_extname(name)
26       arc = location.arcs.find_by_code(code)
27       next unless arc
28       arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}")
29       puts
30     end
31   end
32 end