Class: Warnings::ParserFactory
- Inherits:
-
Object
- Object
- Warnings::ParserFactory
- Defined in:
- lib/warnings/parser/parser_factory.rb
Overview
Factory class for supported parsers.
Constant Summary collapse
- ERROR_NOT_SUPPORTED =
'Parser \'%s\' not supported.'.freeze
- AVAILABLE_PARSERS =
{ bandit: BanditParser, pylint: PylintParser, rubocop: RubocopParser }.freeze
Class Method Summary collapse
-
.create(type) ⇒ Parser
Create a new parser implementation.
Class Method Details
.create(type) ⇒ Parser
Create a new parser implementation.
20 21 22 23 24 25 26 27 |
# File 'lib/warnings/parser/parser_factory.rb', line 20 def self.create(type) key = type key = key.to_sym if key.respond_to?(:to_sym) parser = AVAILABLE_PARSERS[key] raise(format(ERROR_NOT_SUPPORTED, key)) if parser.nil? parser.new end |