Sha256: 48a127b75dcbdb82249d3c4a2552bf18f261150d8d31db840578212b9845eb79
Contents?: true
Size: 896 Bytes
Versions: 1
Compression:
Stored size: 896 Bytes
Contents
module Todoloo module Helpers extend self # Returns an `Enumerator` over the paths that match `pattern` # # TODO We need to optimize how we traverse the file-system so that we can short-circuit the excludes instead # of only filtering after finding them. # # TODO Optimize the seen_path handling # # @pattern [String, Array<String>] # The file paths to glob # # @excludes [Array<String>] # Optional list of file globs to exclude from the enumeration # # @return [Enumerator<String>] def glob_paths(pattern, excludes: []) seen_paths = Set.new Enumerator.new do |y| Dir[*Array(pattern)].lazy.each do |path| if !(seen_paths.include?(path) || excludes.any? { |e| File.fnmatch(e, path) }) y << path end seen_paths << path end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
todoloo-0.0.4 | lib/todoloo/helpers.rb |