Lighthouse/Base.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 95.8% 46 / 48 CC 4 SCAR 7.9
CC
4
Cov
97%
ua
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Lighthouse/Project/Ticket/Attachment.pm ↑ Summary Lighthouse/Token.pm »
1 package Net::Lighthouse::Base;
2  
3 11 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 has 'account' => (
8 isa => 'Str',
9 is => 'ro',
10 );
11  
12 has 'auth' => (
13 isa => 'HashRef',
14 is => 'rw',
15 21 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 11 lazy => 1,
17 );
18  
19 11 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 11 __PACKAGE__->meta->make_immutable;
21  
22 33 ▶sub base_url {
Subroutine base_url: called CC=1 SCAR=0.0
Pod documented
23 33 my $self = shift;
24 33 return 'http://' . $self->account . '.lighthouseapp.com';
25 }
26  
27 39 ▶sub ua {
Subroutine ua: called CC=4 SCAR=13.9
Pod documented
28 39 my $self = shift;
29 39 require Net::Lighthouse;
30 39 my $ua =
31 LWP::UserAgent->new(
32 agent => 'net-lighthouse/' . $Net::Lighthouse::VERSION );
33 39 $ua->default_header( 'Content-Type' => 'application/xml' );
34 # email and password have higher priority
35 39 my $auth = $self->auth;
36 39 ▶ if ( $auth->{email} && $auth->{password} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($auth->{'email'} and $auth->{'password'}) { } 1 38 39
elsif ($auth->{'token'}) { } 1 37 38
Condition66%2/3
$auth->{"email"} and $auth->{"password"}
!ll&&!rl&&r
3801
MC/DC50%1/2
$auth->{"email"} and $auth->{"password"}
$auth->{"email"} $auth->{"password"}
Truth table66%2/3
A and B
A= $auth->{"email"}B= $auth->{"password"}
ABresult
0X0
100
111
37 1 my $base64 = encode_base64( $auth->{email} . ':' . $auth->{password} );
38 1 chomp $base64;
39 1 $ua->default_header( Authorization => 'Basic ' . $base64 );
40 }
41 elsif ( $auth->{token} ) {
42 1 $ua->default_header( 'X-LighthouseToken', $auth->{token} );
43 }
44  
45 39 return $ua;
46 }
47  
48 11 1;
49  
50 __END__
« Lighthouse/Project/Ticket/Attachment.pm ↑ Summary Lighthouse/Token.pm »