Module: FactoryTrace

Defined in:
lib/factory_trace.rb,
lib/factory_trace/tracker.rb,
lib/factory_trace/version.rb,
lib/factory_trace/configuration.rb,
lib/factory_trace/helpers/caller.rb,
lib/factory_trace/writers/writer.rb,
lib/factory_trace/structures/trait.rb,
lib/factory_trace/helpers/converter.rb,
lib/factory_trace/helpers/statusable.rb,
lib/factory_trace/monkey_patches/dsl.rb,
lib/factory_trace/structures/factory.rb,
lib/factory_trace/monkey_patches/trait.rb,
lib/factory_trace/readers/trace_reader.rb,
lib/factory_trace/writers/trace_writer.rb,
lib/factory_trace/structures/collection.rb,
lib/factory_trace/writers/report_writer.rb,
lib/factory_trace/monkey_patches/factory.rb,
lib/factory_trace/processors/find_unused.rb,
lib/factory_trace/preprocessors/extract_used.rb,
lib/factory_trace/monkey_patches/monkey_patches.rb,
lib/factory_trace/preprocessors/extract_defined.rb,
lib/factory_trace/monkey_patches/definition_proxy.rb

Defined Under Namespace

Modules: Helpers, MonkeyPatches, Preprocessors, Processors, Readers, Structures, Writers Classes: Configuration, Tracker

Constant Summary collapse

VERSION =
"1.1.1"

Class Method Summary collapse

Class Method Details

.configurationObject



65
66
67
# File 'lib/factory_trace.rb', line 65

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



61
62
63
# File 'lib/factory_trace.rb', line 61

def configure
  yield(configuration)
end

.startObject



41
42
43
44
45
46
# File 'lib/factory_trace.rb', line 41

def start
  return unless configuration.enabled
  trace_definitions! if configuration.trace_definition?

  tracker.track!
end

.stopObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/factory_trace.rb', line 48

def stop
  return unless configuration.enabled

  # This is required to exclude parent traits from +defined_traits+
  FactoryBot.reload

  if configuration.mode?(:full)
    Writers::ReportWriter.new(configuration.out, configuration).write(Processors::FindUnused.call(defined, used))
  elsif configuration.mode?(:trace_only)
    Writers::TraceWriter.new(configuration.out, configuration).write(defined, used)
  end
end