Module: Bashy_File::Base
Instance Method Summary collapse
- #append ⇒ Object
-
#cmd(cmd) ⇒ Object
cmd_chown_file.
- #cmd_chmod_file ⇒ Object
- #cmd_chown_file ⇒ Object
- #create ⇒ Object
Instance Method Details
#append ⇒ Object
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_file ⇒ Object
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_file ⇒ Object
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 |
#create ⇒ Object
9 10 11 |
# File 'lib/Bashy/Bashy_File.rb', line 9 def create run cmd(%@ echo #{content.inspect} > #{sudo} tee #{path} @) end |