Class: DTK::Network::Client::ModuleDir
- Inherits:
-
Object
- Object
- DTK::Network::Client::ModuleDir
- Extended by:
- Util::Tar
- Defined in:
- lib/client/module_dir.rb
Overview
Operations for managing module folders
Class Method Summary collapse
- .create_and_ret_tar_gz(source_dir, opts = {}) ⇒ Object
- .create_file_with_content(file_path, content) ⇒ Object
- .delete_directory_content(path) ⇒ Object
- .ret_path_with_current_dir(name) ⇒ Object
- .rm_f(path) ⇒ Object
- .ungzip_and_untar(file, target_dir) ⇒ Object
Methods included from Util::Tar
Class Method Details
.create_and_ret_tar_gz(source_dir, opts = {}) ⇒ Object
25 26 27 28 |
# 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) ⇒ Object
20 21 22 23 |
# 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) ⇒ Object
16 17 18 |
# 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) ⇒ Object
8 9 10 |
# File 'lib/client/module_dir.rb', line 8 def self.ret_path_with_current_dir(name) "#{Dir.getwd}/#{name.gsub(':','/')}" end |
.rm_f(path) ⇒ Object
12 13 14 |
# File 'lib/client/module_dir.rb', line 12 def self.rm_f(path) FileUtils.rm_rf(path) end |
.ungzip_and_untar(file, target_dir) ⇒ Object
30 31 32 33 34 |
# 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 |