[ruby-core:77974] [Ruby trunk Feature#7360][Feedback] Adding Pathname#glob
From:
akr@...
Date:
2016-11-05 14:00:44 UTC
List:
ruby-core #77974
Issue #7360 has been updated by Akira Tanaka.
Status changed from Assigned to Feedback
It seems the proposed implementation treats the receiver as a glob pattern.
```
% ruby -rpathname -e '
class Pathname
def glob(pattern, flags = 0, &b)
Array(pattern).flat_map do |pat|
self.class.glob(join(pat), flags, &b)
end
end
end
p Pathname("/b*").glob("i*")
'
[#<Pathname:/boot/initrd.img-3.16.0-4-amd64>, #<Pathname:/bin/ip>]
```
I think it is not intentional.
----------------------------------------
Feature #7360: Adding Pathname#glob
https://bugs.ruby-lang.org/issues/7360#change-61308
* Author: Alexander E. Fischer
* Status: Feedback
* Priority: Normal
* Assignee: Akira Tanaka
----------------------------------------
Currently there is only a Pathname.glob method, which allows you to find Pathname objects by a pattern including wildcard characters like '*'.
I would like to be able to use this relative to a current Pathname.
some_directory = Pathname.new('some_directory')
Pathname.glob(some_directory + 'a*') # all children starting with "a"
could then simply be:
some_directory.glob('a*') # all children starting with "a"
If you like the idea, please let me know. I will provide a patch then.
---Files--------------------------------
19c4ae36aaea65b30e8b73c89f7ac42bd6905ed7.patch (2.84 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>