下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
require 'find' module Find def match(*paths) matched = [] find(*paths) { |path| matched << path if yield path } return matched end module_function :match end def ExecuteAllSh(sourcefile) sourcefile .each do |s| system("bash \""<< s << "\"") end end def ExecuteAllPl(sourcefile) sourcefile .each do |s| system("perl \""<< s << "\"") end end def ExecuteAllRb(sourcefile) sourcefile .each do |s| system("ruby \""<< s << "\"") end end def ExecuteAllPy(sourcefile) sourcefile .each do |s| system("python \""<< s << "\"") end end def ExecuteAllRpmBinRun(sourcefile) sourcefile .each do |s| system("\""<< s << "\"") end end def ExecuteAllClass(sourcefile) sourcefile .each do |s| system("java \""<< s[0...-6] << "\"") end end def ExecuteAllBundle(sourcefile) sourcefile .each do |s| system("\""<< s << "\"") end end def ExecuteAllJar(sourcefile) sourcefile .each do |s| system("java -jar \""<< s << "\"") end end ExecuteAllSh Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".sh"} ExecuteAllPl Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".pl"} ExecuteAllRb Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".rb"} ExecuteAllPy Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".py"} ExecuteAllRpmBinRun Find.match("./"){ |p| ext = p[-4...p.size]; ext && (ext.downcase == ".rpm" || ext.downcase == ".bin" || ext.downcase == ".run")} ExecuteAllClass Find.match("./"){ |p| ext = p[-6...p.size]; ext && ext.downcase == ".class"} ExecuteAllBundle Find.match("./"){ |p| ext = p[-7...p.size]; ext && ext.downcase == ".bundle"} ExecuteAllJar Find.match("./"){ |p| ext = p[-4...p.size]; ext && ext.downcase == ".jar"}
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。