in addition to the attached .patch on the simple-rss.rb, for my own purpose (RssFwd) the below chunk of code is the
dynamic class modifications I make when using simple rss.
the 'def clean_content' addition allows me to get attributes of tags (e.g. :enclosure) like this:
item.enclosure => #Hash{"url" => "http://.../...mp3", "type" =>
"audio/mpeg"}
item.enclosure['url'] => "http://.../...mp3"
######
class SimpleRSS
@@item_ignore_regex = /<link[^>]+type=.application[^>]+>/
@@item_tags << :modified
@@item_tags << :enclosure
@@feed_tags << :name
@@feed_tags << :webMaster
# convert content-less tags to hash of attributes!
alias_method :old_clean_content, :clean_content
def clean_content(tag, attrs, content)
val = old_clean_content(tag, attrs, content)
if (val.nil? or val.to_s.strip == "") and attrs
array = attrs.scan(/(\w+)=['"]?([^'"]+)/)
# thanks http://www.bigbold.com/snippets/posts/show/302
Hash[*array.collect { |x|
[x, x]
}.flatten]
else
val
end
end
end
######
|