class Leftovers::Collector

Attributes

calls[R]
definitions[R]
test_calls[R]

Public Class Methods

new() click to toggle source
# File lib/leftovers/collector.rb, line 11
def initialize
  @calls = []
  @test_calls = []
  @definitions = []
  @count = 0
  @count_calls = 0
  @count_definitions = 0
end

Public Instance Methods

collect() click to toggle source
# File lib/leftovers/collector.rb, line 20
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
collect_file(file) click to toggle source
# File lib/leftovers/collector.rb, line 37
def collect_file(file)
  file_collector = ::Leftovers::FileCollector.new(file.ruby, file)
  file_collector.collect

  file_collector.to_h
end
collect_file_list(list) click to toggle source
# File lib/leftovers/collector.rb, line 29
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
finish_file(_item, _index, result) click to toggle source
# File lib/leftovers/collector.rb, line 50
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
print_progress() click to toggle source