| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Zest::Author::TABULO::Util::Dzil; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '1.000014'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Data::OptList; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Text::Trim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Exporter::Shiny qw( grok_plugin grok_plugins); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #region: #== UTILITY FUNCTIONS (EXPORT_OK) == | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ## no critic: Prototypes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 128 | ▶ | sub grok_plugin($) { # single plugin () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grok_plugin: called CC=12 SCAR=27.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 128 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 128 | my (@plugin) = @{$_[0]}; # MUST be an ARRAY ref. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 128 | ▶ | my $v = ref $plugin[$#plugin] ? pop @plugin : {}; # options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 128 | ▶ | my $k = join '/', grep {; defined && $_ ne '' } map {; $_= trim($_ // '') } (@plugin); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
defined $_ && $_ ne ''
$_ // ""
MC/DC50%1/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
MC/DC100%1/1
$_ // ""
$_
Truth table66%2/3
A && B
A= defined $_B= $_ ne ''
Truth table100%2/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 128 | my ( $moniker, $label ) = split( qr{\s*/\s*}, $k, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 128 | ▶ | ( $moniker, $label ) = (trim($moniker //= ''), trim($label //= '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$moniker //= ""
$label //= ""
MC/DC0%0/1
$moniker //= ""
$moniker
MC/DC100%1/1
$label //= ""
$label
Truth table50%1/2
A
A= $moniker
Truth table100%2/2
A
A= $label
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 128 | $label =~ s!\A$moniker\Z!!; # in case it starts with that | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 128 | ▶ | my $name = join('/', $moniker || (), $label || ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$moniker || ()
$label || ()
MC/DC0%0/2
$moniker || ()
$moniker
()
MC/DC0%0/2
$label || ()
$label
()
Truth table33%1/3
A || B
A= $monikerB= ()
Truth table66%2/3
A || B
A= $labelB= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 128 | ▶ | my $p = [ $moniker || (), $name || (), $v // () ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
$moniker || ()
$name || ()
$v // ()
MC/DC0%0/2
$moniker || ()
$moniker
()
MC/DC0%0/2
$name || ()
$name
()
MC/DC0%0/2
$v // ()
$v
()
Truth table33%1/3
A || B
A= $monikerB= ()
Truth table33%1/3
A || B
A= $nameB= ()
Truth table33%1/3
A // B
A= $vB= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 128 | ▶ | @$p ? $p : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 128 | ▶ | sub grok_plugins { # One or more plugins. Lax style (can be a mix of ARRAY-refs and (k => v) pairs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grok_plugins: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 128 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 128 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 128 | my ( @res, @input ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 128 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 173 | ▶ | if ( ref($arg) =~ m/ARRAY/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | ▶ | push @res, grok_plugins(@input) if @input; # recurse! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 9 | push @res, grok_plugin($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | @input = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 164 | push @input, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 128 | ▶ | if (@input) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 119 | my %prefs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | moniker => 'plugins', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | require_unique => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | must_be => [qw(HASH)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 119 | my @optlist = @{ Data::OptList::mkopt( \@input, \%prefs ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | push @res, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 119 | grok_plugin($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } @optlist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # say STDERR "Grokked plugins: "; p @res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 128 | @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | #endregion (UTILITY FUNCTIONS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | =for :stopwords Tabulo[n] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | Zest::Author::TABULO::Util::Dzil - DZIL-related utility functions used by TABULO's authoring dist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | version 1.000014 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | =for Pod::Coverage grok_plugin grok_plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | Tabulo[n] <dev@tabulo.net> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =head1 LEGAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | This software is copyright (c) 2023 by Tabulo[n]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||