Class: Drydock::FileManager
- Inherits:
-
Object
- Object
- Drydock::FileManager
- Defined in:
- lib/drydock/file_manager.rb
Class Method Summary collapse
Class Method Details
.find(path, ignorefile, prepend_path: false, recursive: true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/drydock/file_manager.rb', line 5 def self.find(path, ignorefile, prepend_path: false, recursive: true) path = path.sub(%r{/$}, '') [].tap do |results| ::Find.find(path) do |subpath| subpath = subpath.sub(%r{^#{path}/}, '') Find.prune if ignorefile.match?(subpath) if File.directory?(subpath) Find.prune if path != subpath && !recursive elsif prepend_path results << File.join(path, subpath) else results << subpath end end end end |