Module: Nirvana::Util
Instance Method Summary collapse
- #capture_all ⇒ Object
- #capture_stderr ⇒ Object
- #capture_stdout ⇒ Object
- #format_output(response) ⇒ Object
Instance Method Details
#capture_all ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/nirvana/util.rb', line 26 def capture_all stdout, stderr, result = nil stderr = capture_stderr do stdout = capture_stdout do result = yield end end [stdout, stderr, result] end |
#capture_stderr ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/nirvana/util.rb', line 17 def capture_stderr out = StringIO.new $stderr = out yield return out.string ensure $stderr = STDERR end |
#capture_stdout ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/nirvana/util.rb', line 8 def capture_stdout out = StringIO.new $stdout = out yield return out.string ensure $stdout = STDOUT end |
#format_output(response) ⇒ Object
36 37 38 |
# File 'lib/nirvana/util.rb', line 36 def format_output(response) EscapeUtils.escape_html(response).gsub("\n", "<br>").gsub("\t", " ").gsub(" ", " ") end |