Module: Divvy::Plugins::FileUtilities

Defined in:
lib/divvy/plugins/file_utilities.rb

Instance Method Summary collapse

Instance Method Details

#mkdir(path, mode = nil) ⇒ Object

Makes a directory path is the diretory to create. This will not create the directory if it already exists mode is the file mode of the directory. If nil, no mode changes will be made



8
9
10
11
# File 'lib/divvy/plugins/file_utilities.rb', line 8

def mkdir(path, mode = nil)
  run("[ -d #{path} ] || mkdir -p #{path}")
  run("chmod #{mode} #{dir}") unless mode.nil?
end

#push_text(path, text) ⇒ Object



13
14
15
16
17
# File 'lib/divvy/plugins/file_utilities.rb', line 13

def push_text(path, text)
  run("[ -f #{path} ] || touch #{path}")
  run("echo '#{text}' | tee -a #{path}")
  # "echo '#{text}' |#{'sudo' if option?(:sudo)} tee -a #{path}"
end