Class: GitHub::Command::Shell

Inherits:
String
  • Object
show all
Defined in:
lib/github/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(*command) ⇒ Shell

Returns a new instance of Shell.



54
55
56
# File 'lib/github/command.rb', line 54

def initialize(*command)
  @command = command
end

Instance Method Details

#commandObject



72
73
74
# File 'lib/github/command.rb', line 72

def command
  @command.join(' ')
end

#error?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/github/command.rb', line 76

def error?
  !!@error
end

#out?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/github/command.rb', line 80

def out?
  !!@out
end

#runObject



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/github/command.rb', line 58

def run
  GitHub.debug "sh: #{command}"
  _, out, err = Open3.popen3(*@command)

  out = out.read.strip
  err = err.read.strip

  if out.any?
    replace @out = out
  elsif err.any?
    replace @error = err
  end
end