简体   繁体   English

如何在磁悬浮列车上使用大虾

[英]How to use prawn on maglev

Being new to maglev I wanted to start with a small, but still useful example. 作为磁悬浮列车的新手,我想从一个小但仍然有用的示例开始。 So i decided to start moving the ruby classes I use to generate my invoices to maglev. 因此,我决定开始将用于生成发票的红宝石类迁移到磁悬浮。 However I ran in an unexpected problem using the (excellent) prawn PDF-library. 但是,我使用(优秀的)虾PDF库遇到了一个意外的问题。

Being on rvm I generated a gemset for the application which is setup in a .rvmrc for the invoice directory. 在rvm上,我为该应用程序生成了一个宝石集,该宝石集在.rvmrc中为发票目录设置。 It gets used when I cd into it: 当我进入它时,它就会被使用:

Using /Users/patru/.rvm/gems/maglev-head with gemset invoice

When I install prawn everything starts out fine, the gem seems to be installed and the ri-docs are being generated. 当我安装大虾时,一切正常,似乎安装了gem并生成了ri-docs。 However, trouble starts when rdoc should be created, the maglev provided gem command gives me 但是,当应该创建rdoc时麻烦就开始了,磁悬浮提供的gem命令给了我

 gem install prawn
[INFO] The MagLev team publishes customized versions of some gems.
...
Successfully installed prawn-0.12.0
1 gem installed
Installing ri documentation for prawn-0.12.0...


RDoc failure in lib/prawn/images/jpg.rb at or around line 20 column 26

Before reporting this, could you check that the file
you're documenting compiles cleanly--RDoc is not a
full Ruby parser, and gets confused easily if fed
invalid programs.

The internal error was:

ERROR:  While generating documentation for prawn-0.12.0
... MESSAGE:   global $@ is a read-only variable
... RDOC args: --ri --op /Users/patru/.rvm/gems/maglev-head@invoice/doc/prawn-0.12.0/ri --title Prawn Documentation --main README -q lib README.md LICENSE COPYING GPLv2 GPLv3 --title prawn-0.12.0 Documentation --quiet
a RubySystemExit occurred (error 2752)

No big deal to live without documentation, it is good enough, but something else seems to go wrong, gem list says 宝石清单说,没有文档就没什么大不了的,它足够好,但似乎还有其他问题

Ascii85 (1.0.1)
bundler (1.0.21)
erector (0.8.3)
pdf-reader (0.10.1)
polyglot (0.3.3)
prawn (0.12.0)
rake (0.9.2)
treetop (1.4.10)
ttfunk (1.0.3)

so all seems to be well, but if I do 所以一切似乎都很好,但是如果我这样做

require 'ruby gems'
require 'prawn'

in irb (which works perfectly on my ree-1.8.7) I get a strange 在irb中(对我的ree-1.8.7完全有效),我得到一个奇怪的结果

NoMethodError: NoMethodError: undefined method `ruby_18' for 
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:246:in `__compileClass'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:14:in `__compileClass'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:13:in `__compileClass'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:12
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core.rb:78
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn.rb:11
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:59:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from (irb):5:in `__compileEval'
from (irb):7:in `__compileEval'
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:394:in `eval'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/1.8/irb.rb:159:in `eval_input'
...

I am probably missing something obvious here. 我可能在这里缺少明显的东西。 Suffice it to say that the 'erector' gem I installed as well (see the gem list above) can be required without problems, so I do not do everything wrong ;-) 只需说我还安装了“ erector”宝石(请参阅上面的宝石清单)就可以了,没有问题,所以我不会做错任何事情;-)

It seems to be an interaction with irb. 似乎是与irb的互动。 I can run the following script and it creates the correct pdf file: 我可以运行以下脚本,它会创建正确的pdf文件:

require 'rubygems'
require 'prawn'

Prawn::Document.generate('hello.pdf') do
  text "Hello! from #{RUBY_ENGINE}"
end

It's probably best to file bug reports at https://github.com/maglev/maglev/issues 最好在https://github.com/maglev/maglev/issues提交错误报告

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM