Class: Minke::Helpers::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/minke/helpers/shell.rb

Instance Method Summary collapse

Instance Method Details

#execute(command) ⇒ Object

Executes a shell command and returns the return status



6
7
8
9
# File 'lib/minke/helpers/shell.rb', line 6

def execute command
  puts command
  system("#{command}")
end

#execute_and_return(command) ⇒ Object



11
12
13
14
# File 'lib/minke/helpers/shell.rb', line 11

def execute_and_return command
  log = `#{command}`
  return log.strip
end

#exist?(filename) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/minke/helpers/shell.rb', line 32

def exist? filename
  File.exist? filename
end

#mktmpdirObject



16
17
18
# File 'lib/minke/helpers/shell.rb', line 16

def mktmpdir
  Dir.mktmpdir
end

#read_file(filename) ⇒ Object



28
29
30
# File 'lib/minke/helpers/shell.rb', line 28

def read_file filename
  File.open(filename, 'rb') { |file| file.read }.strip
end

#remove_entry_secure(dir) ⇒ Object



20
21
22
# File 'lib/minke/helpers/shell.rb', line 20

def remove_entry_secure dir
  FileUtils.remove_entry_secure dir
end

#write_file(filename, data) ⇒ Object



24
25
26
# File 'lib/minke/helpers/shell.rb', line 24

def write_file filename, data
  File.open(filename, 'w') { |file| file.write(data) }
end