首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

Ruby脚本转换成可执行文件-OCRA

2013-12-20 
Ruby脚本转换成可执行文件---OCRAocra --helpocra [options] script.rboptions可取值如下:--dll dllnameIn

Ruby脚本转换成可执行文件---OCRA
ocra --helpocra [options] script.rboptions可取值如下:--dll dllname Include additional DLLs from the Ruby bindir.--no-lzma Disable LZMA compression of the executable.--quiet Suppress output.--help Display this information.--windows Force Windows application (rubyw.exe)--console Force console application (ruby.exe)--no-autoload Don't load/include script.rb's autoloads--icon Replace icon with a custom one--version Display version number

?

?

以下是测试过程:

?

先创建了一个测试脚本test.rb

?

require 'pathname'require_relative 'hello'path = Pathname.new(File.dirname(__FILE__)).realpathf = File.open("F:\\test.txt","w+")f.puts "test"f.puts pathf.closehello "hello world"

?

?

为了测试能否将依赖的脚本一并打包,该脚本引用了hello.rb

?

?

def hello s puts send

?

?

在命令行中执行?

?

F:\>ocra --console test.rb

=== Loading script to check dependencies

hello world

=== Including 53 encoding support files (3194880 bytes,

?

DL is deprecated, please use Fiddle

=== Building test.exe

=== Adding user-supplied source files

=== Adding ruby executable ruby.exe

=== Adding detected DLL C:/ruby-2.0.0/bin/zlib1.dll

=== Adding detected DLL C:/ruby-2.0.0/bin/LIBEAY32.dll

=== Adding detected DLL C:/ruby-2.0.0/bin/SSLEAY32.dll

=== Adding detected DLL C:/ruby-2.0.0/bin/libffi-6.dll

=== Adding library files

=== Compressing 9578823 bytes

=== Finished building test.exe (2410533 bytes)

?

结果:

文件操作正常,打印正常

不过使用path来获取脚本路径,这个会返回一个临时目录

C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ocr18A.tmp/src

所以这个方法应该用不了

?

path = Pathname.new(File.dirname(__FILE__)).realpath

?

其他的用法还有待体验。

?

?

?

?

?

?

热点排行