Class: Decidim::DirectVerifications::Parsers::NameParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/decidim/direct_verifications/parsers/name_parser.rb

Constant Summary collapse

LINE_DELIMITER =
/[\r\n;,]/.freeze
NON_ALPHA_CHARS =
/[^[:print:]]|["$<>|\\]/.freeze

Constants inherited from BaseParser

BaseParser::EMAIL_REGEXP

Instance Method Summary collapse

Methods inherited from BaseParser

#initialize, #to_h

Constructor Details

This class inherits a constructor from Decidim::DirectVerifications::Parsers::BaseParser

Instance Method Details

#headerObject



10
11
12
# File 'lib/decidim/direct_verifications/parsers/name_parser.rb', line 10

def header
  nil
end

#linesObject



14
15
16
# File 'lib/decidim/direct_verifications/parsers/name_parser.rb', line 14

def lines
  txt.split(LINE_DELIMITER)
end

#parse_data(email, line, _header) ⇒ Object



18
19
20
21
22
# File 'lib/decidim/direct_verifications/parsers/name_parser.rb', line 18

def parse_data(email, line, _header)
  name = parse_name(email, line)
  name = strip_non_alpha_chars(name)
  name.presence || fallback_name(email)
end