Derrick Johnson
Derrick Johnson

Reputation:

JRuby, Rails, and FeedTool

Anyone using JRUBY on Rails with FeedTools? I'm getting the following error when I try to run FeedTools:

NameError (undefined local variable or method `parser' for YAML:Module):. 

I've tracked the code down to monkey_patch.rb. It is bombing on the parser line, but I'm new to Ruby and Rails and couldn't debug it on my own. What's weird is it works fine with plain old Rails and Ruby. I need JRuby because I'm trying to deploy on a Java container.

require 'rexml/document'
require 'yaml'

module YAML
def YAML.dump( obj, io = nil )
  if obj.kind_of?(FeedTools::Feed) || obj.kind_of?(FeedTools::FeedItem)
    # Dangit, you WILL NOT serialize these things.
    obj.instance_variable_set("@xml_document", nil)
    obj.instance_variable_set("@root_node", nil)
    obj.instance_variable_set("@channel_node", nil)
  end
obj.to_yaml( io || io2 = StringIO.new )
io || ( io2.rewind; io2.read )
end

def YAML.load( io )
      yp = parser.load( io ) # <- Error here
  if yp.kind_of?(FeedTools::Feed) || yp.kind_of?(FeedTools::FeedItem)
    # No really, I'm serious, you WILL NOT deserialize these things.
    yp.instance_variable_set("@xml_document", nil)
    yp.instance_variable_set("@root_node", nil)
    yp.instance_variable_set("@channel_node", nil)
  end
  yp
end
end

Upvotes: 0

Views: 276

Answers (1)

Charles Oliver Nutter
Charles Oliver Nutter

Reputation: 1426

It's very likely this is fixed with the new YAML implementation that we'll ship in JRuby 1.4. Can you try a JRuby nightly build and let us know if it's still an issue?

Upvotes: 1

Related Questions