用rubyscript2exe 把一个ruby 程序变成exe 文件
1,下载rubyscript2exe.rb 文件
http://github.com/cowlibob/rubyscript2exe.git ,从这里下载的能用。
其它的有个错误
修改也可以: 621:
$0.replace(File.expand_path("./init.rb")) 改成 $_0 = File.expand_path("./init.rb")
2, 直接运行 ruby rubyscript2exe.rb xx.rb
........waiting
你就能得到一个xx.exe
这是我写一个确定xml file 的header encoding 和文件内部encoding 是否相符的程序
里面用到
require 'csv'
require 'nokogiri'
require 'UniversalDetector'
所以先要安装一下
windows
gem install nokogiri
gem install rchardet
linux
sudo apt-get install libxslt1-dev libxml2-dev
sudo gem install nokogiri
sudo gem install rchardet
直接上文件:
require 'rubygems'
require 'csv'
require 'nokogiri'
require 'rchardet'
if(ARGV.size ==0 || (!File.directory? ARGV[0]))
puts "Please give me a folder url."
url=gets.strip
if(!File.directory? url)
puts "Please give me a right folder url."
exit
end
else
url = ARGV[0]#"/home/dermot/screenshots/clientA/projectA/"
end
File.delete(url.split('/').join('_')+".csv") if File.exist?(url.split('/').join('_')+".csv")
csv_file = CSV.open(url.split('/').join('_')+".csv","w")
csv_file << ["filename","isWellFormed","bomEncoding","headerEncoding","matched"]
def get_info(url)
str = File.read(url)
bom_encoding = CharDet.detect(str)["encoding"]
#is_bom = get_bom(str)
doc=Nokogiri::XML.parse(str)
header_encoding = doc.encoding
#doc.xpath("//p").collect(&:text).to_s
matched = (bom_encoding.include?(header_encoding)) ? "yes" : "no"
is_well_formed = confirm_form(str)
return is_well_formed,bom_encoding,header_encoding,matched
end
def get_bom(data)
if data[0,3] == "\xEF\xBB\xBF":
# EF BB BF UTF-8 with BOM
#@result = {"encoding"=> "UTF-8", "confidence"=> 1.0}
return "UTF-8_BOM"
elsif data[0,4] == "\xFF\xFE\x00\x00":
# FF FE 00 00 UTF-32, little-endian BOM
#@result = {"encoding"=> "UTF-32LE", "confidence"=> 1.0}
return "UTF-32LE_BOM"
elsif data[0,4] == "\x00\x00\xFE\xFF":
# 00 00 FE FF UTF-32, big-endian BOM
#@result = {"encoding"=> "UTF-32BE", "confidence"=> 1.0}
return "UTF-32BE_BOM"
elsif data[0,4] == "\xFE\xFF\x00\x00":
# FE FF 00 00 UCS-4, unusual octet order BOM (3412)
#@result = {"encoding"=> "X-ISO-10646-UCS-4-3412", "confidence"=> 1.0}
return "X-ISO-10646-UCS-4-3412_unusual_BOM"
elsif data[0,4] == "\x00\x00\xFF\xFE":
# 00 00 FF FE UCS-4, unusual octet order BOM (2143)
#@result = {"encoding"=> "X-ISO-10646-UCS-4-2143", "confidence"=> 1.0}
return "X-ISO-10646-UCS-4-2143_unusual_BOM"
elsif data[0,2] == "\xFF\xFE":
# FF FE UTF-16, little endian BOM
#@result = {"encoding"=> "UTF-16LE", "confidence"=> 1.0}
return "UTF-16LE_BOM"
elsif data[0,2] == "\xFE\xFF":
# FE FF UTF-16, big endian BOM
#@result = {"encoding"=> "UTF-16LE", "confidence"=> 1.0}
return "UTF-16LE_BOM"
end
return "no"
end
def confirm_form(str)
begin
Nokogiri::XML(str){|config| config.options=Nokogiri::XML::ParseOptions::STRICT}
rescue
return "no"
end
return "yes"
end
def walk_dir(path,csv_file )
dir = Dir.new(path)
dir.find_all do |file|
if (file != "." && file != "..")
url = path+File::SEPARATOR+file
if (File.directory? url)
walk_dir(url,csv_file )
elsif (!(/\.xml$/=~file).nil?)
csv_file << [url]+get_info(url)
end
end
end
end
walk_dir(url,csv_file )
csv_file.close
puts "finished"
想做成 gui的,可是没找到ruby类似filedialog 的组件,有知道的可以告诉下,3xu~!
分享到:
相关推荐
可以用于ruby1.9.1,ruby1.8.7的打包工具。将原始的进行了修改。
该工具可以将ruby脚本转换成exe可执行程序。
用于打包ruby代码生成EXE程序,最新的GEM包ocra-1.31.gem
ruby打包文件ruby打包文件ruby打包文件ruby打包文件ruby打包文件ruby打包文件ruby打包文件ruby打包文件ruby打包文件
一个将ruby脚本打包成二进制可执行文件的工具,包含源码和一个编译完成的二进制文件!支持跨平台编译,在windows、macOS、linux上均可以成功编译运行!包里的二进制文件是在ubuntu16.04中编译成功的版本!
ruby2ruby 提供一些用来根据 RubyParser 兼容的 Sexps 轻松生成纯 Ruby 代码的方法。可在 Ruby 中轻松实现动态语言处理。 标签:ruby2ruby
ruby186-25 for windows
Learn the principles behind object-oriented programming and within a few chapters create a fully functional Ruby application. You'll also gain a basic understanding of many ancillary technologies such...
跟其它界面开发包不同的是,Ruby-GNOME2不仅仅提 供界面控件,它提供了整个GNOME 2.0的环境,包含Ruby/GLib2、Ruby/ATK、Ruby/Pango、Ruby/GTK2、Ruby/GnomeCanvas2、Ruby /GNOME2、Ruby/GnomeVFS、Ruby/GtkHtml2、...
ruby笔记2ruby笔记2ruby笔记2ruby笔记2ruby笔记2
Ruby.on.Rails.Enterprise.Application.Development
rubyinstaller-2.7.0-1-x64.exe安装包,官网下载比较慢,故上传此安装包供其他人下载使用。
Learn the principles behind object-oriented programming and within a few chapters create a fully functional Ruby application. You’ll also gain a basic understanding of many ancillary technologies ...
Ruby on Rails Enterprise Application Development.pdf Ruby Rails企业应用程序开发
用于将ruby文件转换为EXE程序 目前最新版本为5.4,试用于任意ruby版本
Build your own ruby on rails web application
ruby源代码 ruby源代码 ruby源代码 ruby源代码2
命令行进入项目根目录直接执行 sh build.sh即可在桌面生成ipa安装包 #注意:使用本脚本上传到fir.im需要... ruby版本>1.9.3 (查看当前ruby版本 ruby -v) 二. ruby安装完毕,安装fir.im命令行插件 (gem install fir-cli)
ruby代码ruby代码ruby代码ruby代码ruby代码ruby代码ruby代码ruby代码
这是一个把ruby脚本代码转化为exe可执行文件转化后文件有点大。ruby2.0有望改进这方面的支持