Improves handling of non-fiction classification data.
[quanlib.git] / main.rb
1 require 'navigator'
2 require 'page'
3 require 'store'
4 require 'walkdir'
5
6 outputDir = 'output'
7
8 book_ids = []
9 imageCount = 0
10
11 def handleArg(arg)
12   if "--purge" == arg
13     puts 'Purging database...'
14     @store.dropSchema()
15     if File.exists?(Store.unclassified_csv)
16       File.delete(Store.unclassified_csv)
17     end
18   elsif arg.start_with?("--")
19     abort('ERROR:  Unrecognized option "' + arg + '".')
20   end
21 end
22
23 @store = Store.new()
24 @store.connect()
25
26 for arg in ARGV
27   handleArg(arg)
28 end
29
30 @store.init_db()
31
32 for arg in ARGV
33   if ! arg.start_with?("--")
34     puts 'Scanning directory "' + arg + '"...'
35     w = WalkDir.new(@store, arg)
36     book_ids += (w.books)
37   end
38 end
39
40 puts 'Creating output...'
41
42 navigator = Navigator.new(@store)
43 navigator.write_atoz_pages()
44 navigator.write_series_listing()
45 navigator.write_dewey()
46
47 @store.disconnect()
48