class DTK::Network::Client::ModuleDir

Operations for managing module folders

Public Class Methods

create_and_ret_tar_gz(source_dir, opts = {}) click to toggle source
# File lib/client/module_dir.rb, line 25
def self.create_and_ret_tar_gz(source_dir, opts = {})
  raise Error.new("Directory '#{source_dir}' does not exist!") unless Dir.exist?(source_dir)
  gzip(tar(source_dir, opts))
end
create_file_with_content(file_path, content) click to toggle source
# File lib/client/module_dir.rb, line 20
def self.create_file_with_content(file_path, content)
  FileUtils.mkdir_p(File.dirname(file_path))
  File.open(file_path, 'w') { |f| f << content }
end
delete_directory_content(path) click to toggle source
# File lib/client/module_dir.rb, line 16
def self.delete_directory_content(path)
  FileUtils.rm_rf(Dir.glob("#{path}/*"))
end
ret_path_with_current_dir(name) click to toggle source
# File lib/client/module_dir.rb, line 8
def self.ret_path_with_current_dir(name)
  "#{Dir.getwd}/#{name.gsub(':','/')}"
end
rm_f(path) click to toggle source
# File lib/client/module_dir.rb, line 12
def self.rm_f(path)
  FileUtils.rm_rf(path)
end
ungzip_and_untar(file, target_dir) click to toggle source
# File lib/client/module_dir.rb, line 30
def self.ungzip_and_untar(file, target_dir)
  raise Error.new("File '#{file}' does not exist!") unless File.exist?(file)
  FileUtils.mkdir_p(target_dir)
  untar(ungzip(File.open(file, "rb")), target_dir)
end