Class: Datacenter::Shell::Local

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

Defined Under Namespace

Classes: SafeIO

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLocal

Returns a new instance of Local.



18
19
20
# File 'lib/datacenter/shell/local.rb', line 18

def initialize
  @mutex = Mutex.new
end

Class Method Details

.open(*args) {|shell| ... } ⇒ Object

Yields:

  • (shell)


38
39
40
41
# File 'lib/datacenter/shell/local.rb', line 38

def self.open(*args)
  shell = new *args
  yield shell
end

Instance Method Details

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/datacenter/shell/local.rb', line 22

def run(command, options={})
  Datacenter.logger.debug(self.class) { command }

  opts = {
    chdir: options[:chdir] || Dir.pwd,
    out: options[:out] || StringIO.new,
    err: options[:err] || StringIO.new
  }

  if RUBY_ENGINE == 'jruby'
    run_system command, opts
  else
    run_open3 command, opts
  end
end