File Coverage

blib/lib/Net/PMP/Profile/MediaEnclosure.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 17 17 100.0


line stmt bran cond sub pod time code
1             package Net::PMP::Profile::MediaEnclosure;
2 1     1   5 use Moose;
  1         2  
  1         5  
3 1     1   3811 use Net::PMP::Profile::TypeConstraints;
  1         2  
  1         174  
4              
5             our $VERSION = '0.102';
6              
7             has 'href' => ( is => 'rw', isa => 'Net::PMP::Type::Href', required => 1, );
8             has 'type' =>
9             ( is => 'rw', isa => 'Net::PMP::Type::MediaType', required => 1, );
10             has 'media_meta' => ( is => 'rw', isa => 'HashRef', );
11             has 'crop' => ( is => 'rw', isa => 'Str', );
12             has 'width' => ( is => 'rw', isa => 'Int', );
13             has 'height' => ( is => 'rw', isa => 'Int', );
14             has 'resolution' => ( is => 'rw', isa => 'Float', );
15             has 'codec' => ( is => 'rw', isa => 'Str', );
16             has 'format' => ( is => 'rw', isa => 'Str', );
17             has 'duration' => ( is => 'rw', isa => 'Int', );
18              
19             sub as_hash {
20 2     2 1 4 my $self = shift;
21              
22             # alias media_meta back to meta
23 2         8 my %hash = %$self;
24 2 100       8 if ( exists $hash{media_meta} ) {
25 1         4 $hash{meta} = delete $hash{media_meta};
26             }
27 2         9 return \%hash;
28             }
29              
30             __PACKAGE__->meta->make_immutable();
31              
32             1;
33              
34             __END__
35              
36             =head1 NAME
37              
38             Net::PMP::Profile::MediaEnclosure - Rich Media representation for PMP CollectionDoc
39              
40             =head1 SYNOPSIS
41              
42             use Net::PMP::Profile::MediaEnclosure;
43            
44             my $image = Net::PMP::Profile::MediaEnclosure->new(
45             href => 'http://mpr.org/some/asset/some/where.png',
46             type => 'images/png'
47             crop => 'medium',
48             width => 100,
49             height => 150',
50             resolutionn => 102, # PPI
51             media_meta => { foo => 'bar' },
52             );
53              
54             my $audio = Net::PMP::Profile::MediaEnclosure->new(
55             href => 'http://mpr.org/some/audio/some/where.mp3',
56             type => 'audio/mpeg',
57             codec => 'LAME3.99r',
58             format => 'MP3',
59             duration => 60000, # milliseconds
60             media_meta => { foo => 'bar' },
61             );
62              
63             my $video = Net::PMP::Profile::MediaEnclosure->new(
64             href => 'http://mpr.org/some/video/some/where',
65             type => 'video/mpeg',
66             codec => 'Xvid',
67             format => 'MPEG=1',
68             duration => 60000, # milliseconds
69             media_meta => { foo => 'bar' },
70             );
71            
72             =cut
73              
74             =head1 DESCRIPTION
75              
76             Net::PMP::Profile::MediaEnclosure implements the CollectionDoc fields for the PMP Rich Media Profile
77             L<https://github.com/publicmediaplatform/pmpdocs/wiki/Rich-Media-Profiles>.
78              
79             =head1 METHODS
80              
81             =head2 href
82              
83             URI string.
84              
85             =head2 type
86              
87             Content type string.
88              
89             =head2 media_meta
90              
91             Hashref of arbitrary metadata. Note that the PMP schema calls this B<meta> but that word
92             is a reserved method name in L<Moose>.
93              
94             =head2 crop
95              
96             Image semantic identifier string.
97              
98             =head2 width
99              
100             Image width integer.
101              
102             =head2 height
103              
104             Image height integer.
105              
106             =head2 resolution
107              
108             Image pixels-per-inch float.
109              
110             =head2 codec
111              
112             Audio/video codec string.
113              
114             =head2 format
115              
116             Audio/video format string.
117              
118             =head2 duration
119              
120             Audio/video duration integer (milliseconds). E.g. 60000 == 60 seconds.
121              
122             =head2 as_hash
123              
124             Returns the object as a hashref ready to pass to L<Net::PMP::CollectionDoc>.
125              
126             =head1 AUTHOR
127              
128             Peter Karman, C<< <karman at cpan.org> >>
129              
130             =head1 BUGS
131              
132             Please report any bugs or feature requests to C<bug-net-pmp at rt.cpan.org>, or through
133             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-PMP>. I will be notified, and then you'll
134             automatically be notified of progress on your bug as I make changes.
135              
136              
137             =head1 SUPPORT
138              
139             You can find documentation for this module with the perldoc command.
140              
141             perldoc Net::PMP
142              
143              
144             You can also look for information at:
145              
146             =over 4
147              
148             =item IRC
149              
150             Join #pmp on L<http://freenode.net>.
151              
152             =item RT: CPAN's request tracker (report bugs here)
153              
154             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-PMP>
155              
156             =item AnnoCPAN: Annotated CPAN documentation
157              
158             L<http://annocpan.org/dist/Net-PMP>
159              
160             =item CPAN Ratings
161              
162             L<http://cpanratings.perl.org/d/Net-PMP>
163              
164             =item Search CPAN
165              
166             L<http://search.cpan.org/dist/Net-PMP/>
167              
168             =back
169              
170              
171             =head1 ACKNOWLEDGEMENTS
172              
173             American Public Media and the Public Media Platform sponsored the development of this module.
174              
175             =head1 LICENSE AND COPYRIGHT
176              
177             Copyright 2013 American Public Media Group
178              
179             See the LICENSE file that accompanies this module.
180              
181             =cut