File Coverage

blib/lib/PGP/Finger/GPG.pm
Criterion Covered Total %
statement 12 22 54.5
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 16 30 53.3


line stmt bran cond sub pod time code
1             package PGP::Finger::GPG;
2              
3 1     1   2364 use Moose;
  1         2  
  1         6  
4              
5             extends 'PGP::Finger::Source';
6              
7             # ABSTRACT: gpgfinger source to query local gnupg
8             our $VERSION = '1.1'; # VERSION
9              
10 1     1   4842 use PGP::Finger::Result;
  1         2  
  1         17  
11 1     1   4 use PGP::Finger::Key;
  1         1  
  1         16  
12              
13 1     1   903 use IPC::Run qw(run);
  1         25882  
  1         160  
14              
15             has 'cmd' => ( is => 'ro', isa => 'ArrayRef', lazy => 1,
16             default => sub { [ '/usr/bin/gpg', '--export' ] },
17             );
18              
19             sub fetch {
20 0     0 0   my ( $self, $addr ) = @_;
21 0           my @cmd = ( @{$self->cmd}, $addr );
  0            
22 0           my ( $in, $out, $err );
23 0 0         run( \@cmd, \$in, \$out, \$err )
24             or die('error running gpg: '.$err.' ('.$!.')');
25              
26 0           my $result = PGP::Finger::Result->new;
27 0           my $key = PGP::Finger::Key->new(
28             mail => $addr,
29             data => $out,
30             );
31 0           $key->set_attr( source => 'local GnuPG' );
32              
33 0           $result->add_key( $key );
34 0           return $result;
35             }
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             PGP::Finger::GPG - gpgfinger source to query local gnupg
48              
49             =head1 VERSION
50              
51             version 1.1
52              
53             =head1 AUTHOR
54              
55             Markus Benning <ich@markusbenning.de>
56              
57             =head1 COPYRIGHT AND LICENSE
58              
59             This software is Copyright (c) 2015 by Markus Benning.
60              
61             This is free software, licensed under:
62              
63             The GNU General Public License, Version 2 or later
64              
65             =cut