Class: Lucie::Commands::CommandsHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/lucie-cmd/commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandsHelper



31
32
33
34
# File 'lib/lucie-cmd/commands.rb', line 31

def initialize
  @stderr = $stderr
  @pwd = Dir.pwd
end

Instance Attribute Details

#pwdObject

Returns the value of attribute pwd.



29
30
31
# File 'lib/lucie-cmd/commands.rb', line 29

def pwd
  @pwd
end

Instance Method Details

#outputObject



42
43
44
# File 'lib/lucie-cmd/commands.rb', line 42

def output
  @stdout.read
end

#sh(*args) ⇒ Object



36
37
38
39
40
# File 'lib/lucie-cmd/commands.rb', line 36

def sh(*args)
  command = args.join(" ")
  @pid, @stdin, @stdout, @stderr = Open4::popen4("cd \"#{pwd}\" && #{command}")
  @ignored, @status = Process::waitpid2 @pid
end

#statusObject



46
47
48
# File 'lib/lucie-cmd/commands.rb', line 46

def status
  @status.to_i % 255
end