--- /dev/null
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'connection'
+require 'location'
+p Location.count
--- /dev/null
+#!ruby
+# vim: fileencoding=utf-8
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'connection'
+require 'location'
+require 'arc'
+
+location_code = ARGV.shift || 'mmd'
+location = Location.find_by_code(location_code)
+unless location
+ puts "location not found."
+ exit
+end
+
+while line = gets
+ case location.code
+ when 'mmd'
+ name, summary, size, date, mime, origname, with_key, with_password = line.chomp.split(/\t/)
+ when 'mmdfile', 'mmdacc1', 'mmdacc2'
+ name, summary, size, date, origname = line.chomp.split(/\t/)
+ end
+ 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
+ end
+ puts "Arc.create code: #{code}"
+ arc = Arc.create(:code => code, :extname => extname, :location => location, :summary => summary, :origname => origname)
+end
--- /dev/null
+#!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'
+
+location_code = ARGV.shift || 'mmd'
+location = Location.find_by_code(location_code)
+unless location
+ puts "location not found."
+ exit
+end
+
+while line = gets
+ case line
+ when /^$/
+ #
+ when /^error:/
+ #
+ when /^# (.+)/
+ path = $1
+ basename = File.basename(path)
+ md = /\.(.+)\z/.match(basename)
+ extname = md[1]
+ code = basename.sub(/\.(.+)\z/, '')
+ 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_location_id_and_code(location.id, code)
+ else
+ size, comp_size, date, path = line.chomp.split(/\t/)
+ if arc && /\.pmd\z/.match(path)
+ puts [ code, path ].join(' ')
+ arc.pmds.find_or_create_by_path(path)
+ end
+ if arc && /\.vmd\z/.match(path)
+ puts [ code, path ].join(' ')
+ arc.vmds.find_or_create_by_path(path)
+ end
+ if arc && /\.x\z/.match(path)
+ puts [ code, path ].join(' ')
+ arc.xes.find_or_create_by_path(path)
+ end
+ end
+end
--- /dev/null
+#!ruby
+# vim: fileencoding=utf-8 :
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'connection'
+require 'location'
+
+location = Location.find_or_initialize_by_id(1)
+location.update_attributes(:code => "mmd", :site => "http://bytatsu.net/uploader/mikumikudance/", :summary => "MMD専用アップローダ")
+
+location = Location.find_or_initialize_by_id(2)
+location.update_attributes(:code => "mmdfile", :site => "http://loda.jp/mmdfile/", :summary => "MMDデータ保管庫")
+
+location = Location.find_or_initialize_by_id(3)
+location.update_attributes(:code => "mmdacc1", :site => "http://www9.atpages.jp/~mmdaccessory/uploader/", :summary => "MMDアクセサリアップローダ(小物版)")
+
+location = Location.find_or_initialize_by_id(4)
+location.update_attributes(:code => "mmdacc2", :site => "http://www9.atpages.jp/~mmdaccessory/uploader2/", :summary => "MMD Accessory Uploader")
--- /dev/null
+# PostgreSQL. Versions 7.4 and 8.x are supported.
+#
+# Install the ruby-postgres driver:
+# gem install ruby-postgres
+# On Mac OS X:
+# gem install ruby-postgres -- --include=/usr/local/pgsql
+# On Windows:
+# gem install ruby-postgres
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+development:
+ adapter: postgresql
+ encoding: unicode
+ database: nimono_development
+ pool: 5
+ username: nimono
+ password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # The server defaults to notice.
+ #min_messages: warning
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: postgresql
+ encoding: unicode
+ database: nimono_test
+ pool: 5
+ username: nimono
+ password:
+
+production:
+ adapter: postgresql
+ encoding: unicode
+ database: nimono_production
+ pool: 5
+ username: nimono
+ password:
--- /dev/null
+class Arc < ActiveRecord::Base
+ belongs_to :location
+ has_many :pmds
+ has_many :vmds
+ has_many :xes
+end
--- /dev/null
+require 'yaml'
+options = YAML.load(IO.read("config/database.yml"))["development"]
+require 'rubygems'
+gem 'activerecord'
+require 'active_record'
+ActiveRecord::Base.establish_connection(options)
--- /dev/null
+class Location < ActiveRecord::Base
+end
--- /dev/null
+class Pmd < ActiveRecord::Base
+ belongs_to :arc
+end
--- /dev/null
+class Vmd < ActiveRecord::Base
+ belongs_to :arc
+end
--- /dev/null
+class X < ActiveRecord::Base
+ belongs_to :arc
+end