X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=main.rb;h=e294b4a15e3391a0e4b84d41235b2eee1265ca31;hp=76f543e61cffd9019e2a1eee49b4860e7e6ebbf4;hb=HEAD;hpb=bd862df9f2c494a890357b673a4ef26298515432 diff --git a/main.rb b/main.rb index 76f543e..e294b4a 100644 --- a/main.rb +++ b/main.rb @@ -1,10 +1,56 @@ -require './walkdir' +require_relative 'navigator' +require_relative 'page' +require_relative 'store' +require_relative 'walk_dir' -books = [] +@outputDir = 'output' + +@config_file = 'quanlib.ini' +@skip_class = false + +def handleArg(arg) + if arg.start_with?("--config=") + @config_file = arg[9..-1] + puts 'Using config file "' + @config_file + '".' + elsif "--purge" == arg + puts 'Purging database...' + @store.dropSchema() + if File.exists?(@store.unclassified_csv) + File.delete(@store.unclassified_csv) + end + elsif "--skip-class" == arg + puts 'Skipping load of classification table.' + @skip_class = true + elsif arg.start_with?("--") + abort('ERROR: Unrecognized option "' + arg + '".') + end +end + +@store = Store.new(@config_file) +@store.connect() + +for arg in ARGV + handleArg(arg) +end + +@store.init_db(@skip_class) for arg in ARGV - w = WalkDir.new(arg) - books.push(w.books) + if ! arg.start_with?("--") + puts 'Scanning directory "' + arg + '"...' + w = WalkDir.new(@config_file, arg) + w.books + end end -puts books +@store.cross_reference_lists + +puts 'Creating output...' + +navigator = Navigator.new(@store) +navigator.write_atoz_pages() +navigator.write_series_listing() +navigator.write_dewey() + +@store.disconnect() +