Module: EM::FileUtils

Defined in:
lib/em-file-utils.rb

Overview

Evented FileUtils.

Constant Summary collapse

@@cache =

Commands instances cache.

{ }

Class Method Summary collapse

Class Method Details

.cp(from, to) ⇒ CommandBuilder

Copy object using cp -r command.

Parameters:

  • from (String)

    source path

  • to (String)

    target path

Returns:

  • (CommandBuilder)

    the command builder object



33
34
35
36
37
38
39
# 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) ⇒ CommandBuilder

Creates directory using mkdir -p command.

Parameters:

  • directory (String)

    path

Returns:

  • (CommandBuilder)

    the command builder object



90
91
92
93
94
95
# File 'lib/em-file-utils.rb', line 90

def self.mkdir(path)
    cmd = __get(:mkdir)
    cmd << :p
    cmd << path
    cmd
end

.mv(from, to) ⇒ CommandBuilder

Renames object using mv command.

Parameters:

  • from (String)

    source path

  • to (String)

    target path

Returns:

  • (CommandBuilder)

    the command builder object



49
50
51
52
53
54
# File 'lib/em-file-utils.rb', line 49

def self.mv(from, to)
    cmd = __get(:mv)
    cmd << from
    cmd << to
    cmd
end

.rm(path) ⇒ CommandBuilder

Removes object using rm -r command.

Parameters:

  • path (String)

    path to file

Returns:

  • (CommandBuilder)

    the command builder object



63
64
65
66
67
68
# File 'lib/em-file-utils.rb', line 63

def self.rm(path)
    cmd = __get(:rm)
    cmd << :r
    cmd << path
    cmd
end

.touch(path) ⇒ CommandBuilder

Touches file using touch command.

Parameters:

  • path (String)

    to the file

Returns:

  • (CommandBuilder)

    the command builder object



77
78
79
80
81
# File 'lib/em-file-utils.rb', line 77

def self.touch(path)
    cmd = __get(:touch)
    cmd << path
    cmd
end