Improves handling of non-fiction classification data.
[quanlib.git] / main.rb
diff --git a/main.rb b/main.rb
index 76f543e61cffd9019e2a1eee49b4860e7e6ebbf4..4ea9c7057de2e456b65eecb2fcad0515b3fbc283 100644 (file)
--- a/main.rb
+++ b/main.rb
@@ -1,10 +1,48 @@
-require './walkdir'
+require 'navigator'
+require 'page'
+require 'store'
+require 'walkdir'
 
-books = []
+outputDir = 'output'
+
+book_ids = []
+imageCount = 0
+
+def handleArg(arg)
+  if "--purge" == arg
+    puts 'Purging database...'
+    @store.dropSchema()
+    if File.exists?(Store.unclassified_csv)
+      File.delete(Store.unclassified_csv)
+    end
+  elsif arg.start_with?("--")
+    abort('ERROR:  Unrecognized option "' + arg + '".')
+  end
+end
+
+@store = Store.new()
+@store.connect()
 
 for arg in ARGV
-  w = WalkDir.new(arg)
-  books.push(w.books)
+  handleArg(arg)
 end
 
-puts books
+@store.init_db()
+
+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()
+