Sha256: f9333a0b068ab4d321a9deffc19470887fe732935846faba7d49d64c6f9ae5f1
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
require 'i18n/tasks/scanners/scanner' module I18n::Tasks::Scanners # Run multiple {Scanner Scanners} and merge their results. # @note The scanners are run concurrently. A thread is spawned per each scanner. # @since 0.9.0 class ScannerMultiplexer < Scanner # @param scanners [Array<Scanner>] def initialize(scanners:) @scanners = scanners end # Collect the results of all the scanners. Occurrences of a key from multiple scanners are merged. # # @note The scanners are run concurrently. A thread is spawned per each scanner. # @return (see Scanner#keys) def keys Results::KeyOccurrences.merge_keys collect_results.flatten(1) end private # @return [Array<Array<Results::KeyOccurrences>>] def collect_results return [@scanners[0].keys] if @scanners.length == 1 Array.new(@scanners.length).tap do |results| @scanners.map.with_index { |scanner, i| Thread.start { results[i] = scanner.keys } }.each(&:join) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems