Improves handling of non-fiction classification data.
[quanlib.git] / store.rb
index b1e3d7f7bb1e06b2540689d02a8742c957efc333..4895a5bb7483bbcf474c62daca224eee2227e85c 100644 (file)
--- 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