Cannot dump FeedNormalizer Feed objects using YAML

S

Shajith C T

Hi,
I'm downloading and parsing an RSS/Atom feed using open-uri and
feed-normalizer and trying to save the parsed feed as yaml.

Sample code below:

%w(rubygems open-uri feed-normalizer yaml).each {|lib| require lib}
YAML.dump(FeedNormalizer::FeedNormalizer.parse(open("http://waxy.org/links/index.xml")))

Gives:

TypeError: can't dump anonymous class Class

I read elsewhere on the list about why Class-es cannot be dumped, but
I have no clue why trying to dump a FeedNormalizer::Feed object causes
this error(Don't know where to look).

Has anyone done this sort of thing before? Is there any painless
workaround to this?

Thanks in advance!
Shajith
 
A

Andy Smith

Is there any painless workaround to this?

Either use Marshal.dump instead, or set parser to nil on the feed object
before YAMLification:

feed = FeedNormalizer.parse(open("http://waxy.org/links/index.xml"))
feed.parser = nil # [1]
YAML.dump(feed) # now it should work...

# [1] or maybe feed.parser = feed.parser.to_s if you don't
# want to lose meta info.


I intend to fix this in the next release so that pre-serialization
object tampering isn't required :)

Hope that helps.

Andy
 
S

Shajith C T

Either use Marshal.dump instead, or set parser to nil on the feed object
before YAMLification:

Ah, so that's what I need to zero out. I need to use YAML because I
want to keep the data human-inspectable.

Much thanks, and looking forward to the next release.

Shajith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top