module EM::FileUtils

Evented FileUtils.

Public Class Methods

cp(from, to) click to toggle source

Copy object using +cp -r+ command.

@param [String] from source path @param [String] to target path @return [CommandBuilder] the command builder object

# File lib/em-file-utils.rb, line 33
def self.cp(from, to)
    cmd = __get(:cp)
    cmd << :r
    cmd << from
    cmd << to
    cmd
end
mkdir(path) click to toggle source

Creates directory using +mkdir -p+ command.

@param [String] directory path @return [CommandBuilder] the command builder object

# File lib/em-file-utils.rb, line 90
def self.mkdir(path)
    cmd = __get(:mkdir)
    cmd << :p
    cmd << path
    cmd
end
mv(from, to) click to toggle source

Renames object using mv command.

@param [String] from source path @param [String] to target path @return [CommandBuilder] the command builder object

# File lib/em-file-utils.rb, line 49
def self.mv(from, to)
    cmd = __get(:mv)
    cmd << from
    cmd << to
    cmd
end
rm(path) click to toggle source

Removes object using +rm -r+ command.

@param [String] path path to file @return [CommandBuilder] the command builder object

# File lib/em-file-utils.rb, line 63
def self.rm(path)
    cmd = __get(:rm)
    cmd << :r
    cmd << path
    cmd
end
touch(path) click to toggle source

Touches file using touch command.

@param [String] path to the file @return [CommandBuilder] the command builder object

# File lib/em-file-utils.rb, line 77
def self.touch(path)
    cmd = __get(:touch)
    cmd << path
    cmd
end

Private Class Methods

__get(command) click to toggle source

Returns instance of command builder from cache.

# File lib/em-file-utils.rb, line 104
def self.__get(command)
    command = command.to_sym
    
    if @@cache.include? command
        command = @@cache[command]
        command.reset!  # returns
    else
        @@cache[command] = CommandBuilder::new(command)
    end
end