Module: Bashy_File::Base

Includes:
Get_Set::DSL
Included in:
Bashy_File
Defined in:
lib/Bashy/Bashy_File.rb

Instance Method Summary collapse

Instance Method Details

#appendObject



13
14
15
# File 'lib/Bashy/Bashy_File.rb', line 13

def append
  run cmd(%@ echo #{content.inspect} >> #{sudo} tee #{path}@)
end

#cmd(cmd) ⇒ Object

cmd_chown_file



31
32
33
34
35
36
37
# File 'lib/Bashy/Bashy_File.rb', line 31

def cmd cmd
  [ 
    cmd,
    cmd_chmod_file, 
    cmd_chown_file 
  ].compact.join(" && ")
end

#cmd_chmod_fileObject



17
18
19
20
21
22
23
# File 'lib/Bashy/Bashy_File.rb', line 17

def cmd_chmod_file
  sudo = self.sudo || ''
  mod  = self.mode.to_s.strip

  return nil if mod.empty?
  "#{sudo} chmod #{mod} #{path}"
end

#cmd_chown_fileObject



25
26
27
28
29
# File 'lib/Bashy/Bashy_File.rb', line 25

def cmd_chown_file
  og = user_and_group
  return nil unless og
  "#{sudo} chown #{og} #{path}"
end

#createObject



9
10
11
# File 'lib/Bashy/Bashy_File.rb', line 9

def create
  run cmd(%@ echo #{content.inspect} > #{sudo} tee #{path} @)
end