class Object
Public Instance Methods
delete_config_file(path)
click to toggle source
删除模块中的Aimfile
# File lib/aimtp.rb, line 103 def delete_config_file(path) file_name = path + '/Aimfile' if FileTest.exist?(file_name) FileUtils.rm(file_name) end end
pod(name, options = {})
click to toggle source
# File lib/aimtp.rb, line 67 def pod(name, options = {}) if options == {} $dep_arr.push('"' + name + '"') elsif options.is_a? String $dep_arr.push('"' + name + '"' + ', ' + '"' + options + '"') elsif options.is_a? Hash o_str = options.to_s o_str = o_str.gsub(/[\{\}]/, '') $dep_arr.push('"' + name + '"' + ', ' + o_str) end end
process_file(from_path, to_path)
click to toggle source
拷贝文件
# File lib/aimtp.rb, line 98 def process_file(from_path, to_path) FileUtils.cp(from_path, to_path) end
sub(name, path, nRoot = 1)
click to toggle source
# File lib/aimtp.rb, line 58 def sub(name, path, nRoot = 1) $sub_file_path_arr << 'sources/' + name + '/Aimfile' name_arr = name.split('/') mod_name = name_arr[name_arr.length - 1] $sub_pod_hash[mod_name] = path $sub_pod_path_hash[mod_name] = name $sub_need_root_hash[mod_name] = nRoot end
traverse(from_path, to_path)
click to toggle source
循环深入文件夹
# File lib/aimtp.rb, line 80 def traverse(from_path, to_path) if File.directory?(from_path) # 如果是目录 if !FileTest.exist?(to_path) FileUtils.mkdir_p(to_path) end dir = Dir.open(from_path) while name = dir.read next if name == "." # ※ next if name == ".." # ※ traverse(from_path + "/" + name, to_path + "/" + name) end dir.close else process_file(from_path, to_path) # 处理文件 end end