Misc fixes

This commit is contained in:
g0tmi1k
2018-05-15 09:05:58 +01:00
parent 44557797b0
commit 439900a1ea
3 changed files with 15 additions and 12 deletions

View File

@@ -68,10 +68,10 @@ class WpTarget < WebSite
users << row
end
if users
# Sort and uniq
users = users.sort.uniq
# Sort and uniq
users = users.sort.uniq
if users and users.size > 1
# Feedback
grammar = grammar_s(users.size)
puts warning("#{users.size} user#{grammar} exposed via API: #{json_users_url}")

View File

@@ -36,16 +36,19 @@ class WpTarget < WebSite
# Read in RSS/XML
xml = Nokogiri::XML(data)
# Look for <dc:creator> item
xml.xpath('//item/dc:creator').each do |node|
#Format: <dc:creator><![CDATA[.*]]></dc:creator>
users << [%r{.*}i.match(node).to_s]
begin
# Look for <dc:creator> item
xml.xpath('//item/dc:creator').each do |node|
#Format: <dc:creator><![CDATA[.*]]></dc:creator>
users << [%r{.*}i.match(node).to_s]
end
rescue
end
if users
# Sort and uniq
users = users.sort_by { |user| user.to_s.downcase }.uniq
# Sort and uniq
users = users.sort_by { |user| user.to_s.downcase }.uniq
if users and users.size > 1
# Feedback
grammar = grammar_s(users.size)
puts warning("Detected #{users.size} user#{grammar} from RSS feed:")