S3/Request/CreateBucket.pm

filter: Statementstmt 100% 19 / 19 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 87.8% 29 / 33 CC 4 SCAR 7.8
CC
4
Cov
92%
request
3.0
__ANON__
2.1
BEGIN
1.0
CRAP 2.2
« S3/File.pm ↑ Summary S3/HTTPRequest.pm »
1  
2 package AWS::S3::Request::CreateBucket;
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use AWS::S3::Signer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 with 'AWS::S3::Roles::Request';
8  
9 1 has 'bucket' => (
10 is => 'ro',
11 isa => 'Str',
12 required => 1,
13 );
14  
15 has 'location' => (
16 is => 'ro',
17 isa => 'Maybe[Str]',
18 lazy => 1,
19 required => 0,
20 1 ▶ default => sub { shift->s3->region || $ENV{AWS_REGION} },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
(shift())->s3->region or $ENV{"AWS_REGION"} 0 1 1
21 1 );
22  
23 1 has '+_expect_nothing' => ( default => 1 );
24  
25 3 ▶sub request {
Subroutine request: called CC=3 SCAR=11.0
Pod undocumented
26 3 my $s = shift;
27  
28 # By default the bucket is put in us-east-1. But if you _ask_ for
29 # us-east-1 you get an error.
30 3 my $xml = q{};
31 3 ▶ if ( $s->location && $s->location ne 'us-east-1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->location and $s->location ne "us-east-1") 2 1 3
Condition66%2/3
$s->location and $s->location ne "us-east-1"
!ll&&!rl&&r
102
MC/DC50%1/2
$s->location and $s->location ne "us-east-1"
$s->location $s->location ne "us-east-1"
Truth table66%2/3
A and B
A= $s->locationB= $s->location ne "us-east-1"
ABresult
0X0
100
111
32 2 $xml = <<"XML";
33 <CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
34 2 <LocationConstraint>@{[ $s->location ]}</LocationConstraint>
35 </CreateBucketConfiguration>
36 XML
37 }
38  
39 3 my $signer = AWS::S3::Signer->new(
40 s3 => $s->s3,
41 method => 'PUT',
42 uri => $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/',
43 content_type => 'text/plain',
44 content_md5 => '',
45 content => \$xml,
46 );
47  
48 3 return $s->_send_request(
49 $signer->method => $signer->uri => {
50 Authorization => $signer->auth_header,
51 Date => $signer->date,
52 'content-type' => 'text/plain',
53 },
54 $xml
55 );
56 }
57  
58 1 __PACKAGE__->meta->make_immutable;
« S3/File.pm ↑ Summary S3/HTTPRequest.pm »