Class: PolarBear::Utils::Executor

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/polarbear/utils/executor.rb

Instance Method Summary collapse

Instance Method Details

#execute_command(command, input = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/polarbear/utils/executor.rb', line 19

def execute_command(command, input = nil)

  last_command_output = ''

  bearcommand = ["'#{@codecollab_execpath}'", @codecollab_globaloptions, command].join(' ')
  IO.popen(bearcommand, 'r+') { |pipe|

    if input != nil
      pipe.puts(input)
      pipe.close_write
    end

    last_command_output = pipe.read
  }

  raise "#{bearcommand} execution failure" unless ?$ != 0
  last_command_output
end

#set_codecollab_exec_path(ccollab_exe) ⇒ Object

Parameters:

  • ccollab_exe (string)


10
11
12
# File 'lib/polarbear/utils/executor.rb', line 10

def set_codecollab_exec_path(ccollab_exe)
  @codecollab_execpath = ccollab_exe
end

#set_global_option(options) ⇒ Object

Parameters:

  • options (Array)


15
16
17
# File 'lib/polarbear/utils/executor.rb', line 15

def set_global_option(options)
  @codecollab_globaloptions = options
end