Module: SorbetAutoTyper

Extended by:
T::Sig
Defined in:
lib/sorbet_auto_typer/tracer.rb,
lib/sorbet_auto_typer.rb,
lib/sorbet_auto_typer/version.rb,
lib/sorbet_auto_typer/annotator.rb,
lib/sorbet_auto_typer/method_trace.rb,
lib/sorbet_auto_typer/configuration.rb,
lib/sorbet_auto_typer/source_rewriter.rb

Overview

typed: strict

Defined Under Namespace

Classes: Annotator, Configuration, Error, InvalidConfigurationError, MethodTrace, MissingConfigurationError, SourceRewriter, Tracer, TracerAlreadyRunning

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:

  • (config)


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

def configure(&blk)
  config = Configuration.new(output_file: nil)
  yield config
  @config = T.let(config, T.nilable(Configuration))
end

.reset!Object



48
49
50
51
# File 'lib/sorbet_auto_typer.rb', line 48

def reset!
  stop!
  @config = nil
end

.start!Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/sorbet_auto_typer.rb', line 20

def start!
  raise MissingConfigurationError.new if !@config
  raise InvalidConfigurationError.new unless @config.valid?
  raise TracerAlreadyRunning.new unless @current_tracer.nil?

  output_file = File.open(T.must(@config.output_file), 'w')

  @current_tracer = Tracer.new(output_file, T.must(@config.filter_path))
  @current_tracer.start!
end

.stop!Object



32
33
34
35
36
37
38
# File 'lib/sorbet_auto_typer.rb', line 32

def stop!
  @current_tracer = T.let(@current_tracer, T.nilable(Tracer))
  unless @current_tracer.nil?
    @current_tracer.stop!
    @current_tracer = nil
  end
end