From 95160cc75a654fcfab784be92fca3f4744cdf7c2 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Fri, 13 Sep 2024 20:41:16 +0200 Subject: [PATCH] Fix version filtering and deprecation warning The original `reject` had no effect due to matching full paths and comparing `false` against a regular expression. This change replaces a non-functional `reject.map` with `map.grep` for correct filtering and resolves a deprecation warning. Close #266 --- lib/document.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/document.rb b/lib/document.rb index 20c309d..64283a2 100644 --- a/lib/document.rb +++ b/lib/document.rb @@ -101,7 +101,7 @@ def title=(new_title) # Returns an array of the document version identifiers. def versions versions = Dir.glob(directory + 'v*') - versions.reject { |v| !v =~ /^v\d+$/ }.map { |v| File.basename v }.sort + versions.map { |v| File.basename(v) }.grep(/\Av\d+\z/).sort end # Returns true if the document has the specified version.