Module: RuboCop::Server::Helper Private

Defined in:
lib/rubocop/server/helper.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module has a helper method for ‘RuboCop::Server::SocketReader`.

Class Method Summary collapse

Class Method Details

.redirect(stdin: $stdin, stdout: $stdout, stderr: $stderr, &_block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubocop/server/helper.rb', line 17

def self.redirect(stdin: $stdin, stdout: $stdout, stderr: $stderr, &_block)
  old_stdin = $stdin.dup
  old_stdout = $stdout.dup
  old_stderr = $stderr.dup

  $stdin = stdin
  $stdout = stdout
  $stderr = stderr

  yield
ensure
  $stdin = old_stdin
  $stdout = old_stdout
  $stderr = old_stderr
end