File Coverage

blib/lib/Wikibase/Datatype/Print/Lexeme.pm
Criterion Covered Total %
statement 48 48 100.0
branch 7 12 58.3
condition n/a
subroutine 11 11 100.0
pod 0 1 0.0
total 66 72 91.6


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Print::Lexeme;
2              
3 3     3   951080 use base qw(Exporter);
  3         37  
  3         308  
4 3     3   19 use strict;
  3         20  
  3         56  
5 3     3   17 use warnings;
  3         6  
  3         85  
6              
7 3     3   1007 use Error::Pure qw(err);
  3         23898  
  3         70  
8 3     3   113 use Readonly;
  3         11  
  3         127  
9 3     3   1387 use Wikibase::Datatype::Print::Form;
  3         10  
  3         131  
10 3     3   1287 use Wikibase::Datatype::Print::Sense;
  3         8  
  3         125  
11 3     3   30 use Wikibase::Datatype::Print::Statement;
  3         10  
  3         96  
12 3     3   16 use Wikibase::Datatype::Print::Utils qw(print_forms print_senses print_statements);
  3         7  
  3         119  
13 3     3   17 use Wikibase::Datatype::Print::Value::Monolingual;
  3         6  
  3         869  
14              
15             Readonly::Array our @EXPORT_OK => qw(print);
16              
17             our $VERSION = 0.09;
18              
19             sub print {
20 2     2 0 15628 my ($obj, $opts_hr) = @_;
21              
22 2 50       8 if (! defined $opts_hr) {
23 2         4 $opts_hr = {};
24             }
25              
26 2 100       15 if (! $obj->isa('Wikibase::Datatype::Lexeme')) {
27 1         5 err "Object isn't 'Wikibase::Datatype::Lexeme'.";
28             }
29              
30 1         9 my @ret = (
31             'Title: '.$obj->title,
32             );
33              
34             # Lemmas.
35 1         11 my ($lemma) = @{$obj->lemmas};
  1         4  
36 1 50       13 if (defined $lemma) {
37 1         5 push @ret, 'Lemmas: '.
38             Wikibase::Datatype::Print::Value::Monolingual::print($lemma, $opts_hr);
39             }
40              
41             # Language.
42 1 50       18 if ($obj->language) {
43 1         11 push @ret, (
44             'Language: '.$obj->language,
45             );
46             }
47              
48             # Lexical category.
49 1 50       10 if ($obj->lexical_category) {
50 1         11 push @ret, (
51             'Lexical category: '.$obj->lexical_category,
52             );
53             }
54              
55             # Statements.
56 1         11 push @ret, print_statements($obj, $opts_hr,
57             \&Wikibase::Datatype::Print::Statement::print);
58              
59             # Senses.
60 1         6 push @ret, print_senses($obj, $opts_hr,
61             \&Wikibase::Datatype::Print::Sense::print);
62              
63             # Forms.
64 1         16 push @ret, print_forms($obj, $opts_hr,
65             \&Wikibase::Datatype::Print::Form::print);
66              
67 1 50       26 return wantarray ? @ret : (join "\n", @ret);
68             }
69              
70             1;
71              
72             __END__