如何使用 Syck 在 1.9 中的 JRuby 中执行 YAML?
如果我在 Ruby 1.9 模式下运行 JRuby,并告诉它使用 Syck 而不是 Psych,似乎没有任何效果。我错过了什么吗?
Andrew-Grimms-MacBook-Pro:~ agrimm$ ruby --version
jruby 1.6.1 (ruby-1.8.7-p330) (2011-05-08 3fe11da) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java]
Andrew-Grimms-MacBook-Pro:~ agrimm$ ruby --1.9 -S irb
jruby-head :001 > require "yaml"
=> true
jruby-head :002 > YAML::ENGINE.yamler = "syck"
=> "syck"
jruby-head :003 > YAML::ENGINE.yamler
=> "syck"
jruby-head :004 > 42.to_yaml
NameError: uninitialized constant Syck::Yecht
from org/jruby/RubyModule.java:2569:in `const_missing'
from org/jruby/RubyClass.java:218:in `allocate'
from /Users/agrimm/.rvm/rubies/jruby-head/lib/ruby/1.9/syck.rb:102:in `emitter'
from /Users/agrimm/.rvm/rubies/jruby-head/lib/ruby/1.9/syck.rb:399:in `quick_emit'
from /Users/agrimm/.rvm/rubies/jruby-head/lib/ruby/1.9/syck/rubytypes.rb:371:in `to_yaml'
from (irb):4:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1418:in `loop'
from org/jruby/RubyKernel.java:1205:in `catch'
from org/jruby/RubyKernel.java:1205:in `catch'
from /Users/agrimm/.rvm/rubies/jruby-head/bin/jirb:17:in `(root)'
背景:我尝试使用 Syck,因为我在 如何反序列化 Psych 中的类?
If I run JRuby in Ruby 1.9 mode, and tell it to use Syck rather than Psych, nothing seems to work. Am I missing something?
Andrew-Grimms-MacBook-Pro:~ agrimm$ ruby --version
jruby 1.6.1 (ruby-1.8.7-p330) (2011-05-08 3fe11da) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java]
Andrew-Grimms-MacBook-Pro:~ agrimm$ ruby --1.9 -S irb
jruby-head :001 > require "yaml"
=> true
jruby-head :002 > YAML::ENGINE.yamler = "syck"
=> "syck"
jruby-head :003 > YAML::ENGINE.yamler
=> "syck"
jruby-head :004 > 42.to_yaml
NameError: uninitialized constant Syck::Yecht
from org/jruby/RubyModule.java:2569:in `const_missing'
from org/jruby/RubyClass.java:218:in `allocate'
from /Users/agrimm/.rvm/rubies/jruby-head/lib/ruby/1.9/syck.rb:102:in `emitter'
from /Users/agrimm/.rvm/rubies/jruby-head/lib/ruby/1.9/syck.rb:399:in `quick_emit'
from /Users/agrimm/.rvm/rubies/jruby-head/lib/ruby/1.9/syck/rubytypes.rb:371:in `to_yaml'
from (irb):4:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1418:in `loop'
from org/jruby/RubyKernel.java:1205:in `catch'
from org/jruby/RubyKernel.java:1205:in `catch'
from /Users/agrimm/.rvm/rubies/jruby-head/bin/jirb:17:in `(root)'
Background: I'm trying to use Syck because of my problems with Psych in How do I deserialize classes in Psych?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来它没有在 JRuby 中实现。 1.9.2 下:
JRuby 1.6.2 下
虽然我(还)不是 JRuby 专家,但 JRuby 1.6.0 的发行说明表示
与 Ruby 1.9.2 的兼容性达到了非常高的水平。
也许这并没有延伸到syck..?Looks like it's not implemented in JRuby. Under 1.9.2:
Under JRuby 1.6.2
Although I'm not (yet) an expert with JRuby, the release notes for JRuby 1.6.0 say
compatibility with Ruby 1.9.2 to a very high level.
Perhaps this doesn't extend to syck..?