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.



89
90
91
# File 'lib/github/command.rb', line 89

def initialize(*command)
  @command = command
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



86
87
88
# File 'lib/github/command.rb', line 86

def error
  @error
end

#outObject (readonly)

Returns the value of attribute out.



87
88
89
# File 'lib/github/command.rb', line 87

def out
  @out
end

Instance Method Details

#commandObject



108
109
110
# File 'lib/github/command.rb', line 108

def command
  @command.join(' ')
end

#error?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/github/command.rb', line 112

def error?
  !!@error
end

#out?Boolean

Returns:

  • (Boolean)


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

def out?
  !!@out
end

#runObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/github/command.rb', line 93

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 if !err.empty?
  replace @out = out if !out.empty?

  self
end