X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=store.rb;fp=store.rb;h=69e1278d40393ea9d3d7e75d34cdf452645e8ed1;hp=4895a5bb7483bbcf474c62daca224eee2227e85c;hb=2891b7126f522211f6d38f1ea3f684ffefb27b94;hpb=0aeb88ddc91aa8f9fd8d93a8004d5df5094a4613 diff --git a/store.rb b/store.rb index 4895a5b..69e1278 100644 --- a/store.rb +++ b/store.rb @@ -1,32 +1,39 @@ require 'csv' require 'fileutils' +require 'inifile' 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 + def unclassified_csv + @basePath + '/csv/unclassified.csv' end - def initialize + def initialize(config_file) @conn = nil - #@dburl = 'dbi:Pg:quanlib:localhost' - @dbhost = "localhost" + config = IniFile.load(config_file) + if nil == config + puts 'FATAL: Failed to load config file "' + config_file + '". Aborting initialization.' + return + end + + section = config['database'] + @dbhost = section['host'] @dbport = 5432 - @dbname = 'quanlib' - @dbuser = 'quanlib' - @dbpass = 'quanlib' + @dbname = section['name'] + @dbuser = section['user'] + @dbpass = section['pass'] + + section = config['filesystem'] + @basePath = section['basePath'] end def connect # @conn = PGconn.connect('localhost', 5432, '', '', 'quanlib', 'quanlib', 'quanlib') - @conn = PG.connect('localhost', 5432, '', '', 'quanlib', 'quanlib', 'quanlib') + @conn = PG.connect(@dbhost, @dbport, '', '', @dbname, @dbuser, @dbpass) return @conn end @@ -41,14 +48,14 @@ class Store return path, name end - def create_schema + def create_schema(skip_class) create_authors = <