def books
result = []
for file in @files.sort
- if Book.canHandle?(file)
+ if Book.can_handle?(file) && (!is_duplicate?(file))
book = Book.new(@store)
- book.loadFromFile(file)
+ book.load_from_file(file)
id = @store.store_book(book)
result.push(id)
end
return result
end
+ # Duplicate versions of a text are named
+ # xxx_suffix.ext
+ # Where suffix is one of bis, ter, quater, quinquies
+ # for the 2nd, 3rd, 4th or 5th variant respectively.
+ def is_duplicate?(file)
+ s = file.to_s
+ suffix = ['_bis.', '_ter.', '_quater.', '_quinquies.']
+ suffix.each do |pat|
+ if s.include?(pat)
+ return true
+ end
+ end
+
+ return false
+ end
+
def walk(path)
result = []
children = Dir.entries(path)