| 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
Condition66%2/3
$auth->{"email"} and $auth->{"password"}
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"}
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||