Net/Amazon/S3/ACL/Set.pm

filter: Statementstmt 92.9% 66 / 71 Branchbran 66.6% 12 / 18 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 88.2% 15 / 17 Podpod 83.3% 5 / 6 totaltotal 87.8% 101 / 115 CC 11 SCAR 15.5
CC
11
Cov
88%
_grant
10.6
build_headers
2.0
grant_read_acp
2.0
CRAP 4.7
« Net/Amazon/S3/Authorization/IAM.pm ↑ Summary Net/Amazon/S3/Signature.pm »
1 package Net::Amazon::S3::ACL::Set;
2 # ABSTRACT: Representation of explicit ACL
3 100 $Net::Amazon::S3::ACL::Set::VERSION = '0.992';
4 100 ▶use Moose 0.85;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 100 ▶use MooseX::StrictConstructor 0.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 100 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 100 ▶use Ref::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 100 ▶use Safe::Isa ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 100 ▶use Net::Amazon::S3::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 100 ▶use Net::Amazon::S3::ACL::Grantee::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 100 ▶use Net::Amazon::S3::ACL::Grantee::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 100 ▶use Net::Amazon::S3::ACL::Grantee::Email;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 100 class_type 'Net::Amazon::S3::ACL::Set';
17  
18 100 my %permission_map = (
19 full_control => Net::Amazon::S3::Constants::HEADER_GRANT_FULL_CONTROL,
20 read => Net::Amazon::S3::Constants::HEADER_GRANT_READ,
21 read_acp => Net::Amazon::S3::Constants::HEADER_GRANT_READ_ACP,
22 write => Net::Amazon::S3::Constants::HEADER_GRANT_WRITE,
23 write_acp => Net::Amazon::S3::Constants::HEADER_GRANT_WRITE_ACP,
24 );
25  
26 100 my %grantees_map = (
27 id => 'Net::Amazon::S3::ACL::Grantee::User',
28 user => 'Net::Amazon::S3::ACL::Grantee::User',
29 uri => 'Net::Amazon::S3::ACL::Grantee::Group',
30 group => 'Net::Amazon::S3::ACL::Grantee::Group',
31 email => 'Net::Amazon::S3::ACL::Grantee::Email',
32 );
33  
34 has _grantees => (
35 is => 'ro',
36 15 ▶ default => sub { +{} },
Subroutine __ANON__: called CC=1 SCAR=0.0
37 100 );
38  
39 30 ▶sub build_headers {
Subroutine build_headers: called CC=2 SCAR=6.9
Pod undocumented
40 30 my ($self) = @_;
41  
42 30 my %headers;
43 30 ▶ while (my ($header, $grantees) = each %{ $self->_grantees }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->_grantees;}) 61 30 91
44 61 $headers{$header} = join ', ', map $_->format_for_header, @$grantees;
45 }
46  
47 30 %headers;
48 }
49  
50 1 ▶sub grant_full_control {
Subroutine grant_full_control: called CC=1 SCAR=0.0
Pod documented
51 1 my ($self, @grantees) = @_;
52  
53 1 $self->_grant (full_control => @grantees);
54 }
55  
56 15 ▶sub grant_read {
Subroutine grant_read: called CC=1 SCAR=0.0
Pod documented
57 15 my ($self, @grantees) = @_;
58  
59 15 $self->_grant (read => @grantees);
60 }
61  
62 0 ▶sub grant_read_acp {
Subroutine grant_read_acp: not called CC=1 SCAR=6.9
Pod documented
63 0 my ($self, @grantees) = @_;
64  
65 0 $self->_grant (read_acp => @grantees);
66 }
67  
68 16 ▶sub grant_write {
Subroutine grant_write: called CC=1 SCAR=0.0
Pod documented
69 16 my ($self, @grantees) = @_;
70  
71 16 $self->_grant (write => @grantees);
72 }
73  
74 0 ▶sub grant_write_acp {
Subroutine grant_write_acp: not called CC=1 SCAR=6.9
Pod documented
75 0 my ($self, @grantees) = @_;
76  
77 0 $self->_grant (write_acp => @grantees);
78 }
79  
80 32 ▶sub _grant {
Subroutine _grant: called CC=10 SCAR=23.6
81 32 my ($self, $permission, @grantees) = @_;
82 32 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 32 32
83  
84 32 my $key = lc $permission;
85 32 $key =~ tr/-/_/;
86  
87 die "Unknown permission $permission"
88 32 ▶ unless exists $permission_map{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $permission_map{$key} 0 32 32
89  
90 32 ▶ return unless @grantees;
Branch: 1 branch
BranchTrueFalseTotal
unless @grantees 0 32 32
91  
92 32 ▶ my $list = $self->_grantees->{$permission_map{$key}} ||= [];
Condition100%2/2
$self->_grantees->{$permission_map{$key}} ||= []
l!l
131
MC/DC100%1/1
$self->_grantees->{$permission_map{$key}} ||= []
$self->_grantees->{$permission_map{$key}}
Truth table100%2/2
A
A= $self->_grantees->{$permission_map{$key}}
Aresult
11
00
93 32 ▶ while (@grantees) {
Branch: 1 branch
BranchTrueFalseTotal
if (@grantees) 49 32 81
94 49 my $type = shift @grantees;
95  
96 49 ▶ if ($type->$Safe::Isa::_isa ('Net::Amazon::S3::ACL::Grantee')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->$Safe::Isa::_isa("Net::Amazon::S3::ACL::Grantee")) 2 47 49
97 2 push @{ $list }, $type;
98 2 next;
99 }
100  
101 die "Unknown grantee type $type"
102 47 ▶ unless exists $grantees_map{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $grantees_map{$type} 0 47 47
103  
104 47 ▶ die "Grantee type $type requires one argument"
Branch: 1 branch
BranchTrueFalseTotal
unless @grantees 0 47 47
105 unless @grantees;
106  
107 47 my @grantee = (shift @grantees);
108 0 ▶ @grantees = @{ $grantee[0] }
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_arrayref($grantee[0]) 0 47 47
109 if Ref::Util::is_plain_arrayref ($grantee[0]);
110  
111 47 push @{ $list }, map $grantees_map{$type}->new ($_), @grantee;
112 }
113  
114 32 return $self;
115 }
116  
117 100 1;
118  
119 __END__
« Net/Amazon/S3/Authorization/IAM.pm ↑ Summary Net/Amazon/S3/Signature.pm »