require 'connection'
require 'location'
require 'arc'
+require 'scrap'
location_code = ARGV.shift || 'mmd'
location = Location.find_by_code(location_code)
exit
end
-while line = gets
- name, summary, size, date, origname = line.chomp.split(/\t/)
- md = /\.(.+)\z/.match(name)
- extname = md[1]
- code = File.basename(name, '.' + extname)
- case location.code
- when 'mmd'
- #
- when 'mmdfile'
- code = 'file%04d' % code.to_i
- when 'mmdacc1'
- code = 'mini%04d' % code.to_i
- when 'mmdacc2'
- code = code[3..-1]
- end
- arc = Arc.find_by_code(code)
- if arc
- puts "found code: #{code}"
- next
+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
+ end
end
- puts "Arc.create code: #{code}"
- arc = Arc.create(:code => code, :extname => extname, :location => location, :summary => summary, :origname => origname)
end
class Location < ActiveRecord::Base
+ has_many :arcs
+
+ def create_arc(name, summary, size, date, origname)
+ md = /\.(.+)\z/.match(name)
+ extname = md[1]
+ code = File.basename(name, '.' + extname)
+ case self.code
+ when 'mmd'
+ #
+ when 'mmdfile'
+ code = 'file%04d' % code.to_i
+ when 'mmdacc1'
+ code = 'mini%04d' % code.to_i
+ when 'mmdacc2'
+ code = code[3..-1]
+ end
+ arc = Arc.find_by_code(code)
+ if arc
+ puts "found code: #{code}"
+ return
+ end
+ puts "arcs.create code: #{code}"
+ arc = arcs.create(:code => code, :extname => extname, :summary => summary, :origname => origname)
+ end
end