X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=main.rb;h=564ba8b8159d523775146ca9324b3e96a1f0f83d;hb=8853161a81df93fb7ddb36e5dc2991f40fd230f0;hp=98f5a3555656ba398afcc59efad7e7ffc2f0e2a2;hpb=0104e6084e78bc47f39ad73698bd8d63090d5eef;p=quanlib.git diff --git a/main.rb b/main.rb index 98f5a35..564ba8b 100644 --- a/main.rb +++ b/main.rb @@ -1,10 +1,55 @@ -require './walkdir.rb' +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() +