| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of TBX-Min | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2016 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::TIG; | ||||||||||||||||||||||||||||
| 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 note_groups); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Class::Tiny qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | term | ||||||||||||||||||||||||||||
| 15 | part_of_speech | ||||||||||||||||||||||||||||
| 16 | customer | ||||||||||||||||||||||||||||
| 17 | status | ||||||||||||||||||||||||||||
| 18 | note_groups | ||||||||||||||||||||||||||||
| 19 | 1 | ); | |||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | our $VERSION = '0.08'; # VERSION | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # ABSTRACT: Store information from one TBX-Min C<tig> element | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub part_of_speech { | ||||||||||||||||||||||||||
|
Subroutine
part_of_speech: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 29 | 0 | my ($self, $pos) = @_; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | if(defined $pos){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | _validate_pos($pos); | |||||||||||||||||||||||||||
| 32 | 0 | $self->{part_of_speech} = $pos; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 0 | return $self->{part_of_speech}; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub note_groups { ## no critic(RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
note_groups: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 38 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | croak 'extra argument found (note_groups is a getter only)'; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | return $self->{note_groups}; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub add_note_group { | ||||||||||||||||||||||||||
|
Subroutine
add_note_group: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 0 | my ($self, $note_grp) = @_; | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | if( !$note_grp || !$note_grp->isa('TBX::Min::NoteGrp') ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$note_grp and $note_grp->isa("TBX::Min::NoteGrp")
MC/DC0%0/2
$note_grp and $note_grp->isa("TBX::Min::NoteGrp")
$note_grp
$note_grp->isa("TBX::Min::NoteGrp")
Truth table0%0/3
A and B
A= $note_grpB= $note_grp->isa("TBX::Min::NoteGrp")
| |||||||||||||||||||||||||||||
| 48 | 0 | croak 'argument to add_term_group should be a TBX::Min::TIG'; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 0 | push @{$self->{note_groups}}, $note_grp; | |||||||||||||||||||||||||||
| 51 | 0 | return; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub status { | ||||||||||||||||||||||||||
|
Subroutine
status: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 56 | 0 | my ($self, $status) = @_; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | if(defined $status){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | _validate_status($status); | |||||||||||||||||||||||||||
| 59 | 0 | $self->{status} = $status; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 0 | return $self->{status}; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # above Pod::Coverage makes this not "naked" via Pod::Coverage::TrustPod | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | my %valid = map {+($_=>1)} Class::Tiny->get_all_attributes_for(__PACKAGE__); | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | # validate arguments | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if(my @invalids = grep {!$valid{$_}} sort keys %$args){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | croak 'Invalid attributes for class: ' . | |||||||||||||||||||||||||||
| 73 | join ' ', @invalids | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if($args->{note_groups} && ref $args->{note_groups} ne 'ARRAY'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"note_groups"} and ref $args->{"note_groups"} ne "ARRAY"
MC/DC0%0/2
$args->{"note_groups"} and ref $args->{"note_groups"} ne "ARRAY"
$args->{"note_groups"}
ref $args->{"note_groups"} ne "ARRAY"
Truth table0%0/3
A and B
A= $args->{"note_groups"}B= ref $args->{"note_groups"} ne "ARRAY"
| |||||||||||||||||||||||||||||
| 76 | 0 | croak q{Attribute 'note_groups' should be an array reference}; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if($args->{part_of_speech}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | _validate_pos($args->{part_of_speech}); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if($args->{status}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | _validate_status($args->{status}); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $self->{note_groups} ||= []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"note_groups"} ||= []
MC/DC0%0/1
$self->{"note_groups"} ||= []
$self->{"note_groups"}
Truth table0%0/2
A
A= $self->{"note_groups"}
| |||||||||||||||||||||||||||||
| 86 | 0 | return; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | my @allowed_pos = qw(noun properNoun verb adjective adverb other); | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub _validate_pos { | ||||||||||||||||||||||||||
|
Subroutine
_validate_pos: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 91 | 0 | my ($pos) = @_; | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | if(!grep{$pos eq $_} @allowed_pos){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | croak "Illegal part of speech '$pos'"; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 0 | return; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | my @allowed_status = qw(admitted preferred notRecommended obsolete); | |||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub _validate_status { | ||||||||||||||||||||||||||
|
Subroutine
_validate_status: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 100 | 0 | my ($pos) = @_; | |||||||||||||||||||||||||||
| 101 | 0 | ▶ | if(!grep{$pos eq $_} @allowed_status){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | croak "Illegal status '$pos'"; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 0 | return; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | 1; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||