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.



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

def initialize(*command)
  @command = command
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



95
96
97
# File 'lib/github/command.rb', line 95

def error
  @error
end

#outObject (readonly)

Returns the value of attribute out.



96
97
98
# File 'lib/github/command.rb', line 96

def out
  @out
end

Instance Method Details

#commandObject



115
116
117
# File 'lib/github/command.rb', line 115

def command
  @command.join(' ')
end

#error?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/github/command.rb', line 119

def error?
  !!@error
end

#out?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/github/command.rb', line 123

def out?
  !!@out
end

#runObject



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/github/command.rb', line 102

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