Sha256: 6b13e15458a1037556be3cf404d4ccaed1664b1037745dcbec68ad4551d32774
Contents?: true
Size: 1005 Bytes
Versions: 4
Compression:
Stored size: 1005 Bytes
Contents
require "concurrent-ruby" require "parallel" # File scanner for finding todos class Todoloo::FileScanner def initialize(pattern, excludes: [], trace: nil) @parsers = Concurrent::Hash.new @pattern = pattern @excludes = excludes @trace_output = case trace when nil, false nil when true $stderr when String File.open(trace, "w") else raise ArgumentError, "Invalid value #{trace} for argument trace" end end # @return [Todoloo::TaskList] def scan Todoloo::TaskList.new.add(scan_files) end private def parser (@parsers[Parallel.worker_number] ||= Todoloo::Parser.new) end # @return [Array<Array<Task>>] def scan_files Parallel.map(Todoloo::Helpers.glob_paths(@pattern, excludes: @excludes)) do |path| trace { "* Scan #{path}" } parser.parse_and_transform(File.read(path), path: path) end end def trace(&block) return unless @trace_output @trace_output.puts(block.call) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
todoloo-0.0.4 | lib/todoloo/file_scanner.rb |
todoloo-0.0.3 | lib/todoloo/file_scanner.rb |
todoloo-0.0.2 | lib/todoloo/file_scanner.rb |
todoloo-0.0.1 | lib/todoloo/file_scanner.rb |