易截截图软件、单文件、免安装、纯绿色、仅160KB

Ruby Ruport实践—Ruport::Formatter应用扩展

Ruport目前自带支持PDF,HTML,CSV,TXT格式输出,如果想打印.xml,.bat报表怎么办?
本例将以XML格式为例,实现Ruport::Formatter的另一种自定义应用。
Ruport的应用参考: Ruby Ruport实践—简单报表系统
注:其他格式的报表只需要修改renders对应的内容(如希望保存为.bat格式,将renders :xml改为renders :bat),模板输出内容均用
"output<<"方法进行输出即可
一、在ReportOutputController中添加xml格式
class ReportXml < Ruport::Formatter
renders :xml, :for => ReportOutputController
build :data_sheet do
eval(options[:outputContent])
end
end 
二、report_templates中定义为如下内容的模板
output<<"<products>"
data.each do |d|
output<<"<product>"
output<<"<title>#{d.title}</title><type>#{d.description}</type><price>#{d.price}</price>"
output<<"</product>"
end
output<<"</products>" 
注:为了测试方便,可将 "eval(options[:outputContent])"直接替换成模板内容
演示效果:


相关文档:

ruby 字符串 理解 "" ''

ruby中单引号和双引号的意义有所不同,双引号包围的字符作变量替换,单引号包围的变量不做替换
也可以使用 %q 和 %Q 来生成字符串对象。%q 相当于单引号,%Q相当于双引号。
举例如下:
irb(main):010:0> "show trsult: #{1*3}"
=> "show trsult: 3"
irb(main):011:0> 'show trsult: #{1*3}'
=> "show trs ......

install ruby on cygwin

转自 http://zhujg.javaeye.com/blog/355040
首先 安装 cygwin
cygwin 要安装的插件是
默认的+ make + gcc + libiconv
+ openssl
cygwin下需要编译原文件
到ruby-lang(http://ruby-lang.org/)
下载ruby-1.9.1-p0.tar.gz
tar xvf ruby-1.9.1-p0.tar.gz
cd
ruby-1.9.1-p0
./configure
make && make in ......

ruby和watir学习常用网站整理

转自51testing.com, 原见:http://bbs.51testing.com/thread-171535-1-1.html http://swik.net/Watir+Programming
http://www.pragprog.com/ #很多好的源码哦
http://docs.rubygems.org/ #rubygems
http://www.fxruby.org/  #fxruby
http://groups.google.com/group/watir-general/topics #goog ......

Installing Ruby 1.8.6 from Source on Ubuntu

Installing Ruby from source is my preferred method, although in Ubuntu Feisty you can supposedly install it with apt-get install ruby
now. Here’s the essential packages needed to get a source build working right though and the process I just went through:
sudo apt-get install build-essentia ......

Install ruby 1.9 on Windows using zip binary

Update:  This post is outdated. All in one installer for 1.9
is ready now, you should use it if you need 1.9 on windows. Get it here
http://rubyforge.org/frs/?group_id=167
Ruby has “all-in-one” installer for Windows, but it is outdated. As
of May 2009, Ruby 1.9.1 is released, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号