Git-Background
view release on metacpan or search on metacpan
lib/Git/Background/Future.pm view on Meta::CPAN
return $self->fail( $message, 'git', @result );
}
# $run goes out of scope and the file handles and the proc object are freed
return $self->done(@result);
}
sub exit_code {
my ($self) = @_;
return ( $self->get )[2];
}
sub is_done {
my ($self) = @_;
$self->_await_if_git_is_done;
return $self->SUPER::is_done;
}
sub is_failed {
my ($self) = @_;
$self->_await_if_git_is_done;
return $self->SUPER::is_failed;
}
sub is_ready {
my ($self) = @_;
$self->_await_if_git_is_done;
return $self->SUPER::is_ready;
}
sub path_stderr {
my ($self) = @_;
return ( $self->get )[4];
}
sub path_stdout {
my ($self) = @_;
return ( $self->get )[3];
}
sub state { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
my ($self) = @_;
$self->_await_if_git_is_done;
return $self->SUPER::state;
}
sub stderr {
my ($self) = @_;
return @{ ( $self->get )[1] };
}
sub stdout {
my ($self) = @_;
return @{ ( $self->get )[0] };
}
sub _await_if_git_is_done {
my ($self) = @_;
my $run = $self->udata('_run');
if ( defined $run && !$run->{_proc}->alive ) {
$self->await;
}
return;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Git::Background::Future - use L<Future> with L<Git::Background>
=head1 VERSION
Version 0.008
=head1 SYNOPSIS
use Git::Background 0.008;
my $future = Git::Background->run(qw(status -s));
my @stdout = $future->stdout;
my ($stdout_ref, $stderr_ref, $exit_code, $stdout_path, $stderr_path) =
$future->get;
=head1 DESCRIPTION
This is a subclass of L<Future>. Please read the excellent documentation of
C<Future> to see what you can do with this module, this man page only
describes the changes to C<Future> specific to L<Git::Background>.
=head2 UTF-8
The default is to read the output from Git on its stdout and stderr as UTF-8.
The strings returned by the C<get>, C<stderr>, and C<stdout> methods can
therefore contain wide characters. When you write this data to a file handle,
you must ensure that the destination also uses a suitable encoding. This is
necessary to correctly handle any wide characters in the data. You can do this
by setting the encoding of the destination filehandle, e.g.:
binmode(STDOUT, ':encoding(UTF-8)');
=head1 USAGE
=head2 new( RUN )
New C<Git::Background::Future> objects should be constructed by using the
C<run> method of L<Git::Background>.
Current API available since 0.002.
=head2 await
( run in 1.523 second using v1.01-cache-2.11-cpan-39bf76dae61 )