OSDN Git Service

read zip on scrap
authornomeu <nomeu@nomeu.org>
Sat, 12 Jun 2010 18:47:43 +0000 (03:47 +0900)
committernomeu <nomeu@nomeu.org>
Sat, 12 Jun 2010 18:47:43 +0000 (03:47 +0900)
bin/read-zip.rb

index 98d1c66..8eea431 100644 (file)
@@ -1,3 +1,11 @@
+#!ruby
+# vim: fileencoding=utf-8
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'scrap'
+
+location = ARGV.shift || 'mmd'
+scrap = Scrap.find_by_location(location)
+
 require 'rubygems'
 gem 'zipruby'
 require 'zipruby'
@@ -27,9 +35,13 @@ rescue Zip::Error => exc
   puts "error: " + exc.message
 end
 
-location = ARGV.shift || 'mmd'
-
-Dir.glob("/Volumes/uploader/arc/#{location}/*.zip") do |ent|
-  dump_zip(ent)
-  puts
+ent = "/Volumes/uploader/src/#{location}/index.html"
+open(ent) do |f|
+  while line = f.gets
+    if scrap.match(line)
+      name, = scrap.row
+      dump_zip("/Volumes/uploader/arc/#{location}/#{name}")
+      puts
+    end
+  end
 end