OSDN Git Service

merged load-entries
authornomeu <nomeu@nomeu.org>
Sat, 12 Jun 2010 19:30:30 +0000 (04:30 +0900)
committernomeu <nomeu@nomeu.org>
Sat, 12 Jun 2010 19:30:30 +0000 (04:30 +0900)
bin/load-arcs.rb
bin/load-entries.rb [deleted file]
lib/location.rb

index 2a77130..16b8874 100644 (file)
@@ -4,6 +4,9 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
 require 'connection'
 require 'location'
 require 'arc'
+require 'pmd'
+require 'vmd'
+require 'x'
 require 'scrap'
 
 location_code = ARGV.shift || 'mmd'
@@ -12,14 +15,16 @@ unless location
   puts "location not found."
   exit
 end
-
 scrap = Scrap.find_by_location(location.code)
 
 ent = "/Volumes/uploader/src/#{location.code}/index.html"
 open(ent) do |f|
   while line = f.gets
     if scrap.match(line)
-      location.create_arc *scrap.row
+      name, summary, size, date, origname = scrap.row
+      arc = location.create_arc(name, summary, size, date, origname)
+      arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}")
+      puts
     end
   end
 end
diff --git a/bin/load-entries.rb b/bin/load-entries.rb
deleted file mode 100644 (file)
index 015d4ab..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!ruby
-# vim: fileencoding=utf-8
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
-require 'connection'
-require 'location'
-require 'arc'
-require 'pmd'
-require 'vmd'
-require 'x'
-require 'scrap'
-
-location_code = ARGV.shift || 'mmd'
-location = Location.find_by_code(location_code)
-unless location
-  puts "location not found."
-  exit
-end
-scrap = Scrap.find_by_location(location.code)
-
-ent = "/Volumes/uploader/src/#{location.code}/index.html"
-open(ent) do |f|
-  while line = f.gets
-    if scrap.match(line)
-      name, = scrap.row
-      code, extname = location.generate_arc_code_and_extname(name)
-      arc = location.arcs.find_by_code(code)
-      next unless arc
-      arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}")
-      puts
-    end
-  end
-end
index 2dae5a8..eda840e 100644 (file)
@@ -23,7 +23,7 @@ class Location < ActiveRecord::Base
     arc = Arc.find_by_code(code)
     if arc
       puts "found code: #{code}"
-      return
+      return arc
     end
     puts "arcs.create code: #{code}"
     arc = arcs.create(:code => code, :extname => extname, :summary => summary, :origname => origname)