Module: Viking::FileUtils

Defined in:
lib/viking/fileutilz.rb

Class Method Summary collapse

Class Method Details

.cd(dirname, &block) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/viking/fileutilz.rb', line 4

def self.cd(dirname, &block)
  if block
    Viking::Dir.chdir(dirname, &block)
  else
    Viking::Dir.chdir(dirname)
  end
end

.chdir(dirname, &block) ⇒ Object



12
13
14
# File 'lib/viking/fileutilz.rb', line 12

def self.chdir(dirname, &block)
  cd(dirname, &block)
end

.chmod(mode, list) ⇒ Object



16
17
18
19
20
21
# File 'lib/viking/fileutilz.rb', line 16

def self.chmod(mode, list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |path|
    Viking::File.chmod(mode, path)
  end
end

.chown(user, group, list) ⇒ Object



23
24
25
26
27
28
# File 'lib/viking/fileutilz.rb', line 23

def self.chown(user, group, list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |dir|
    Viking::File.chown(user, group, dir)
  end
end

.getwdObject



30
31
32
# File 'lib/viking/fileutilz.rb', line 30

def self.getwd
  Viking::Dir.getwd
end

.makedirs(list) ⇒ Object



34
35
36
37
38
39
# File 'lib/viking/fileutilz.rb', line 34

def self.makedirs(list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |dir|
    Viking::Dir.mkdir(dir)
  end
end

.mkdir(list) ⇒ Object



41
42
43
# File 'lib/viking/fileutilz.rb', line 41

def self.mkdir(list)
  makedirs(list)
end

.move(src, dst) ⇒ Object



45
46
47
# File 'lib/viking/fileutilz.rb', line 45

def self.move(src, dst)
  Viking::File.move(src, dst)
end

.mv(src, dst) ⇒ Object



49
50
51
# File 'lib/viking/fileutilz.rb', line 49

def self.mv(src, dst)
  move(src, dst)
end

.pwdObject



53
54
55
# File 'lib/viking/fileutilz.rb', line 53

def self.pwd
  getwd
end

.remove(list) ⇒ Object



57
58
59
60
61
62
# File 'lib/viking/fileutilz.rb', line 57

def self.remove(list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |dir|
    remove_file(dir)
  end
end

.remove_dir(path) ⇒ Object



64
65
66
# File 'lib/viking/fileutilz.rb', line 64

def self.remove_dir(path)
  Viking::Dir.delete(path)
end

.remove_entry(path) ⇒ Object



68
69
70
# File 'lib/viking/fileutilz.rb', line 68

def self.remove_entry(path)
  rm_r(path)
end

.remove_file(path) ⇒ Object



72
73
74
# File 'lib/viking/fileutilz.rb', line 72

def self.remove_file(path)
  Viking::File.delete(path)
end

.rm(list) ⇒ Object



76
77
78
# File 'lib/viking/fileutilz.rb', line 76

def self.rm(list)
  remove(list)
end

.rm_r(list) ⇒ Object



80
81
82
83
84
85
# File 'lib/viking/fileutilz.rb', line 80

def self.rm_r(list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |path|
    Viking.client.delete(Path.new(path), true)
  end
end

.rmdir(list) ⇒ Object



87
88
89
90
91
92
# File 'lib/viking/fileutilz.rb', line 87

def self.rmdir(list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |dir|
    remove_dir(dir)
  end
end

.touch(list) ⇒ Object



94
95
96
97
98
99
# File 'lib/viking/fileutilz.rb', line 94

def self.touch(list)
  list = (list.is_a? Array) ? list : [list]
  list.each do |path|
    Viking.client.create_new_file(Path.new(path))
  end
end