rubyµ÷ÓÃDLL
¿ªÔ´²âÊÔ¹¤¾ßwatirÊDzÉÓõÄrubyÓïÑÔ½øÐпª·¢µÄ¡£ÔÚÑо¿watir¿ò¼ÜµÄʱºò£¬·¢ÏÖÓÐÒ»²¿·Öº¯ÊýwatirûÓÐÌṩ¶øÇÒÔÝʱûÕÒµ½ºÏÊʵÄgem°ü£¬¶øºÜ¶à¹¦ÄÜÔÚÎÒÃÇÔÀ´µÄ×Ô¶¯»¯²âÊÔ¿ò¼ÜÖж¼Í¨¹ýcдµÄdll½øÐÐÁËʵÏÖ£¬ÓÚÊÇÎÒÃÇÏ£ÍûÄܹ»°ÑÕⲿ·ÖµÄdllÎÞ·ìµÄÒÆÖ²µ½watirÉÏ£¬¼õÉÙÎÒÃǵŤ×÷Á¿£¬¶øÇÒ¿ÉÒÔ¸ü¸ßЧµÄʵÏÖÎÒÃÇÐèÒªµÄ¹¦ÄÜ¡£
ÔÚrubyµÄ¿ªÔ´ÏîÄ¿ÖУ¬Win32ApiÕâ¸ögem¿ÉÒÔʵÏÖÎÒÃÇÐèÒªµÄ¹¦ÄÜ¡£Í¨¹ýÒÔÏ·½·¨ £¬ÎÒÃǾͿÉÒÔµ÷ÓÃÍⲿdllÖеĺ¯Êý¡£
Win32Api.new(dllname, proc, import, export)
²ÎÊý˵Ã÷
dllname:dllÎļþµÄÃû×Ö£¬Èç¹ûÏëֻдdllµÄÃû×Ö£¬¿ÉÒÔ½«dll·Åµ½system32Ŀ¼»òÕßµ±Ç°Ä¿Â¼Ï£¬»òÕßдÉÏdllÎļþËùÔڵķ¾¶
proc: dllÖк¯ÊýµÄÃû×Ö
import£ºº¯Êý´«Èë²ÎÊýµÄ²ÎÊýÀàÐÍ£¬ÆäÖÐ "p" ¶ÔÓ¦Ö¸Õ룬"n","l"¶ÔÓ¦long£¬"i"¶ÔÓ¦int£¬"v" ¶ÔÓ¦void£¬Èç¹ûÓжà¸ö²ÎÊý£¬¿ÉÒÔͨ¹ý ["p","n"]Êý×éµÄ·½Ê½À´ÊµÏÖ£¬ÆäÖÐÖÃΪnil¿ÉÒÔ±íʾûÓвÎÊý
export£ºº¯ÊýµÄ·µ»ØÖµÀàÐÍ£¬²ÎÊýÀàÐÍͬÉÏ
Win32API#call([args ...])
µ÷ÓÃdllÖеĺ¯Êý£¬²ÎÊýºÍ·µ»ØÖµÓ¦¸ÃÓënewÉêÃ÷ÖеÄÒ»Ö£¬Èç¹û·µ»ØÒ»¸öÖ¸Õ룬ÐèÒªÊÂÇ°³õʼ»¯£¬·ñÔò¿ÉÄÜ»áÓÐÄÚ´æÒç³öÎÊÌâ¡£
Àý×Ó:
ÓиödllµÄÍ·ÎļþµÄÉêÃ÷Ϊ:
extern "C" long PASCAL EXPORT BMPToJPG(char *jpg,char *bmp);
ÄÇôÔÚ½«Ö¸¶¨µÄdllÎļþ·ÅÔÚµ±Ç°Ä¿Â¼£¬ruby´úÂëÈçÏÂ
require 'rubygems'
require 'Win32Api'
JPG=Win32API.new(File.dirname(__FILE__)+"\\JpgDll.dll","BmpToJpg",["p","p"],"l")
JPG.call("D:\\1.bmp","D:\\1.jpg")
Ö´ÐÐÉÏÊö´úÂëºó£¬¾ÍÄÜ°ÑDÅÌϵÄ1.bmpÎļþÁí´æΪ 1.jpgÎļþ
Ïà¹ØÎĵµ£º
RuportÊÇÒ»¸öÃâ·ÑµÄRuby±¨±í¹¤¾ß£¬Ëü¿ÉÒÔÁîµ½ÖÆ×÷±¨±íÈí¼þ±äµÃ¼òµ¥Ò»Ð©¡£RuportÖ§³Ö´ÓÎļþ»òÕßÊý¾Ý¿â»ñµÃÊý¾Ý£¬Ìṩ¹¤¾ß²Ù×÷Êý¾Ý¡£¶îÍâµØ£¬RuportÖ§³Ö¸ßÀ©Õ¹µÄ¸ñʽ»¯Èí¼þ£¬Ä¿Ç°Äܹ»Ö§Ô®HTML¡¢PDF¡¢CSVºÍÎı¾Êä³ö¡£
Ruport¿ÉÄÜÊÇRubyĿǰΨһµÄ±¨±í¹¤¾ß£¬Ä¿Ç°ÔÚ³ÖÐø¿ª·¢ÖУ¬¸ü¶àµÄÐÂÌØÐÔÕýÔÚÌí¼Ó¡£
°²×°·½·¨£º
gem instal ......
¿ª·¢»·¾³
OS:WindowsXP
Ruby:Ruby1.8.7
Rails:Rails2.3.5
Mysql:Mysql5.0.9
IDE:Rubymine2.0.1
×¼±¸¹¤×÷£º
°²×°ÒÔÏÂgem°ü
gem install ruport
gem install ruport-util
gem install acts_as_reportable
±¾ÀýÉè¼ÆµÄ±¨±íϵͳ¹¤×÷ÔÀíÈçͼ£¨´¿Êô¸öÈËÀí½â£©£¬ÒÔProducts±íΪÀý£º
½ÓÏÂÀ´ÊµÏÖµÄÀý×Ó½«ÀûÓÃeval·½·¨ÊµÏ ......
ת×Ô 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 ......
RuportÖÐpdf_writer¶ÔÖÐÎĵÄÖ§³Ö²¢²»ºÃ£¬Êä³öµÄÖÐÎÄÏÔʾµÄÊÇÂÒÂë¡£ÉÏÍø²éÁ˺ܶà×ÊÁÏ£¬Ò²Ã»ÓÐÕÒµ½ºÃµÄ½â¾ö·½°¸£¬ÎÞÄÎÖ»ºÃ²é¿´Ô´´úÂ룬µ½µ×ΪʲôRuport×Ô´øµÄPDF¹¤¾ß²»Ö§³ÖÖÐÎÄÊä³ö¡£
Ruport::Formatter::PDF::WriterÖÐÕÒµ½ÒÔÏ´úÂë
metrics = load_font_metrics(font)
metrics = PDF::Writer: ......
RuportÄ¿Ç°×Ô´øÖ§³ÖPDF,HTML,CSV,TXT¸ñʽÊä³ö£¬Èç¹ûÏë´òÓ¡.xml£¬.bat±¨±íÔõô°ì£¿
±¾Àý½«ÒÔXML¸ñʽΪÀý£¬ÊµÏÖRuport::FormatterµÄÁíÒ»ÖÖ×Ô¶¨ÒåÓ¦Óá£
RuportµÄÓ¦Óòο¼£º Ruby Ruportʵ¼ù—¼òµ¥±¨±íϵͳ
×¢£ºÆäËû¸ñʽµÄ±¨±íÖ»ÐèÒªÐÞ¸Ärenders¶ÔÓ¦µÄÄÚÈÝ£¨ÈçÏ£Íû±£´æΪ.bat¸ñʽ£¬½«renders :xml¸ÄΪrenders :bat£©£¬ ......