module RBS::FileFinder
Public Class Methods
(Pathname path, skip_hidden: boolish, ?immediate: top) { (Pathname) → void } → void
(Pathname path, skip_hidden: boolish, ?immediate: top) → Enumerator[Pathname, void]
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/file_finder.rb, line 7 def self.each_file(path, immediate: nil, skip_hidden:, &block) return enum_for((__method__ or raise), path, immediate: immediate, skip_hidden: skip_hidden) unless block case when path.file? yield path when path.directory? paths = Pathname.glob("#{path}/**/*.rbs") if skip_hidden paths.select! do |child| child.relative_path_from(path).ascend.drop(1).none? { _1.basename.to_s.start_with?("_") } end end paths.sort_by!(&:to_s) paths.each(&block) end end
Enumerate RBS files under path
When path is a file, it yields the path.
FileFinder.each_file(Pathname("foo.rbs")) {} # => yields `foo.rbs`
When path is a directory, it yields all .rbs files under the directory, recursively.
-
Skips files under directory starting with
_, ifskip_hiddenistrue -
Yields files under directory starting with
_even ifskip_hiddenis true, when the_directory is given explicitly, andimmediate:istrue
FileFinder.each_file(Pathname("sig"), skip_hidden: false) {} # => yields all `.rbs` files under `sig` FileFinder.each_file(Pathname("sig"), skip_hidden: true) {} # => yields all `.rbs` files under `sig`, skips `_` directories FileFinder.each_file(Pathname("_hidden"), skip_hidden: true) {} # => yields all `.rbs` files under `_hidden`, skips other `_` directories
immediate keyword is unused and left for API compatibility.