1 # Walk the directory (and subdirectories), identifying books.
4 # .../AuthorName/Title_of_the_Awesome_Book.ext
6 # Author is given as FirstLast. For example,
7 # Robert Anson Heinlein is RoberHeinlein, and
8 # JKRowling is JoanneRowling.
10 # Book titles have spaces replaced with underscores,
11 # and punctuation [,!?'] replaced with hyphens.
13 # If the book forms part of a series, then an all-capitals
14 # series designator, followed by a numeric volume number,
15 # followed by an underscore, is prefixed to the name.
16 # For example, Hardy Boys' volume 1, The Tower Treasure,
17 # is rendered as .../FranklinDixon/HB001_The_Tower_Treasure.epub
18 # and Mrs. Pollifax volume 6, On the China Station, is
19 # .../DorothyGilman/P06_On_the_China_Station.epub.
25 def initialize(store, root)
33 for file in @files.sort
34 if Book.can_handle?(file) && (!is_duplicate?(file))
35 book = Book.new(@store)
36 book.load_from_file!(file)
37 id = @store.store_book(book)
44 # Duplicate versions of a text are named
46 # Where suffix is one of bis, ter, quater, quinquies
47 # for the 2nd, 3rd, 4th or 5th variant respectively.
48 def is_duplicate?(file)
50 suffix = ['_bis.', '_ter.', '_quater.', '_quinquies.']
62 children = Dir.entries(path)
64 fullName = (path.chomp("/")) + "/" + child
65 if (File.directory?(fullName)) and (child != ".") and (child != "..") and (!File.symlink?(fullName))
67 if (sub != nil) and (sub.length > 0)
70 elsif (! File.directory?(fullName))