Class: ReDD::Dir

Inherits:
Dir
  • Object
show all
Includes:
Namaste::Mixin
Defined in:
lib/redd.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.mkdir(path, integer = 0777, args = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/redd.rb', line 10

def self.mkdir path, integer=0777, args = {}
  super path, integer
  d = Dir.new path
  d.type = Dnatural::VERSION

  ::Dir.chdir(d.path)  do
    ::Dir.mkdir 'add'
	FileUtils.touch 'delete.txt'
  end
  d
end

Instance Method Details

#add(src, dest, options = {}) ⇒ Object



26
27
28
29
30
# File 'lib/redd.rb', line 26

def add src, dest, options = {}
  FileUtils.mkdir_p File.dirname(File.join(path, 'add', dest))
  file = FileUtils.cp src, File.join(path, 'add', dest), options
  File.new File.join(path, 'add', dest)
end

#listObject



22
23
24
# File 'lib/redd.rb', line 22

def list
  NoMethodError
end

#remove(list, options = {}) ⇒ Object



32
33
34
35
36
37
# File 'lib/redd.rb', line 32

def remove list, options = {}
  list = [list] if list.instance_of? String
  File.open(File.join(path, 'delete.txt'), 'w') do |f|
    f.write list.join("\n")
  end
end