| 1 | # ============================================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package MooseX::App::Meta::Role::Class::Documentation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ============================================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use Pod::Elemental; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 16 | ▶ | use Pod::Elemental::Selectors qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 16 | ▶ | use Pod::Elemental::Transformer::Pod5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | ▶ | use Pod::Elemental::Transformer::Nester; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 16 | has 'command_short_description' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | isa => 'Maybe[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | builder => '_build_command_short_description', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 16 | has 'command_long_description' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | isa => 'Maybe[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | builder => '_build_command_long_description', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 16 | has 'command_usage' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | isa => 'Maybe[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | builder => '_build_command_usage', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | has 'command_strict' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 83 | ▶ | default => sub {0}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 16 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | ▶ | sub command_short_description_predicate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_short_description_predicate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 23 | return $self->_command_pod_predicate('command_short_description'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | ▶ | sub _build_command_short_description { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_command_short_description: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 9 | my %pod = $self->_build_command_pod(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | return $pod{'command_short_description'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 9 | ▶ | if defined $pod{'command_short_description'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 36 | ▶ | sub command_long_description_predicate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_long_description_predicate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 36 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 36 | return $self->_command_pod_predicate('command_long_description'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub _build_command_long_description { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_command_long_description: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my %pod = $self->_build_command_pod(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | return $pod{'command_long_description'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if defined $pod{'command_long_description'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 35 | ▶ | sub command_usage_predicate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_usage_predicate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 35 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 35 | return $self->_command_pod_predicate('command_usage'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub _build_command_usage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_command_usage: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my %pod = $self->_build_command_pod(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | return $pod{'command_usage'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if defined $pod{'command_usage'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 94 | ▶ | sub _command_pod_predicate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_command_pod_predicate: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 94 | my ($self,$field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 94 | my $attribute = $self->meta->find_attribute_by_name($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 94 | ▶ | unless ($attribute->has_value($self)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 14 | $self->_build_command_pod($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 94 | my $value = $attribute->get_value($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 94 | ▶ | return (defined $value && $value ? 1:0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and $value
MC/DC50%1/2
defined $value and $value
defined $value
$value
Truth table66%2/3
A and B
A= defined $valueB= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 23 | ▶ | sub _build_command_pod { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_command_pod: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 23 | my %pod_raw = MooseX::App::Utils::parse_pod($self->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | my %pod = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | command_usage => ($pod_raw{SYNOPSIS} || $pod_raw{USAGE}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | command_long_description => ($pod_raw{DESCRIPTION} || $pod_raw{OVERVIEW}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 23 | ▶ | command_short_description => ($pod_raw{NAME} || $pod_raw{ABSTRACT}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition77%7/9
$pod_raw{'SYNOPSIS'} || $pod_raw{'USAGE'}
$pod_raw{'DESCRIPTION'} || $pod_raw{'OVERVIEW'}
$pod_raw{'NAME'} || $pod_raw{'ABSTRACT'}
MC/DC50%1/2
$pod_raw{'SYNOPSIS'} || $pod_raw{'USAGE'}
$pod_raw{'SYNOPSIS'}
$pod_raw{'USAGE'}
MC/DC50%1/2
$pod_raw{'DESCRIPTION'} || $pod_raw{'OVERVIEW'}
$pod_raw{'DESCRIPTION'}
$pod_raw{'OVERVIEW'}
MC/DC100%2/2
$pod_raw{'NAME'} || $pod_raw{'ABSTRACT'}
$pod_raw{'NAME'}
$pod_raw{'ABSTRACT'}
Truth table66%2/3
A || B
A= $pod_raw{'SYNOPSIS'}B= $pod_raw{'USAGE'}
Truth table66%2/3
A || B
A= $pod_raw{'DESCRIPTION'}B= $pod_raw{'OVERVIEW'}
Truth table100%3/3
A || B
A= $pod_raw{'NAME'}B= $pod_raw{'ABSTRACT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Loop sections that need to be extracted from POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 23 | foreach my $key (keys %pod) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 69 | my $meta_attribute = $self->meta->find_attribute_by_name($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 69 | ▶ | unless defined $meta_attribute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 69 | ▶ | if $meta_attribute->has_value($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 61 | $meta_attribute->set_raw_value($self,$pod{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 23 | return %pod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | #{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # package Moose::Meta::Class::Custom::Trait::AppCommand; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # sub register_implementation { return 'MooseX::App::Meta::Role::Class::Documentation' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||