5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/raev/author.rb', line 5
def self.normalize_name author_name
if author_name.nil?
return nil
else
author = author_name.strip
if author.empty?
return nil
end
no_authors = ["admin", "blogs", "editor", "staff"]
if no_authors.include?(author.downcase)
return nil
end
end
m = /\((.*)\)/.match(author)
unless m.nil?
author = m[1]
end
author = author.gsub(/\"(.*)\"/, "").gsub(/\'(.*)\'/, "").gsub(" ", " ")
author = author.gsub("by ", "")
return author.split(' ').map(&:capitalize).join(' ')
end
|