Class: Nautilus::Shell

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

Instance Method Summary collapse

Instance Method Details

#build_command(command, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nautilus/shell.rb', line 9

def build_command(command, options = {})
  actual_command = command.kind_of?(Array) ? command.join(" ") : command
  if options[:background]
    if windows?
      actual_command = "start /wait /b " + command
    elsif options[:background]
      actual_command << " &"
    end
  end      
  actual_command
end

#run(command, options = {}) ⇒ Object



5
6
7
# File 'lib/nautilus/shell.rb', line 5

def run(command, options = {})
  sh build_command(command, options)
end

#sh(command) ⇒ Object



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

def sh(command)
  successful = system(command)
  raise "Error while running >>#{command}<<" unless successful
end

#windows?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/nautilus/shell.rb', line 21

def windows?
  RUBY_PLATFORM =~ /mswin/
end