Add support to cross-reference books against list of award-winners.
[quanlib.git] / main.rb
1 require_relative 'navigator'
2 require_relative 'page'
3 require_relative 'store'
4 require_relative 'walkdir'
5
6 @outputDir = 'output'
7
8 book_ids = []
9 @config_file = 'quanlib.ini'
10 @skip_class = false
11
12 def handleArg(arg)
13   if arg.start_with?("--config=")
14     @config_file = arg[9..-1]
15     puts 'Using config file "' + @config_file + '".'
16   elsif "--purge" == arg
17     puts 'Purging database...'
18     @store.dropSchema()
19     if File.exists?(@store.unclassified_csv)
20       File.delete(@store.unclassified_csv)
21     end
22   elsif "--skip-class" == arg
23     puts 'Skipping load of classification table.'
24     @skip_class = true
25   elsif arg.start_with?("--")
26     abort('ERROR:  Unrecognized option "' + arg + '".')
27   end
28 end
29
30 @store = Store.new(@config_file)
31 @store.connect()
32
33 for arg in ARGV
34   handleArg(arg)
35 end
36
37 @store.init_db(@skip_class)
38
39 for arg in ARGV
40   if ! arg.start_with?("--")
41     puts 'Scanning directory "' + arg + '"...'
42     w = WalkDir.new(@store, arg)
43     book_ids += (w.books)
44   end
45 end
46
47 @store.cross_reference_lists
48
49 puts 'Creating output...'
50
51 navigator = Navigator.new(@store)
52 navigator.write_atoz_pages()
53 navigator.write_series_listing()
54 navigator.write_dewey()
55
56 @store.disconnect()
57