X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=walkdir.rb;h=236e3feaf7244852b4b58e780e9fdce456da6fc2;hp=1dadd2e35b95974f81ad43366698c46b93dac7b9;hb=fcaeedd4d1c128ff84371c0a7db5d0af6751492a;hpb=dfbc8c62ee2ee6e188609fc44e1a5ac4df40acf4 diff --git a/walkdir.rb b/walkdir.rb index 1dadd2e..236e3fe 100644 --- a/walkdir.rb +++ b/walkdir.rb @@ -31,9 +31,9 @@ class WalkDir 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 @@ -41,6 +41,22 @@ class WalkDir 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)