Class: GitHub::Command::Shell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*command) ⇒ Shell

Returns a new instance of Shell.



59
60
61
# File 'lib/github/command.rb', line 59

def initialize(*command)
  @command = command
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



56
57
58
# File 'lib/github/command.rb', line 56

def error
  @error
end

#outObject (readonly)

Returns the value of attribute out.



57
58
59
# File 'lib/github/command.rb', line 57

def out
  @out
end

Instance Method Details

#commandObject



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

def command
  @command.join(' ')
end

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  !!@error
end

#out?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/github/command.rb', line 84

def out?
  !!@out
end

#runObject



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/github/command.rb', line 63

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

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

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

  self
end