Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tabs... :)

  • Loading branch information...
commit df8db3509b67240a94135bce2ef60c6da4570cde 1 parent 2b6eab8
@sergot authored
Showing with 53 additions and 53 deletions.
  1. +53 −53 lib/IO/Capture/Simple.pm
View
106 lib/IO/Capture/Simple.pm
@@ -5,101 +5,101 @@ my $stderr = $*ERR;
my $stdin = $*IN;
sub capture(Callable $code) is export {
- my ($out, $err, $in);
+ my ($out, $err, $in);
- capture_on($out, $err, $in);
- $code.();
- capture_off;
+ capture_on($out, $err, $in);
+ $code.();
+ capture_off;
- $out, $err, $in;
+ $out, $err, $in;
}
sub capture_on($out is rw, $err is rw, $in is rw) is export {
- capture_stdout_on($out);
- capture_stderr_on($err);
- capture_stdin_on($in);
+ capture_stdout_on($out);
+ capture_stderr_on($err);
+ capture_stdin_on($in);
}
sub capture_stdout(Callable $code) is export {
- my $result;
+ my $result;
- my $*OUT = class {
- method print(*@args) {
- $result ~= @args.join;
- }
- }
+ my $*OUT = class {
+ method print(*@args) {
+ $result ~= @args.join;
+ }
+ }
- $code.();
+ $code.();
- $result;
+ $result;
}
sub capture_stdout_on($target is rw) is export {
- $*OUT = class {
- method print(*@args) {
- $target ~= @args.join;
- }
- }
+ $*OUT = class {
+ method print(*@args) {
+ $target ~= @args.join;
+ }
+ }
}
sub capture_stderr(Callable $code) is export {
- my $result;
+ my $result;
- my $*ERR = class {
- method print(*@args) {
- $result ~= @args.join;
- }
- }
+ my $*ERR = class {
+ method print(*@args) {
+ $result ~= @args.join;
+ }
+ }
- $code.();
+ $code.();
- $result;
+ $result;
}
sub capture_stderr_on($target is rw) is export {
- $*ERR = class {
- method print(*@args) {
- $target ~= @args.join;
- }
- }
+ $*ERR = class {
+ method print(*@args) {
+ $target ~= @args.join;
+ }
+ }
}
sub capture_stdin(Callable $code) is export {
- my $result;
+ my $result;
- my $*IN = class {
- method get() {
- $result ~= $stdin.get;
- }
- }
+ my $*IN = class {
+ method get() {
+ $result ~= $stdin.get;
+ }
+ }
- $code.();
+ $code.();
- $result;
+ $result;
}
sub capture_stdin_on($target is rw) is export {
- $*IN = class {
- method get() {
- $target ~= $stdin.get;
- }
- }
+ $*IN = class {
+ method get() {
+ $target ~= $stdin.get;
+ }
+ }
}
sub capture_stdout_off is export {
- $*OUT = $stdout;
+ $*OUT = $stdout;
}
sub capture_stderr_off is export {
- $*ERR = $stderr;
+ $*ERR = $stderr;
}
sub capture_stdin_off is export {
- $*IN = $stdin;
+ $*IN = $stdin;
}
sub capture_off is export {
- $*OUT = $stdout;
- $*ERR = $stderr;
- $*IN = $stdin;
+ $*OUT = $stdout;
+ $*ERR = $stderr;
+ $*IN = $stdin;
}
Please sign in to comment.
Something went wrong with that request. Please try again.