作为磁悬浮的新手,我想从一个小但仍然有用的例子开始。所以我决定开始移动我用来生成磁悬浮发票的ruby类。但是我使用(优秀的)PDF库存在意外问题。
在rvm上我为应用程序生成了一个gemset,它在.rvmrc中为invoice目录设置。当我进入它时它会被使用:
Using /Users/patru/.rvm/gems/maglev-head with gemset invoice
当我安装大虾时,一切都很好,宝石似乎已经安装好了,并且正在生成ri-docs。但是,当应该创建rdoc时会出现问题,maglev提供的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)
没有文档就没什么大不了的,这已经足够了,但其他东西似乎出了问题,宝石列表说
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)
所以一切似乎都很好,但如果我这样做
require 'ruby gems'
require 'prawn'
in 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'
...
我可能在这里遗漏了一些明显的东西。我只想说这个“架设者”就足够了。我安装的宝石(见上面的宝石清单)可以毫无问题地要求,所以我不会做错事; - )
答案 0 :(得分:0)
这似乎是与irb的互动。我可以运行以下脚本并创建正确的pdf文件:
require 'rubygems'
require 'prawn'
Prawn::Document.generate('hello.pdf') do
text "Hello! from #{RUBY_ENGINE}"
end
提交错误报告