Sha256: ae4f2e93042c35abeb53ef5d9c92f6c23b5094c824ebe6899ded746d7007dc65
Contents?: true
Size: 1.54 KB
Versions: 7
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'fast_ignore' require 'set' require 'parallel' module Leftovers class Collector attr_reader :calls, :test_calls, :definitions def initialize @calls = [] @test_calls = [] @definitions = [] @count = 0 @count_calls = 0 @count_definitions = 0 end def collect Leftovers.reporter.prepare collect_file_list(Leftovers::FileList.new) print_progress Leftovers.newline @calls = @calls.to_set.freeze @test_calls = @test_calls.to_set.freeze end def collect_file_list(list) if Leftovers.parallel? Parallel.each(list, finish: method(:finish_file), &method(:collect_file)) else list.each { |file| finish_file(nil, nil, collect_file(file)) } end end def collect_file(file) file_collector = ::Leftovers::FileCollector.new(file.ruby, file) file_collector.collect file_collector.to_h end def print_progress Leftovers.print( "\e[2Kchecked #{@count} files, collected #{@count_calls} calls, #{@count_definitions} definitions\r" # rubocop:disable Layout/LineLength ) end def finish_file(_item, _index, result) @count += 1 @count_calls += result[:calls].length @count_definitions += result[:definitions].length print_progress if Leftovers.progress? if result[:test?] @test_calls.concat(result[:calls]) else @calls.concat(result[:calls]) end @definitions.concat(result[:definitions]) end end end
Version data entries
7 entries across 7 versions & 1 rubygems