lib/feedparser/feedparser.rb in ruby-feedparser-0.9.3 vs lib/feedparser/feedparser.rb in ruby-feedparser-0.9.4

- old
+ new

@@ -7,20 +7,21 @@ require 'magic' require 'uri' module FeedParser - VERSION = "0.9.3" + VERSION = "0.9.4" class UnknownFeedTypeException < RuntimeError end def self.recode(str) encoding = nil begin encoding = Magic.guess_string_mime_encoding(str) - rescue Magic::Exception + rescue => e + raise unless e.class.to_s =~ /\AMagic::(?:Exception|Error)\z/ # this happens when magic does not find any content at all, e.g. with # strings that contain only whitespace. In these case it *should* be safe # to assume UTF-8 encoding = Encoding::UTF_8 end @@ -197,10 +198,11 @@ when 0 return nil when 1 return creators[0] else - return creators[0...-1].join(", ")+" and "+creators[-1] + sorted_creators = creators.sort + return sorted_creators[0...-1].join(", ") + " and " + sorted_creators[-1] end end def to_s(localtime = true) s = "--------------------------------\n" +