Skip to content

Commit 5f71f7f

Browse files
committed
Add support for the base keyword argument to Dir.[].
1 parent 5554bd3 commit 5f71f7f

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Compatibility:
3535

3636
* Yield different number of arguments for `Hash#each` and `Hash#each_pair` based
3737
on the block arity like MRI (#1629).
38-
* Add support for the `base` keyword argument to `Dir.glob`.
38+
* Add support for the `base` keyword argument to `Dir.{[], glob}`.
3939

4040
# 1.0 RC 14
4141

spec/tags/core/dir/element_reference_tags.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@ fails:Dir.[] matches non-dotfiles with '*'
44
fails:Dir.[] matches non-dotfiles in the current directory with '**'
55
fails:Dir.[] recursively matches any nondot subdirectories with '**/'
66
fails:Dir.[] matches dot or non-dotfiles with '{,.}*'
7-
fails:Dir.[] :base option passed matches entries only from within the specified directory
8-
fails:Dir.[] :base option passed accepts both relative and absolute paths
9-
fails:Dir.[] :base option passed returns [] if specified path does not exist
10-
fails:Dir.[] :base option passed returns [] if specified path is a file
11-
fails:Dir.[] :base option passed handles '' as current directory path
12-
fails:Dir.[] :base option passed handles nil as current directory path

src/main/ruby/core/dir.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ def home(user=nil)
209209
PrivateFile.expand_path("~#{user}")
210210
end
211211

212-
def [](*patterns)
212+
def [](*patterns, base: nil)
213213
if patterns.size == 1
214214
pattern = Truffle::Type.coerce_to_path(patterns[0], false)
215215
return [] if pattern.empty?
216216
patterns = glob_split pattern
217217
end
218218

219-
glob patterns
219+
glob patterns, base: base
220220
end
221221

222222
def glob(pattern, flags=0, base: nil, &block)

0 commit comments

Comments
 (0)