| 1 | 7 | ▶ | use v5.42; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | class App::Gimei::Runner { | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 7 | ▶ | binmode STDOUT, ":encoding(UTF-8)"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Pod::Find qw( pod_where ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use App::Gimei; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use App::Gimei::Parser; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # instance variables | ||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 7 | field $conf = { POD_FILE => pod_where( { -inc => 1 }, 'App::Gimei' ) }; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # | ||||||||||||||||||||||||||||
| 23 | # private instance methods | ||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 34 | ▶ | my method _parse_option ( $args_ref, $opts_ref ) { | ||||||||||||||||||||||||||
|
Subroutine
_parse_option: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 27 | 34 | $opts_ref->{n} = 1; | |||||||||||||||||||||||||||
| 28 | 34 | $opts_ref->{sep} = ', '; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 34 | my $p = Getopt::Long::Parser->new( config => ["no_ignore_case"], ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 34 | ▶ | local $SIG{__WARN__} = sub { die "Error: $_[0]" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 34 | my $ok = | |||||||||||||||||||||||||||
| 34 | $p->getoptionsfromarray( $args_ref, $opts_ref, "help|h", "version|v", "n=i", | ||||||||||||||||||||||||||||
| 35 | "sep=s", ); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 33 | ▶ | if ( $opts_ref->{n} < 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 1 | die | |||||||||||||||||||||||||||
| 39 | "Error: value $opts_ref->{n} invalid for option n (must be positive number)\n"; | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # | ||||||||||||||||||||||||||||
| 44 | # public instance methods | ||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 34 | ▶ | method execute (@args) { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 34 | my %opts; | |||||||||||||||||||||||||||
| 49 | 34 | $self->&_parse_option( \@args, \%opts ); | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 32 | ▶ | if ( $opts{version} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 2 | say "$App::Gimei::VERSION"; | |||||||||||||||||||||||||||
| 53 | 2 | return 0; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 30 | ▶ | if ( $opts{help} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 2 | pod2usage( -input => ${$conf}{POD_FILE}, -exitval => 'noexit' ); | |||||||||||||||||||||||||||
| 58 | 2 | return 0; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 28 | ▶ | if ( !@args ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 3 | push @args, 'name:kanji'; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 28 | my $generators = App::Gimei::Parser::parse(\@args); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 25 | _semantic_analysis($generators); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 23 | foreach ( 1 .. $opts{n} ) { | |||||||||||||||||||||||||||
| 70 | 24 | say join $opts{sep}, $generators->execute(); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 23 | return 0; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # | ||||||||||||||||||||||||||||
| 77 | # class methods | ||||||||||||||||||||||||||||
| 78 | # | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 25 | ▶ | sub _semantic_analysis ($generators) { | ||||||||||||||||||||||||||
|
Subroutine
_semantic_analysis: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 81 | 25 | foreach my $gen ( $generators->to_list() ) { | |||||||||||||||||||||||||||
| 82 | 26 | ▶ | if ( $gen->word_class eq 'Data::Gimei::Address' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$gen->word_class eq "Data::Gimei::Address" and $gen->rendering eq "romaji"
MC/DC100%2/2
$gen->word_class eq "Data::Gimei::Address" and $gen->rendering eq "romaji"
$gen->word_class eq "Data::Gimei::Address"
$gen->rendering eq "romaji"
Truth table100%3/3
A and B
A= $gen->word_class eq "Data::Gimei::Address"B= $gen->rendering eq "romaji"
| |||||||||||||||||||||||||||||
| 83 | && $gen->rendering eq 'romaji' ) | ||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||
| 85 | 2 | die "Error: rendering romaji is not supported for address\n"; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 7 | 1; | |||||||||||||||||||||||||||