16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/raev/author.rb', line 16
def self.normalize_name author_name
if author_name.nil?
return nil
else
author = author_name.strip
if author.empty?
return nil
end
if NO_AUTHOR_STRINGS.include?(author.downcase)
return nil
end
end
m = REGEX_EMAIL_WITH_NAME.match(author)
unless m.nil?
author = m[1]
end
author.gsub!(REGEX_DOUBLE_QUOTES, "".freeze)
author.gsub!(REGEX_QUOTES, "".freeze)
author.gsub!(" ".freeze, " ".freeze)
author.gsub!("by ".freeze, "".freeze)
return author.split(' '.freeze).map(&:capitalize).join(' '.freeze)
end
|