X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=store.rb;h=4895a5bb7483bbcf474c62daca224eee2227e85c;hp=b1e3d7f7bb1e06b2540689d02a8742c957efc333;hb=0aeb88ddc91aa8f9fd8d93a8004d5df5094a4613;hpb=b8fe580f73b094e366643388ecd2d184b643616a diff --git a/store.rb b/store.rb index b1e3d7f..4895a5b 100644 --- a/store.rb +++ b/store.rb @@ -6,8 +6,14 @@ require 'pg' require 'series' class Store + @@BASEPATH = '/arc/quanlib' # TODO: FIXME: configure this in a sane way + @@UNCLASSIFIED_CSV = @@BASEPATH + '/unclassified.csv' + + def self.unclassified_csv + @@UNCLASSIFIED_CSV + end + def initialize - @basepath = '/arc/quanlib' # TODO: FIXME: configure this in a sane way @conn = nil #@dburl = 'dbi:Pg:quanlib:localhost' @@ -328,7 +334,7 @@ EOS (efspath, efsname) = construct_efs_path(id) - fullpath = @basepath + '/efs/' + efspath + '/' + efsname + fullpath = @@BASEPATH + '/efs/' + efspath + '/' + efsname return Cover.new(nil, fullpath, mime_type) @@ -357,7 +363,7 @@ EOS (efspath, efsname) = construct_efs_path(efs_id) - efspath = @basepath + '/efs/' + efspath + efspath = @@BASEPATH + '/efs/' + efspath FileUtils.mkdir_p(efspath) @@ -444,7 +450,7 @@ EOS def populate_classifications_table puts "Populating the Classifications table..." first = true - CSV.foreach(@basepath + '/csv/class.csv') do |row| + CSV.foreach(@@BASEPATH + '/csv/class.csv') do |row| if first # skip the header row first = false @@ -484,7 +490,7 @@ EOS def populate_fast_table puts "Populating the FAST table..." first = true - CSV.foreach(@basepath + '/csv/fast.csv') do |row| + CSV.foreach(@@BASEPATH + '/csv/fast.csv') do |row| if first first = false # skip the header row else @@ -498,7 +504,7 @@ EOS def populate_series_table puts "Populating the Series table..." - CSV.foreach(@basepath + '/csv/series.csv') do |row| + CSV.foreach(@@BASEPATH + '/csv/series.csv') do |row| id = next_id('series_id') sqlInsert = "INSERT INTO Series (id, age, genre, grouping, code, descr) VALUES ($1, $2, $3, $4, $5, $6);" args = [id] + row