Class: FastIgnore::Walkers::FileSystem
- Defined in:
- lib/fast_ignore/walkers/file_system.rb
Instance Method Summary collapse
-
#allowed?(path, root: Dir.pwd, directory: nil, content: nil, exists: nil, include_directories: false) ⇒ Boolean
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists.
-
#each(parent_full_path, parent_relative_path, &block) ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from Base
Constructor Details
This class inherits a constructor from FastIgnore::Walkers::Base
Instance Method Details
#allowed?(path, root: Dir.pwd, directory: nil, content: nil, exists: nil, include_directories: false) ⇒ Boolean
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fast_ignore/walkers/file_system.rb', line 6 def allowed?(path, root: Dir.pwd, directory: nil, content: nil, exists: nil, include_directories: false) # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists full_path = PathExpander.(path, root) return false unless full_path.start_with?(root) begin dir = directory?(full_path, directory) rescue ::Errno::ENOENT, ::Errno::EACCES, ::Errno::ELOOP, ::Errno::ENAMETOOLONG nil end return false if !include_directories && dir candidate = ::FastIgnore::Candidate.new(full_path, nil, dir, exists, content) return false unless candidate.exists? @rule_groups.allowed_recursive?(candidate) end |
#each(parent_full_path, parent_relative_path, &block) ⇒ Object
rubocop:disable Metrics/MethodLength
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fast_ignore/walkers/file_system.rb', line 25 def each(parent_full_path, parent_relative_path, &block) # rubocop:disable Metrics/MethodLength ::Dir.children(parent_full_path).each do |filename| full_path = parent_full_path + filename dir = directory?(full_path, nil) candidate = ::FastIgnore::Candidate.new(full_path, filename, dir, true, nil) next unless @rule_groups.allowed_unrecursive?(candidate) relative_path = parent_relative_path + filename if dir each(full_path + '/', relative_path + '/', &block) else yield(relative_path) end rescue ::Errno::ENOENT, ::Errno::EACCES, ::Errno::ENOTDIR, ::Errno::ELOOP, ::Errno::ENAMETOOLONG nil end end |