Cannot dump FeedNormalizer Feed objects using YAML

Discussion in 'Ruby' started by Shajith C T, Jun 23, 2007.

  1. Shajith C T

    Shajith C T Guest

    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}


    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 C T, Jun 23, 2007
    1. Advertisements

  2. Shajith C T

    Andy Smith Guest

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

    feed = FeedNormalizer.parse(open(""))
    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 Smith, Jun 23, 2007
    1. Advertisements

  3. Shajith C T

    Shajith C T Guest

    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 C T, Jun 23, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.