Module: Pulsar::Helpers::Shell

Includes:
FileUtils
Included in:
Clamp
Defined in:
lib/pulsar/helpers/shell.rb

Instance Method Summary collapse

Instance Method Details

#cd(path, opts, &block) ⇒ Object



8
9
10
11
# File 'lib/pulsar/helpers/shell.rb', line 8

def cd(path, opts, &block)
  puts "Directory: #{path.white}".yellow if opts[:verbose]
  FileUtils.cd(path) { yield }
end

#rm_rf(path, opts) ⇒ Object



13
14
15
16
# File 'lib/pulsar/helpers/shell.rb', line 13

def rm_rf(path, opts)
  puts "Remove: #{path.white}".yellow if opts[:verbose]
  FileUtils.rm_rf(path)
end

#run_cmd(cmd, opts) ⇒ Object



18
19
20
21
22
23
# File 'lib/pulsar/helpers/shell.rb', line 18

def run_cmd(cmd, opts)
  puts "Command: #{cmd.white}".yellow if opts[:verbose]
  system(cmd)

  raise "Command #{cmd} Failed" if $? != 0
end

#touch(file, opts) ⇒ Object



25
26
27
28
# File 'lib/pulsar/helpers/shell.rb', line 25

def touch(file, opts)
  puts "Touch: #{file.white}".yellow if opts[:verbose]
  FileUtils.touch(file)
end