module AgileUtils::FileUtil
Constants
- CustomError
Public Class Methods
delete(files)
click to toggle source
Delete the files from the given list
@param files list of files to be deleted
# File lib/agile_utils/file_util.rb, line 43 def delete(files) files.each do |file| FileUtils.rm_rf(file) end end
find(base_dir, extension = "xhtml")
click to toggle source
Find list of files based on certain extension
@param [String] base_dir the starting directory @param [String] extension the file extension to search for
@return [Array<String>] list of matching files or empty list rubocop:disable CollectionMethods
# File lib/agile_utils/file_util.rb, line 15 def find(base_dir, extension = "xhtml") file_paths = [] Find.find(base_dir) do |path| file_paths << path if path =~ /.*\.#{extension}$/ end file_paths end
gunzip(filename, output_dir)
click to toggle source
Uncompress 'input.tar.gz' file
@param [String] filename input file in the 'tar.gzip' format @param [String] output_dir the output directory
# File lib/agile_utils/file_util.rb, line 34 def gunzip(filename, output_dir) input_file = File.open(filename, "rb") tgz = Zlib::GzipReader.new(input_file) Archive::Tar::Minitar.unpack(tgz, output_dir) end
tar_gzip_files(files, output="output.tgz")
click to toggle source
@param [Array<String>] files list of input files @param [String] output the output file in .tar.gz format
# File lib/agile_utils/file_util.rb, line 26 def tar_gzip_files(files, output="output.tgz") Minitar.pack(files, Zlib::GzipWriter.new(File.open(output, 'wb'))) end
time() { || ... }
click to toggle source
Time the operation before and after the operation for tuning purpose
# File lib/agile_utils/file_util.rb, line 50 def time beg_time = Time.now yield end_time = Time.now end_time - beg_time end