Class: Packwerk::Parsers::Factory

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Singleton
Defined in:
lib/packwerk/parsers/factory.rb

Instance Method Summary collapse

Constructor Details

#initializeFactory

Returns a new instance of Factory.



24
25
26
27
28
# File 'lib/packwerk/parsers/factory.rb', line 24

def initialize
  @ruby_parser = T.let(nil, T.nilable(ParserInterface))
  @erb_parser = T.let(nil, T.nilable(ParserInterface))
  @erb_parser_class = T.let(nil, T.nilable(T::Class[T.anything]))
end

Instance Method Details

#erb_parser_classObject



41
42
43
# File 'lib/packwerk/parsers/factory.rb', line 41

def erb_parser_class
  @erb_parser_class ||= Erb
end

#erb_parser_class=(klass) ⇒ Object



46
47
48
49
# File 'lib/packwerk/parsers/factory.rb', line 46

def erb_parser_class=(klass)
  @erb_parser_class = klass
  @erb_parser = nil
end

#for_path(path) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/packwerk/parsers/factory.rb', line 31

def for_path(path)
  case path
  when RUBY_REGEX
    @ruby_parser ||= Ruby.new
  when ERB_REGEX
    @erb_parser ||= T.unsafe(erb_parser_class).new
  end
end