blib/lib/TBX/Min/TermGroup.pm

filter: Statementstmt 42.2% 19 / 45 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 1 totaltotal 35.2% 24 / 68 CC 7 SCAR 17.2
CC
7
Cov
33%
BUILD
12.0
part_of_speech
6.0
status
6.0
CRAP 5.6
« blib/lib/TBX/Min/Entry.pm ↑ Summary Build »
1 #
2 # This file is part of TBX-Min
3 #
4 # This software is copyright (c) 2013 by Alan Melby.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package TBX::Min::TermGroup;
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use subs qw(part_of_speech status);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 use Class::Tiny qw(
14 term
15 part_of_speech
16 note
17 customer
18 status
19 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 our $VERSION = '0.06'; # VERSION
23  
24 # ABSTRACT: Store information from one TBX-Min C<termGroup> element
25  
26  
27 sub part_of_speech {
28 0 ▶ my ($self, $pos) = @_;
Subroutine part_of_speech: not called CC=2 SCAR=17.9
29 0 ▶ if(defined $pos){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pos) 0 0 0
30 0 _validate_pos($pos);
31 0 $self->{part_of_speech} = $pos;
32 }
33 0 return $self->{part_of_speech};
34 }
35  
36  
37 sub status {
38 0 ▶ my ($self, $status) = @_;
Subroutine status: not called CC=2 SCAR=17.9
39 0 ▶ if(defined $status){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $status) 0 0 0
40 0 _validate_status($status);
41 0 $self->{status} = $status;
42 }
43 0 return $self->{status};
44 }
45  
46 # above Pod::Coverage makes this not "naked" via Pod::Coverage::TrustPod
47 sub BUILD {
48 0 ▶ my ($self, $args) = @_;
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod undocumented
49 0 ▶ if($args->{part_of_speech}){
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"part_of_speech"}) 0 0 0
50 0 _validate_pos($args->{part_of_speech});
51 }
52 0 ▶ if($args->{status}){
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"status"}) 0 0 0
53 0 _validate_status($args->{status});
54 }
55 0 return;
56 }
57  
58 1 my @allowed_pos = qw(noun properNoun verb adjective adverb other);
59 sub _validate_pos {
60 0 ▶ my ($pos) = @_;
Subroutine _validate_pos: not called CC=2 SCAR=17.9
61 0 ▶ if(!grep{$pos eq $_} @allowed_pos){
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$pos eq $_;} @allowed_pos) 0 0 0
62 0 croak "Illegal part of speech '$pos'";
63 }
64 0 return;
65 }
66  
67 1 my @allowed_status = qw(admitted preferred notRecommended obsolete);
68 sub _validate_status {
69 0 ▶ my ($pos) = @_;
Subroutine _validate_status: not called CC=2 SCAR=17.9
70 0 ▶ if(!grep{$pos eq $_} @allowed_status){
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$pos eq $_;} @allowed_status) 0 0 0
71 0 croak "Illegal status '$pos'";
72 }
73 0 return;
74 }
75  
76 1 1;
77  
78 __END__
79  
80 =pod
81  
82 =head1 NAME
83  
84 TBX::Min::TermGroup - Store information from one TBX-Min C<termGroup> element
85  
86 =head1 VERSION
87  
88 version 0.06
89  
90 =head1 SYNOPSIS
91  
92 use TBX::Min::TermGroup;
93 my $term_grp = TBX::Min::TermGroup->new(
94 {term => 'bat signal', status => "preferred"});
95 $term_grp->part_of_speech('noun');
96 $term_grp->customer('GCPD');
97 print $term_grp->term; # 'bat signal'
98  
99 =head1 DESCRIPTION
100  
101 This class represents a single term group contained in a TBX-Min file. A term
102 group contains a single term and information pertaining to it, such as part of
103 speech, a note, or the associated customer.
104  
105 =head1 METHODS
106  
107 =head2 C<new>
108  
109 Creates a new C<TBX::Min::TermGroup> instance. Optionally you may pass in a hash
110 reference which is used to initialized the object. The fields of the hash
111 correspond to the names of the accessor methods listed below.
112  
113 =head2 C<term>
114  
115 Get or set the term text associated with this term group.
116  
117 =head2 C<part_of_speech>
118  
119 Get or set the part of speech associated with this term group.
120  
121 =head2 C<note>
122  
123 Get or set a note associated with this term group.
124  
125 =head2 C<customer>
126  
127 Get or set a customer associated with this term group.
128  
129 =head2 C<status>
130  
131 Get or set a status associated with this term group.
132  
133 =head1 SEE ALSO
134  
135 L<TBX::Min>
136  
137 =for Pod::Coverage BUILD
138  
139 =head1 AUTHOR
140  
141 Nathan Glenn <garfieldnate@gmail.com>
142  
143 =head1 COPYRIGHT AND LICENSE
144  
145 This software is copyright (c) 2013 by Alan Melby.
146  
147 This is free software; you can redistribute it and/or modify it under
148 the same terms as the Perl 5 programming language system itself.
149  
150 =cut
« blib/lib/TBX/Min/Entry.pm ↑ Summary Build »