line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Lighthouse::Base; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
9153
|
use Any::Moose; |
|
11
|
|
|
|
|
37119
|
|
|
11
|
|
|
|
|
149
|
|
4
|
11
|
|
|
11
|
|
25137
|
use MIME::Base64; |
|
11
|
|
|
|
|
6699
|
|
|
11
|
|
|
|
|
809
|
|
5
|
11
|
|
|
11
|
|
1206
|
use LWP::UserAgent; |
|
11
|
|
|
|
|
49672
|
|
|
11
|
|
|
|
|
884
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'account' => ( |
8
|
|
|
|
|
|
|
isa => 'Str', |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'auth' => ( |
13
|
|
|
|
|
|
|
isa => 'HashRef', |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
default => sub { {} }, |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
11
|
|
|
11
|
|
68
|
no Any::Moose; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
87
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub base_url { |
23
|
33
|
|
|
33
|
1
|
2711
|
my $self = shift; |
24
|
33
|
|
|
|
|
376
|
return 'http://' . $self->account . '.lighthouseapp.com'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub ua { |
28
|
39
|
|
|
39
|
1
|
1110
|
my $self = shift; |
29
|
39
|
|
|
|
|
7855
|
require Net::Lighthouse; |
30
|
39
|
|
|
|
|
360
|
my $ua = |
31
|
|
|
|
|
|
|
LWP::UserAgent->new( |
32
|
|
|
|
|
|
|
agent => 'net-lighthouse/' . $Net::Lighthouse::VERSION ); |
33
|
39
|
|
|
|
|
4064
|
$ua->default_header( 'Content-Type' => 'application/xml' ); |
34
|
|
|
|
|
|
|
# email and password have higher priority |
35
|
39
|
|
|
|
|
3382
|
my $auth = $self->auth; |
36
|
39
|
100
|
66
|
|
|
305
|
if ( $auth->{email} && $auth->{password} ) { |
|
|
100
|
|
|
|
|
|
37
|
1
|
|
|
|
|
7
|
my $base64 = encode_base64( $auth->{email} . ':' . $auth->{password} ); |
38
|
1
|
|
|
|
|
4
|
chomp $base64; |
39
|
1
|
|
|
|
|
4
|
$ua->default_header( Authorization => 'Basic ' . $base64 ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ( $auth->{token} ) { |
42
|
1
|
|
|
|
|
4
|
$ua->default_header( 'X-LighthouseToken', $auth->{token} ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
39
|
|
|
|
|
224
|
return $ua; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |