Class: IO::Execution
Instance Attribute Summary collapse
-
#error_callback ⇒ Object
Returns the value of attribute error_callback.
-
#output_callback ⇒ Object
Returns the value of attribute output_callback.
Instance Method Summary collapse
Instance Attribute Details
#error_callback ⇒ Object
Returns the value of attribute error_callback.
125 126 127 |
# File 'lib/git_topic/core_ext.rb', line 125 def error_callback @error_callback end |
#output_callback ⇒ Object
Returns the value of attribute output_callback.
125 126 127 |
# File 'lib/git_topic/core_ext.rb', line 125 def output_callback @output_callback end |
Instance Method Details
#on_error(&block) ⇒ Object
153 154 155 |
# File 'lib/git_topic/core_ext.rb', line 153 def on_error &block self.error_callback = block end |
#on_output(&block) ⇒ Object
157 158 159 |
# File 'lib/git_topic/core_ext.rb', line 157 def on_output &block self.output_callback = block end |
#run(*args, &block) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/git_topic/core_ext.rb', line 127 def run *args, &block self.output_callback = proc{ } self.error_callback = proc{ } # Let the block set up error, output hooks self.instance_eval &block Open3.popen3 *args do |pin, pout, perr, wait_thread| nothing_read = false until nothing_read do nothing_read = true if s = pout.gets self.output_callback[ s ] nothing_read = false end if s = perr.gets self.error_callback[ s ] nothing_read = false end end wait_thread.value end end |