Permalink
Browse files

Add DEVEL_COVER_IO_OPTIONS environment variable.

Set it to "pretty" to make readable JSON DB files.
  • Loading branch information...
1 parent a9d6071 commit 2f79f3e96e1ea6a7d88f7571f46f55b39f21bffe @pjcj committed Apr 23, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/Devel/Cover/DB/IO.pm
View
@@ -27,7 +27,8 @@ sub new
my $class = shift;
my $self =
{
- format => $Format,
+ format => $Format,
+ options => $ENV{DEVEL_COVER_IO_OPTIONS} || "",
@_
};
@@ -76,9 +77,11 @@ sub write
return $self;
}
+ my $json = JSON::PP->new->utf8;
+ $json->ascii->pretty->canonical if $self->{options} =~ /\bpretty\b/i;
open my $fh, ">", $file or die "Can't open $file: $!";
flock($fh, LOCK_EX) or die "Cannot lock mailbox - $!\n";
- print $fh "", JSON::PP::encode_json($data); # "", for 5.6.1
+ print $fh $json->encode($data);
close $fh or die "Can't close $file: $!";
$self
}

0 comments on commit 2f79f3e

Please sign in to comment.