lib/find_files.rb in markdown_exec-2.3.0 vs lib/find_files.rb in markdown_exec-2.4.0

- old
+ new

@@ -26,24 +26,29 @@ # excluding directories if exclude_dirs is true. Paths are relative if use_relative_paths is true. # # Example: # find_files('version.rb', ['lib/**', 'spec'], true, true) # # This might return file paths like ['markdown_exec/version.rb', 'spec/version_spec.rb']. -def find_files(pattern, paths = ['', Dir.pwd], base_dir: Dir.pwd, exclude_dirs: false, use_relative_paths: true) +def find_files(pattern, paths = ['', Dir.pwd], base_dir: Dir.pwd, + exclude_dirs: false, use_relative_paths: true) matched_files = [] paths.each do |path_with_wildcard| # Combine the path with the wildcard and the pattern search_pattern = File.join(path_with_wildcard, pattern) # Use Dir.glob with the File::FNM_DOTMATCH flag to include hidden files files = Dir.glob(search_pattern, File::FNM_DOTMATCH) # Optionally exclude "." and ".." and directory names - files.reject! { |file| file.end_with?('/.', '/..') || File.directory?(file) } if exclude_dirs + files.reject! { |file| + file.end_with?('/.', '/..') || File.directory?(file) + } if exclude_dirs # Optionally use relative paths - files.map! { |file| file.sub(/^#{Regexp.escape(base_dir)}\//, '') } if use_relative_paths + files.map! { |file| + file.sub(/^#{Regexp.escape(base_dir)}\//, '') + } if use_relative_paths matched_files += files end matched_files.uniq