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.



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

def initialize(*command)
  @command = command
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#outObject (readonly)

Returns the value of attribute out.



117
118
119
# File 'lib/github/command.rb', line 117

def out
  @out
end

Instance Method Details

#commandObject



138
139
140
# File 'lib/github/command.rb', line 138

def command
  @command.join(' ')
end

#error?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/github/command.rb', line 142

def error?
  !!@error
end

#out?Boolean

Returns:

  • (Boolean)


146
147
148
# File 'lib/github/command.rb', line 146

def out?
  !!@out
end

#runObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/github/command.rb', line 123

def run
  GitHub.debug "sh: #{command}"

  out = err = nil
  Open3.popen3(*@command) do |_, pout, perr|
    out = pout.read.strip
    err = perr.read.strip
  end

  replace @error = err unless err.empty?
  replace @out = out unless out.empty?

  self
end