File Coverage

blib/lib/Wikibase/Datatype/Print/Mediainfo.pm
Criterion Covered Total %
statement 36 36 100.0
branch 11 20 55.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 56 66 84.8


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Print::Mediainfo;
2              
3 3     3   924255 use base qw(Exporter);
  3         34  
  3         290  
4 3     3   20 use strict;
  3         7  
  3         55  
5 3     3   14 use warnings;
  3         13  
  3         79  
6              
7 3     3   1366 use Error::Pure qw(err);
  3         23644  
  3         73  
8 3     3   116 use Readonly;
  3         6  
  3         106  
9 3     3   1533 use Wikibase::Datatype::Print::MediainfoStatement;
  3         11  
  3         181  
10 3         148 use Wikibase::Datatype::Print::Utils qw(print_descriptions print_labels
11 3     3   23 print_statements);
  3         7  
12 3     3   18 use Wikibase::Datatype::Print::Value::Monolingual;
  3         6  
  3         898  
13              
14             Readonly::Array our @EXPORT_OK => qw(print);
15              
16             our $VERSION = 0.09;
17              
18             sub print {
19 2     2 0 3716 my ($obj, $opts_hr) = @_;
20              
21 2 50       8 if (! defined $opts_hr) {
22 2         4 $opts_hr = {};
23             }
24              
25 2 50       7 if (! exists $opts_hr->{'lang'}) {
26 2         17 $opts_hr->{'lang'} = 'en';
27             }
28              
29 2 100       17 if (! $obj->isa('Wikibase::Datatype::Mediainfo')) {
30 1         5 err "Object isn't 'Wikibase::Datatype::Mediainfo'.";
31             }
32              
33 1 50       23 my @ret = (
    50          
    50          
    50          
    50          
    50          
34             defined $obj->id ? 'Id: '.$obj->id : (),
35             defined $obj->title ? 'Title: '.$obj->title : (),
36             defined $obj->ns ? 'NS: '.$obj->ns : (),
37             defined $obj->lastrevid ? 'Last revision id: '.$obj->lastrevid : (),
38             defined $obj->modified ? 'Date of modification: '.$obj->modified : (),
39             defined $obj->page_id ? 'Page ID: '.$obj->page_id : (),
40             );
41              
42             # Label.
43 1         94 push @ret, print_labels($obj, $opts_hr,
44             \&Wikibase::Datatype::Print::Value::Monolingual::print);
45              
46             # Description.
47 1         8 push @ret, print_descriptions($obj, $opts_hr,
48             \&Wikibase::Datatype::Print::Value::Monolingual::print);
49              
50             # Statements.
51 1         6 push @ret, print_statements($obj, $opts_hr,
52             \&Wikibase::Datatype::Print::MediainfoStatement::print);
53              
54 1 50       8 return wantarray ? @ret : (join "\n", @ret);
55             }
56              
57             1;
58              
59             __END__