Class: CapistranoMulticonfigParallel::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano_multiconfig_parallel/initializers/helper.rb

Overview

class used to find application dependencies

Class Method Summary collapse

Class Method Details

.capture(stream) ⇒ Object

rubocop:disable Lint/Eval



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/capistrano_multiconfig_parallel/initializers/helper.rb', line 5

def self.capture(stream)
  stream = stream.to_s
  captured_stream = Tempfile.new(stream)
  stream_io = eval("$#{stream}")
  origin_stream = stream_io.dup
  stream_io.reopen(captured_stream)

  yield

  stream_io.rewind
  return captured_stream.read
ensure
  captured_stream.close
  captured_stream.unlink
  stream_io.reopen(origin_stream)
end