OpenPGP/Constants.pm

filter: Statementstmt 100% 28 / 28 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 97.3% 36 / 37 CC 5 SCAR 11.7
CC
5
Cov
97%
import
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« OpenPGP/Armour.pm ↑ Summary OpenPGP/CFB.pm »
1 package Crypt::OpenPGP::Constants;
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 14 our $VERSION = '1.21'; # VERSION
6  
7 14 our %CONSTANTS = (
8 'PGP_PKT_PUBKEY_ENC' => 1,
9 'PGP_PKT_SIGNATURE' => 2,
10 'PGP_PKT_SYMKEY_ENC' => 3,
11 'PGP_PKT_ONEPASS_SIG' => 4,
12 'PGP_PKT_SECRET_KEY' => 5,
13 'PGP_PKT_PUBLIC_KEY' => 6,
14 'PGP_PKT_SECRET_SUBKEY' => 7,
15 'PGP_PKT_COMPRESSED' => 8,
16 'PGP_PKT_ENCRYPTED' => 9,
17 'PGP_PKT_MARKER' => 10,
18 'PGP_PKT_PLAINTEXT' => 11,
19 'PGP_PKT_RING_TRUST' => 12,
20 'PGP_PKT_USER_ID' => 13,
21 'PGP_PKT_PUBLIC_SUBKEY' => 14,
22 'PGP_PKT_USER_ATTRIBUTE' => 17,
23 'PGP_PKT_ENCRYPTED_MDC' => 18,
24 'PGP_PKT_MDC' => 19,
25  
26 'DEFAULT_CIPHER' => 2,
27 'DEFAULT_DIGEST' => 2,
28 'DEFAULT_COMPRESS' => 1,
29 );
30  
31 14 our %TAGS;
32 14 my %RULES = (
33 '^PGP_PKT' => 'packet',
34 );
35  
36 14 for my $re (keys %RULES) {
37 14 $TAGS{ $RULES{$re} } = [ grep /$re/, keys %CONSTANTS ];
38 }
39  
40 84 ▶sub import {
Subroutine import: called CC=5 SCAR=16.1
41 84 my $class = shift;
42  
43 84 my @to_export;
44 84 my @args = @_;
45 84 for my $item (@args) {
46 push @to_export,
47 171 ▶ $item =~ s/^:// ? @{ $TAGS{$item} } : $item;
Branch: 1 branch
BranchTrueFalseTotal
$item =~ s/^:// ? : 13 158 171
48 }
49  
50 14 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
51 84 my $pkg = caller;
52 84 for my $con (@to_export) {
53 warn __PACKAGE__, " does not export the constant '$con'"
54 379 ▶ unless exists $CONSTANTS{$con};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Crypt::OpenPGP::Constants::CONSTANTS{$con} 0 379 379
55 379 ▶ *{"${pkg}::$con"} = sub () { $CONSTANTS{$con} }
Subroutine __ANON__: called CC=1 SCAR=0.0
56 379 }
57 }
58  
59 14 1;
60 __END__
« OpenPGP/Armour.pm ↑ Summary OpenPGP/CFB.pm »