Class: AnnotateRb::ModelAnnotator::FileToParserMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_rb/model_annotator/file_to_parser_mapper.rb

Defined Under Namespace

Classes: UnsupportedFileTypeError

Constant Summary collapse

MAP =
{
  ".rb" => FileParser::CustomParser,
  ".yml" => FileParser::YmlParser
}.freeze

Class Method Summary collapse

Class Method Details

.map(file_name) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/annotate_rb/model_annotator/file_to_parser_mapper.rb', line 14

def map(file_name)
  extension = File.extname(file_name).downcase
  parser = MAP[extension]

  raise UnsupportedFileTypeError, "File '#{file_name}' does not have a supported file type." if parser.nil?

  parser
end