0
JRuby on Rails와 FeedTools를 사용하는 사람은 누구입니까?JRuby, Rails 및 FeedTool
NameError (undefined local variable or method `parser' for YAML:Module):.
내가 monkey_patch.rb
아래 코드를 추적 한 : 나는 FeedTools를 실행하려고 할 때 다음과 같은 오류를 받고 있어요. 그것은 파서 라인에 폭격이지만, Ruby와 Rails를 처음 접했고 스스로 디버깅 할 수 없었습니다. 이상한 것은 일반 old Rails와 Ruby에서 잘 작동한다는 것입니다. Java 컨테이너에 배포하려고하기 때문에 JRuby가 필요합니다.
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