package App::Critique;
use strict;
use warnings;
use File::HomeDir ();
use JSON::MaybeXS ();
our $VERSION = '0.05';
our $AUTHORITY = 'cpan:STEVAN';
# load our CONFIG first, ...
our %CONFIG;
BEG
QUE_DATA_DIR'} || '.critique';
$CONFIG{'DATA_FILE'} = $ENV{'CRITIQUE_DATA_FILE'} || 'session.json';
$CONFIG{'COLOR'} = $ENV{'CRITIQUE_COLOR'} // 1;
$CONFIG{'DEBUG'} = $ENV{'CR
NV{'ANSI_COLORS_DISABLED'} = ! $CONFIG{'COLOR'};
}
# ... then gloablly used stuff, ....
our $JSON = JSON::MaybeXS->new->utf8->pretty->canonical;
# ... then load the app and plugins
use App::Cmd::S
d line options, and will look
something like this:
~/.critique/<git-repo>/<git-branch>/session.json
The value of C<git-repo> will be surmised from the C<git-work-tree>
which itself defaults to fin
ath->is_file;
my $file = Path::Tiny::path( $path );
my $json = $file->slurp;
my $data = $App::Critique::JSON->decode( $json );
return $class->unpack( $data );
}
sub store {
my (
= $self->{_path};
my $data = $self->pack;
eval {
# JSON might die here ...
my $json = $App::Critique::JSON->encode( $data );
# if the file does not exist
# t
>parent->mkpath unless -e $file;
# now try and write out the JSON
my $fh = $file->openw;
$fh->print( $json );
$fh->close;
1;
} or do {
Carp::confe