Finger/File.pm

filter: Statementstmt 47.7% 21 / 44 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 1 totaltotal 41.9% 26 / 62 CC 6 SCAR 23.1
CC
6
Cov
39%
_build__data
20.0
fetch
12.0
BEGIN
1.0
CRAP 10.1
« Finger/App.pm ↑ Summary Finger/Keyserver.pm »
1 package PGP::Finger::File;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 extends 'PGP::Finger::Source';
6  
7 # ABSTRACT: gpgfinger source for local file input
8 1 our $VERSION = '1.1'; # VERSION
9  
10 1 ▶use PGP::Finger::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use PGP::Finger::Key;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 has 'input' => ( is => 'ro', isa => 'Str', required => 1 );
17  
18 1 has 'format' => ( is => 'ro', isa => 'Str', default => 'armored' );
19  
20 1 has '_data' => ( is => 'ro', lazy_build => 1 );
21  
22 0 ▶sub _build__data {
Subroutine _build__data: not called CC=4 SCAR=30.0
23 0 my $self = shift;
24 0 my $fh;
25 my $buf;
26 0 my $data = '';
27  
28 0 ▶ if( $self->input eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->input eq '-') { } 0 0 0
29 0 $fh = IO::Handle->new_from_fd(fileno(STDIN),'r');
30 } else {
31 0 $fh = IO::File->new($self->input,'r');
32 }
33 0 ▶ if( ! defined $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
34 0 die('unable to open '.$self->input.': '.$!);
35 }
36  
37 0 ▶ while( $fh->read( $buf, 1024 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->read($buf, 1024)) 0 0 0
38 0 $data .= $buf;
39 }
40  
41 0 $fh->close;
42  
43 0 return $data;
44 }
45  
46 0 ▶sub fetch {
Subroutine fetch: not called CC=3 SCAR=24.8
Pod undocumented
47 0 my ( $self, $addr ) = @_;
48 0 my $result = PGP::Finger::Result->new;
49 0 my $key;
50  
51 0 ▶ if( $self->format eq 'armored' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->format eq 'armored') { } 0 0 0
elsif ($self->format eq 'binary') { } 0 0 0
52 0 $key = PGP::Finger::Key->new_armored(
53 mail => $addr,
54 data => $self->_data,
55 );
56 } elsif ( $self->format eq 'binary' ) {
57 0 $key = PGP::Finger::Key->new(
58 mail => $addr,
59 data => $self->_data,
60 );
61 } else {
62 0 die('unknown input format: '.$self->format);
63 }
64 0 $key->set_attr( source => 'local file input' );
65 0 $key->set_attr( input => $self->input );
66  
67 0 $result->add_key( $key );
68 0 return $result;
69 }
70  
71 1 1;
72  
73 __END__
« Finger/App.pm ↑ Summary Finger/Keyserver.pm »