Skip to content

Commit

Permalink
Depend on true::VERSION to avoid YAML bugs in META.yml parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwern committed Feb 14, 2011
1 parent 6ac4425 commit 60bfd25
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ my $builder = MyBuild->new(
'Digest::MD5' => '2.36',
'Object::ID' => '0.1.0',
"Devel::Declare::MethodInstaller::Simple" => '0.006000',
'true' => '0.12',
'true::VERSION' => '0.16',
'Capture::Tiny' => '0.06',
},
build_requires => {
Expand Down
7 changes: 5 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
2.6.0
New Feature
New Features
* Added capture(), from Capture::Tiny, to capture output to STDOUT and
STDERR [github 178]

Windows Fixes
* Fix t/center.t (Myf White)
* Fix t/command_line_wrapper.t
* Fix t/command_line_wrapper.t (Myf White)

New Docs
* Added perl5ifaq entries for capturing output from a command using
capture()

Misc
* The dependency on true.pm will no longer confuse some YAML parsers.


2.5.1 Fri, 28 Jan 2011 11:01:33 +1000
Misc
Expand Down
5 changes: 3 additions & 2 deletions META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build_requires:
Test::Warn: 0.11
configure_requires:
Module::Build: 0.36
generated_by: 'Module::Build version 0.3623'
generated_by: 'Module::Build version 0.3624'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
Expand Down Expand Up @@ -134,6 +134,7 @@ provides:
version: v2.5.1
requires:
CLASS: 1.00
Capture::Tiny: 0.06
Child: 0.007
DateTime: 0.47
DateTime::Format::Epoch: 0.11
Expand Down Expand Up @@ -164,7 +165,7 @@ requires:
indirect: 0.22
parent: 0.221
perl: v5.10.0
'true': 0.12
true::VERSION: 0.16
version: 0.77
resources:
Chat: irc://irc.perl.org/#perl5i
Expand Down
38 changes: 38 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,44 @@ What it does
encoding turned on. Consequently, if you want to output raw bytes to a
file, such as outputting an image, you must set "binmode $fh".

capture()
my($stdout, $stderr) = capture { ... } %options;
my $stdout = capture { ... } %options;

"capture()" lets you capture all output to "STDOUT" and "STDERR" in any
block of code.

# $out = "Hello"
# $err = "Bye"
my($out, $err) = capture {
print "Hello";
print STDERR "Bye";
};

If called in scalar context, it will only return "STDOUT" and silence
"STDERR".

# $out = "Hello"
my $out = capture {
print "Hello";
warn "oh god";
};

"capture" takes some options.

tee tee will cause output to be captured yet still printed.

my $out = capture { print "Hi" } tee => 1;

merge
merge will merge "STDOUT" and "STDERR" into one variable.

# $out = "HiBye"
my $out = capture {
print "Hi";
print STDERR "Bye";
} merge => 1;

Carp
"croak" and "carp" from Carp are always available.

Expand Down

0 comments on commit 60bfd25

Please sign in to comment.