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.



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

def initialize(*command)
  @command = command
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



78
79
80
# File 'lib/github/command.rb', line 78

def error
  @error
end

#outObject (readonly)

Returns the value of attribute out.



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

def out
  @out
end

Instance Method Details

#commandObject



98
99
100
# File 'lib/github/command.rb', line 98

def command
  @command.join(' ')
end

#error?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/github/command.rb', line 102

def error?
  !!@error
end

#out?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/github/command.rb', line 106

def out?
  !!@out
end

#runObject



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/github/command.rb', line 85

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