line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Lighthouse::Project::Ticket::Attachment; |
2
|
3
|
|
|
3
|
|
5112
|
use Any::Moose; |
|
3
|
|
|
|
|
38005
|
|
|
3
|
|
|
|
|
26
|
|
3
|
3
|
|
|
3
|
|
1668
|
use Params::Validate ':all'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
777
|
|
4
|
3
|
|
|
3
|
|
675
|
use Net::Lighthouse::Util; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
809
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# read only attr |
7
|
|
|
|
|
|
|
has [ 'created_at' ] => ( |
8
|
|
|
|
|
|
|
isa => 'DateTime', |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has [ 'width', 'height', 'size', 'uploader_id', 'id', ] => ( |
13
|
|
|
|
|
|
|
isa => 'Maybe[Int]', |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has [ 'content_type', 'filename', 'url', 'code' ] => ( |
18
|
|
|
|
|
|
|
isa => 'Str', |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# make tests happy, added Test::MockObject |
23
|
|
|
|
|
|
|
if ( $INC{'Moose.pm'} ) { |
24
|
|
|
|
|
|
|
require Moose::Util::TypeConstraints; |
25
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::class_type( 'LWP::UserAgent' ); |
26
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::class_type( 'Test::MockObject' ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
else { |
29
|
|
|
|
|
|
|
require Mouse::Util::TypeConstraints; |
30
|
|
|
|
|
|
|
Mouse::Util::TypeConstraints::class_type( 'LWP::UserAgent' ); |
31
|
|
|
|
|
|
|
Mouse::Util::TypeConstraints::class_type( 'Test::MockObject' ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'ua' => ( is => 'ro', isa => 'LWP::UserAgent|Test::MockObject', ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'content' => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
default => sub { |
40
|
|
|
|
|
|
|
my $self = shift; |
41
|
|
|
|
|
|
|
my $ua = $self->ua; |
42
|
|
|
|
|
|
|
my $res = $ua->get( $self->url ); |
43
|
|
|
|
|
|
|
if ( $res->is_success ) { |
44
|
|
|
|
|
|
|
return $res->content; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
3
|
|
18
|
no Any::Moose; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
19
|
|
53
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub load_from_xml { |
56
|
3
|
|
|
3
|
1
|
4869
|
my $self = shift; |
57
|
3
|
|
|
|
|
20
|
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
|
|
|
|
|
14
|
for my $k ( keys %$ref ) { |
62
|
33
|
|
|
|
|
78
|
$self->{$k} = $ref->{$k}; |
63
|
|
|
|
|
|
|
} |
64
|
3
|
|
|
|
|
21
|
return $self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |