remove junk from real_names

This commit is contained in:
Christian Mehlmauer
2012-09-20 22:03:01 +02:00
parent 2c4069921b
commit 520cbdcf9b
3 changed files with 110 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ module WpUsernames
:real_name => real_name ? real_name : "empty"}
end
end
usernames = remove_junk_from_real_name(usernames)
# clean the array, remove nils and possible duplicates
usernames.flatten!
@@ -79,6 +80,21 @@ module WpUsernames
body[%r{<title>([^<]*)</title>}i, 1]
end
def remove_junk_from_real_name(usernames)
real_names = []
usernames.each do |u|
real_name = u[:real_name]
unless real_name == "empty"
real_names << real_name
end
end
junk = get_equal_string_end(real_names)
usernames.each do |u|
u[:real_name] = u[:real_name].sub(/#{junk}$/, "")
end
usernames
end
def author_url(author_id)
@uri.merge("?author=#{author_id}").to_s
end