X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=main.rb;h=564ba8b8159d523775146ca9324b3e96a1f0f83d;hp=76f543e61cffd9019e2a1eee49b4860e7e6ebbf4;hb=8853161a81df93fb7ddb36e5dc2991f40fd230f0;hpb=bd862df9f2c494a890357b673a4ef26298515432 diff --git a/main.rb b/main.rb index 76f543e..564ba8b 100644 --- a/main.rb +++ b/main.rb @@ -1,10 +1,55 @@ -require './walkdir' +require_relative 'navigator' +require_relative 'page' +require_relative 'store' +require_relative 'walkdir' -books = [] +@outputDir = 'output' + +book_ids = [] +@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 - w = WalkDir.new(arg) - books.push(w.books) + handleArg(arg) end -puts books +@store.init_db(@skip_class) + +for arg in ARGV + if ! arg.start_with?("--") + puts 'Scanning directory "' + arg + '"...' + w = WalkDir.new(@store, arg) + book_ids += (w.books) + end +end + +puts 'Creating output...' + +navigator = Navigator.new(@store) +navigator.write_atoz_pages() +navigator.write_series_listing() +navigator.write_dewey() + +@store.disconnect() +