Lighthouse/Project/Ticket/Attachment.pm

filter: Statementstmt 75.6% 28 / 37 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 72.9% 35 / 48 CC 3 SCAR 9.2
CC
3
Cov
71%
__ANON__
6.0
load_from_xml
2.0
BEGIN
1.0
CRAP 2.5
« Lighthouse/Project.pm ↑ Summary Lighthouse/Base.pm »
1 package Net::Lighthouse::Project::Ticket::Attachment;
2 3 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Net::Lighthouse::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # read only attr
7 3 has [ 'created_at' ] => (
8 isa => 'DateTime',
9 is => 'ro',
10 );
11  
12 3 has [ 'width', 'height', 'size', 'uploader_id', 'id', ] => (
13 isa => 'Maybe[Int]',
14 is => 'ro',
15 );
16  
17 3 has [ 'content_type', 'filename', 'url', 'code' ] => (
18 isa => 'Str',
19 is => 'ro',
20 );
21  
22 # make tests happy, added Test::MockObject
23 3 ▶if ( $INC{'Moose.pm'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{'Moose.pm'}) { } 0 3 3
24 0 require Moose::Util::TypeConstraints;
25 0 Moose::Util::TypeConstraints::class_type( 'LWP::UserAgent' );
26 0 Moose::Util::TypeConstraints::class_type( 'Test::MockObject' );
27 }
28 else {
29 3 require Mouse::Util::TypeConstraints;
30 3 Mouse::Util::TypeConstraints::class_type( 'LWP::UserAgent' );
31 3 Mouse::Util::TypeConstraints::class_type( 'Test::MockObject' );
32 }
33  
34 3 has 'ua' => ( is => 'ro', isa => 'LWP::UserAgent|Test::MockObject', );
35  
36 has 'content' => (
37 is => 'ro',
38 lazy => 1,
39 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
40 0 my $self = shift;
41 0 my $ua = $self->ua;
42 0 my $res = $ua->get( $self->url );
43 0 ▶ if ( $res->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_success) { } 0 0 0
44 0 return $res->content;
45 }
46 else {
47 0 return;
48 }
49 }
50 3 );
51  
52 3 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 3 __PACKAGE__->meta->make_immutable;
54  
55 3 ▶sub load_from_xml {
Subroutine load_from_xml: called CC=2 SCAR=6.9
Pod documented
56 3 my $self = shift;
57 3 my $ref = Net::Lighthouse::Util->translate_from_xml(shift);
58  
59 # dirty hack: some attrs are read-only, and Mouse doesn't support
60 # writer => '...'
61 3 for my $k ( keys %$ref ) {
62 33 $self->{$k} = $ref->{$k};
63 }
64 3 return $self;
65 }
66  
67 3 1;
68  
69 __END__
« Lighthouse/Project.pm ↑ Summary Lighthouse/Base.pm »