Sha256: 955147b83fe61d2d90db6dd471f6a6ae87c687f2c7350c3e1f3e4450d2c231cf
Contents?: true
Size: 313 Bytes
Versions: 10
Compression:
Stored size: 313 Bytes
Contents
def preserving_env old_env = ENV.to_hash begin yield ensure ENV.clear ENV.update(old_env) end end def capture_stdout old_stdout = $stdout.dup rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY") $stdout = wr yield wr.close rd.read ensure $stdout = old_stdout end
Version data entries
10 entries across 10 versions & 1 rubygems