Skip to content

Commit

Permalink
Fix version filtering and deprecation warning
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tagliala committed Sep 13, 2024
1 parent 79d68a8 commit 78e9c49
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 78e9c49

Please sign in to comment.