| 1 | #! /bin/false | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2016-2018 Guido Flohr <guido.flohr@cantanea.com>, | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # all rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # the Free Software Foundation; either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | package Qgoda::Config; | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | $Qgoda::Config::VERSION = 'v0.9.2'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | ▶ | use Locale::TextDomain qw('qgoda'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | ▶ | use Scalar::Util qw(reftype looks_like_number); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | use File::Globstar qw(quotestar); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | ▶ | use File::Globstar::ListMatch; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | use Qgoda::Util qw(read_file empty yaml_error merge_data lowercase | |||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | ▶ | safe_yaml_load); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | my %processors; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=28 SCAR=44.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | require Qgoda; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | my $q = Qgoda->new; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | my $logger = $q->logger('config'); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my $filename; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | if (!empty $args{filename}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $filename = $args{filename}; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } elsif (-e '_config.yaml') { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | $filename = '_config.yaml'; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } elsif (-e '_config.yml') { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $filename = '_config.yml'; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } elsif (-e '_config.json') { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $filename = '_config.json'; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } elsif (!$q->getOption('no-config')) { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | $logger->warning(__"config file '_config.yaml' not found, " | |||||||||||||||||||||||||||||||||||||||||
| 53 | . "proceeding with defaults."); | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | my $config = $class->default; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | if (!empty $filename) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | $logger->info(__x("reading configuration from '{filename}'", | |||||||||||||||||||||||||||||||||||||||||
| 60 | filename => $filename)); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my $yaml = read_file $filename; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | if (!defined $yaml) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $logger->fatal(__x("cannot read '{filename}': {error}", | |||||||||||||||||||||||||||||||||||||||||
| 64 | filename => $filename, error => $!)); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my $local = eval { safe_yaml_load $yaml }; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | $logger->fatal(yaml_error $filename, $@) if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | foreach my $key (grep { /^__q_/ } keys %{$local || {}}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $logger->fatal(__x("illegal configuration variable '{var}':" | |||||||||||||||||||||||||||||||||||||||||
| 72 | . " names starting with '__q_' are reserved" | ||||||||||||||||||||||||||||||||||||||||||
| 73 | . " for internal purposes.", | ||||||||||||||||||||||||||||||||||||||||||
| 74 | var => $key)); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | $config = merge_data $config, $local if $local; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | my $local_filename; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | if (-e '_localconfig.yaml') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $local_filename = '_localconfig.yaml'; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } elsif (-e '_localconfig.yml') { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $local_filename = '_localconfig.yml'; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } elsif (-e '_localconfig.json') { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $local_filename = '_localconfig.json'; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | if (!empty $local_filename) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $logger->info(__x("reading local configuration from '{filename}'", | |||||||||||||||||||||||||||||||||||||||||
| 90 | filename => $local_filename)); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $yaml = read_file $local_filename; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (!defined $yaml) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $logger->fatal(__x("cannot read '{filename}': {error}", | |||||||||||||||||||||||||||||||||||||||||
| 94 | filename => $local_filename, error => $!)); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $local = eval { safe_yaml_load $yaml }; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $logger->fatal(yaml_error $local_filename, $@) if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | foreach my $key (grep { /^__q_/ } keys %{$local || {}}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $logger->fatal(__x("illegal configuration variable '{var}':" | |||||||||||||||||||||||||||||||||||||||||
| 102 | . " names starting with '__q_' are reserved" | ||||||||||||||||||||||||||||||||||||||||||
| 103 | . " for internal purposes.", | ||||||||||||||||||||||||||||||||||||||||||
| 104 | var => $key)); | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $config = merge_data $config, $local if $local; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | my $self = bless $config, $class; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | eval { $self->checkConfig($self) }; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $logger->fatal(__x("{filename}: {error}", | |||||||||||||||||||||||||||||||||||||||||
| 115 | filename => $filename, error => $@)); | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # Clean up certain variables or overwrite them unconditionally. | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | $config->{srcdir} = Cwd::abs_path($config->{srcdir}); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | $config->{paths}->{site} = Cwd::abs_path($config->{paths}->{site}); | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | my @exclude = ( | |||||||||||||||||||||||||||||||||||||||||
| 123 | '/_*', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | '.*' | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | my @exclude_watch = ( | |||||||||||||||||||||||||||||||||||||||||
| 127 | '/_*', | ||||||||||||||||||||||||||||||||||||||||||
| 128 | '.*', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | my $viewdir = File::Spec->abs2rel($self->{paths}->{views}); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | push @exclude_watch, '!' . quotestar $viewdir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | if $viewdir !~ m{^\.\./}; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | my $includedir = File::Spec->abs2rel($self->{paths}->{includes}); | |||||||||||||||||||||||||||||||||||||||||
| 135 | 4 | ▶ | push @exclude_watch, '!' . quotestar $includedir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | if $includedir !~ m{^\.\./}; | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | ▶ | my @config_exclude = @{$config->{exclude} || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | ▶ | my @config_exclude_watch = @{$config->{exclude_watch} || $config->{exclude} || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$config->{"exclude_watch"} or $config->{"exclude"}
MC/DC0%0/2
$config->{"exclude_watch"} or $config->{"exclude"}
$config->{"exclude_watch"}
$config->{"exclude"}
Truth table33%1/3
A or B
A= $config->{"exclude_watch"}B= $config->{"exclude"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | push @exclude, @config_exclude; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | push @exclude_watch, @config_exclude_watch; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | my $outdir = File::Spec->abs2rel($self->{outdir}, $self->{srcdir}); | |||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | ▶ | if ($outdir !~ m{^\.\./}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | push @exclude, quotestar $outdir, 1; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | push @exclude_watch, quotestar $outdir, 1; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | $self->{__q_exclude} = File::Globstar::ListMatch->new( | ||||||||||||||||||||||||||||||||||||||||||
| 150 | \@exclude, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ignoreCase => !$self->{'case-sensitive'} | |||||||||||||||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 153 | $self->{__q_exclude_watch} = File::Globstar::ListMatch->new( | ||||||||||||||||||||||||||||||||||||||||||
| 154 | \@exclude_watch, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 4 | ignoreCase => !$self->{'case-sensitive'} | |||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | sub default { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # Default configuration. | ||||||||||||||||||||||||||||||||||||||||||
| 163 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | ▶ | title => __"A New Qgoda Powered Site", | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | # FIXME! This should not be configurable. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | srcdir => '.', | ||||||||||||||||||||||||||||||||||||||||||
| 167 | location => '/{directory}/{basename}/{index}{suffix}', | ||||||||||||||||||||||||||||||||||||||||||
| 168 | permalink => '{significant-path}', | ||||||||||||||||||||||||||||||||||||||||||
| 169 | index => 'index', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 'case-sensitive' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | view => 'default.html', | ||||||||||||||||||||||||||||||||||||||||||
| 172 | latency => 0.5, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | exclude => [], | ||||||||||||||||||||||||||||||||||||||||||
| 174 | exclude_watch => [], | ||||||||||||||||||||||||||||||||||||||||||
| 175 | no_scm => [], | ||||||||||||||||||||||||||||||||||||||||||
| 176 | paths => { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | views => '_views', | ||||||||||||||||||||||||||||||||||||||||||
| 178 | plugins => '_plugins', | ||||||||||||||||||||||||||||||||||||||||||
| 179 | po => '_po', | ||||||||||||||||||||||||||||||||||||||||||
| 180 | site => '_site', | ||||||||||||||||||||||||||||||||||||||||||
| 181 | timestamp => '_timestamp', | ||||||||||||||||||||||||||||||||||||||||||
| 182 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 183 | compare_output => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | helpers => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | processors => { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | chains => { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | markdown => { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | modules => [qw(TT2 Markdown)], | ||||||||||||||||||||||||||||||||||||||||||
| 189 | suffix => 'html', | ||||||||||||||||||||||||||||||||||||||||||
| 190 | wrapper => 'html' | ||||||||||||||||||||||||||||||||||||||||||
| 191 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | html => { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | modules => [qw(TT2 HTMLFilter)], | ||||||||||||||||||||||||||||||||||||||||||
| 194 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | triggers => { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | md => 'markdown', | ||||||||||||||||||||||||||||||||||||||||||
| 198 | mdown => 'markdown', | ||||||||||||||||||||||||||||||||||||||||||
| 199 | mkdn => 'markdown', | ||||||||||||||||||||||||||||||||||||||||||
| 200 | mdwn => 'markdown', | ||||||||||||||||||||||||||||||||||||||||||
| 201 | mkd => 'markdown', | ||||||||||||||||||||||||||||||||||||||||||
| 202 | html => 'html', | ||||||||||||||||||||||||||||||||||||||||||
| 203 | htm => 'html', | ||||||||||||||||||||||||||||||||||||||||||
| 204 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | options => { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | Markdown => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | TT2 => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 208 | HTMLFilter => [ | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 'AnchorTarget', | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 'Generator', | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 'CleanUp', | ||||||||||||||||||||||||||||||||||||||||||
| 212 | ['TOC', | ||||||||||||||||||||||||||||||||||||||||||
| 213 | content_tag => 'qgoda-content', | ||||||||||||||||||||||||||||||||||||||||||
| 214 | toc_tag => 'qgoda-toc', | ||||||||||||||||||||||||||||||||||||||||||
| 215 | start => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 216 | end => 6, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | template => 'components/toc.html' | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 219 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 220 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 222 | link_score => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | taxonomies => { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | tags => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 225 | categories => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 226 | links => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 227 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 228 | po => { | ||||||||||||||||||||||||||||||||||||||||||
| 229 | tt2 => [qw(_views)], | ||||||||||||||||||||||||||||||||||||||||||
| 230 | from_code => 'utf-8', | ||||||||||||||||||||||||||||||||||||||||||
| 231 | copyright_holder => __"Set config.po.copyright_holder in _config.yaml", | ||||||||||||||||||||||||||||||||||||||||||
| 232 | msgid_bugs_address => __"Set config.po.msgid_bugs_address in _config.yaml", | ||||||||||||||||||||||||||||||||||||||||||
| 233 | qgoda => 'qgoda', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | refresh => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | xgettext => 'xgettext', | ||||||||||||||||||||||||||||||||||||||||||
| 236 | xgettext_tt2 => 'xgettext-tt2', | ||||||||||||||||||||||||||||||||||||||||||
| 237 | msgfmt => 'msgfmt', | ||||||||||||||||||||||||||||||||||||||||||
| 238 | msgmerge => 'msgmerge', | ||||||||||||||||||||||||||||||||||||||||||
| 239 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | front_matter_placeholder => "[% '' %]\n", | ||||||||||||||||||||||||||||||||||||||||||
| 241 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | # Consistency check. | ||||||||||||||||||||||||||||||||||||||||||
| 245 | sub checkConfig { | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | ▶ | my ($self, $config) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkConfig: called CC=50 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | ▶ | die __"invalid format (not a hash)\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | unless ($self->__isHash($config)); | ||||||||||||||||||||||||||||||||||||||||||
| 250 | die __x("'{variable}' must be a dictionary", variable => 'processors') | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | ▶ | unless $self->__isHash($config->{processors}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | die __x("'{variable}' must be a dictionary", variable => 'processors.chains') | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | ▶ | unless $self->__isHash($config->{processors}->{chains}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | foreach my $chain (keys %{$config->{processors}->{chains}}) { | |||||||||||||||||||||||||||||||||||||||||
| 255 | die __x("'{variable}' must be a dictionary", variable => "processors.chains.$chain") | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 8 | ▶ | unless $self->__isHash($config->{processors}->{chains}->{$chain}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 8 | ▶ | if (exists $config->{processors}->{chains}->{$chain}->{modules}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | die __x("'{variable}' must not be a dictionary", variable => "processors.chains.$chain.modules") | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 8 | ▶ | if $self->__isHash($config->{processors}->{chains}->{$chain}->{modules}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 8 | ▶ | if (!$self->__isArray($config->{processors}->{chains}->{$chain}->{modules})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | $config->{processors}->{chains}->{$chain}->{modules} = | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | [$config->{processors}->{chains}->{$chain}->{modules}], | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $config->{processors}->{chains}->{$chain}->{modules} = ['Null']; | |||||||||||||||||||||||||||||||||||||||||
| 266 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 8 | ▶ | if (exists $config->{processors}->{chains}->{$chain}->{suffix}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | die __x("'{variable}' must be a single value", variable => "processors.chains.$chain.suffix") | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | ▶ | if ref $config->{processors}->{chains}->{$chain}->{suffix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | die __x("'{variable}' must be a dictionary", variable => 'processors.triggers') | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 4 | ▶ | unless $self->__isHash($config->{processors}->{triggers}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | foreach my $suffix (keys %{$config->{processors}->{triggers}}) { | |||||||||||||||||||||||||||||||||||||||||
| 275 | 28 | my $chain = $config->{processors}->{triggers}->{$suffix}; | |||||||||||||||||||||||||||||||||||||||||
| 276 | die __x("processor chain suffix '{suffix}' references undefined chain '{chain}'", | ||||||||||||||||||||||||||||||||||||||||||
| 277 | suffix => $suffix, chain => $chain) | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 28 | ▶ | unless exists $config->{processors}->{chains}->{$chain}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | die __x("'{variable}' must be a dictionary", variable => 'processors.options') | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | ▶ | unless $self->__isHash($config->{processors}->{options}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | die __x("'{variable}' must be a dictionary", variable => 'helpers') | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | if exists $self->{helpers} && !$self->__isHash($self->{helpers}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"helpers"} and not $self->__isHash($self->{"helpers"})
MC/DC0%0/2
exists $self->{"helpers"} and not $self->__isHash($self->{"helpers"})
exists $self->{"helpers"}
not $self->__isHash($self->{"helpers"})
Truth table33%1/3
A and not(B)
A= exists $self->{"helpers"}B= not $self->__isHash($self->{"helpers"})
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | foreach my $helper (keys %{$config->{helpers}}) { | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $arguments = $config->{helpers}->{$helper}; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if (empty $arguments) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $arguments = [] if empty $arguments; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | } elsif (ref $arguments) { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | die __x("'{variable}' must be a list", variable => "helpers.$helper") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | if !$self->__isArray($arguments); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $arguments = [$arguments]; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $config->{helpers}->{$helper} = $arguments; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | die __x("'{variable}' must be a list", variable => 'exclude') | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | ▶ | if exists $self->{exclude} && !$self->__isArray($self->{exclude}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"exclude"} and not $self->__isArray($self->{"exclude"})
MC/DC0%0/2
exists $self->{"exclude"} and not $self->__isArray($self->{"exclude"})
exists $self->{"exclude"}
not $self->__isArray($self->{"exclude"})
Truth table33%1/3
A and not(B)
A= exists $self->{"exclude"}B= not $self->__isArray($self->{"exclude"})
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | die __x("'{variable}' must be a list", variable => 'exclude_watch') | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | ▶ | if exists $self->{exclude_watch} && !$self->__isArray($self->{exclude_watch}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"exclude_watch"} and not $self->__isArray($self->{"exclude_watch"})
MC/DC0%0/2
exists $self->{"exclude_watch"} and not $self->__isArray($self->{"exclude_watch"})
exists $self->{"exclude_watch"}
not $self->__isArray($self->{"exclude_watch"})
Truth table33%1/3
A and not(B)
A= exists $self->{"exclude_watch"}B= not $self->__isArray($self->{"exclude_watch"})
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | die __x("'{variable}' must be a list", variable => 'defaults') | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 4 | ▶ | if exists $self->{defaults} && !$self->__isArray($config->{defaults}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"defaults"} and not $self->__isArray($config->{"defaults"})
MC/DC0%0/2
exists $self->{"defaults"} and not $self->__isArray($config->{"defaults"})
exists $self->{"defaults"}
not $self->__isArray($config->{"defaults"})
Truth table33%1/3
A and not(B)
A= exists $self->{"defaults"}B= not $self->__isArray($config->{"defaults"})
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | die __x("'{variable}' must be a dictionary", variable => 'taxonomies') | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 4 | ▶ | if exists $self->{taxonomies} && !$self->__isHash($config->{taxonomies}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"taxonomies"} and not $self->__isHash($config->{"taxonomies"})
MC/DC0%0/2
exists $self->{"taxonomies"} and not $self->__isHash($config->{"taxonomies"})
exists $self->{"taxonomies"}
not $self->__isHash($config->{"taxonomies"})
Truth table33%1/3
A and not(B)
A= exists $self->{"taxonomies"}B= not $self->__isHash($config->{"taxonomies"})
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 4 | foreach my $taxonomy (keys %{$config->{taxonomies}}) { | |||||||||||||||||||||||||||||||||||||||||
| 306 | $config->{taxonomies}->{$taxonomy} = 1 | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 12 | ▶ | if !defined $config->{taxonomies}->{$taxonomy}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | die __x("'{variable}' must be a single value", variable => 'type') | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | ▶ | if ref $config->{type}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | die __x("'{variable}' must be a dictionary", variable => 'po') | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | ▶ | if exists $self->{po} && !$self->__isHash($config->{po}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"po"} and not $self->__isHash($config->{"po"})
MC/DC0%0/2
exists $self->{"po"} and not $self->__isHash($config->{"po"})
exists $self->{"po"}
not $self->__isHash($config->{"po"})
Truth table33%1/3
A and not(B)
A= exists $self->{"po"}B= not $self->__isHash($config->{"po"})
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 4 | foreach my $cmd (qw(xgettext xgettext_tt2 qgoda msgfmt msgmerge)) { | |||||||||||||||||||||||||||||||||||||||||
| 316 | 20 | ▶ | if (exists $config->{po}->{$cmd}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | die __x("'{variable}' must not be empty", variable => "po.$cmd") | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 20 | ▶ | if empty $config->{po}->{$cmd}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 20 | ▶ | if (ref $config->{po}->{$cmd} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $config->{"po"}{$cmd} and not $self->__isArray($config->{"po"}{$cmd})
MC/DC0%0/2
ref $config->{"po"}{$cmd} and not $self->__isArray($config->{"po"}{$cmd})
ref $config->{"po"}{$cmd}
not $self->__isArray($config->{"po"}{$cmd})
Truth table33%1/3
A and not(B)
A= ref $config->{"po"}{$cmd}B= not $self->__isArray($config->{"po"}{$cmd})
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | && !$self->__isArray($config->{po}->{$cmd})) { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | die __x("'{variable}' must be a single value or a a list", | |||||||||||||||||||||||||||||||||||||||||
| 322 | variable => "po.$cmd"); | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | die __x("'{variable}' must be a list", variable => 'linguas') | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 4 | ▶ | if exists $config->{linguas} && !$self->__isArray($config->{linguas}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $config->{"linguas"} and not $self->__isArray($config->{"linguas"})
MC/DC0%0/2
exists $config->{"linguas"} and not $self->__isArray($config->{"linguas"})
exists $config->{"linguas"}
not $self->__isArray($config->{"linguas"})
Truth table66%2/3
A and not(B)
A= exists $config->{"linguas"}B= not $self->__isArray($config->{"linguas"})
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | die __x("'{variable}' must be a list", variable => 'analyzers') | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 4 | ▶ | if exists $self->{analyzers} && !$self->__isArray($self->{analyzers}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"analyzers"} and not $self->__isArray($self->{"analyzers"})
MC/DC0%0/2
exists $self->{"analyzers"} and not $self->__isArray($self->{"analyzers"})
exists $self->{"analyzers"}
not $self->__isArray($self->{"analyzers"})
Truth table33%1/3
A and not(B)
A= exists $self->{"analyzers"}B= not $self->__isArray($self->{"analyzers"})
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | die __x("'{variable}' must be a list", variable => 'po.mdextra') | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | ▶ | if exists $self->{analyzers} && !$self->__isArray($self->{po}->{mdextra}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"analyzers"} and not $self->__isArray($self->{"po"}{"mdextra"})
MC/DC0%0/2
exists $self->{"analyzers"} and not $self->__isArray($self->{"po"}{"mdextra"})
exists $self->{"analyzers"}
not $self->__isArray($self->{"po"}{"mdextra"})
Truth table33%1/3
A and not(B)
A= exists $self->{"analyzers"}B= not $self->__isArray($self->{"po"}{"mdextra"})
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | die __x("'{variable}' must be a list", variable => 'po.views') | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 4 | ▶ | if exists $self->{analyzers} && !$self->__isArray($self->{po}->{views}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"analyzers"} and not $self->__isArray($self->{"po"}{"views"})
MC/DC0%0/2
exists $self->{"analyzers"} and not $self->__isArray($self->{"po"}{"views"})
exists $self->{"analyzers"}
not $self->__isArray($self->{"po"}{"views"})
Truth table33%1/3
A and not(B)
A= exists $self->{"analyzers"}B= not $self->__isArray($self->{"po"}{"views"})
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | die __x("'{variable}' must be a list", variable => 'no_scm') | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | ▶ | if exists $self->{analyzers} && !$self->__isArray($self->{po}->{views}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"analyzers"} and not $self->__isArray($self->{"po"}{"views"})
MC/DC0%0/2
exists $self->{"analyzers"} and not $self->__isArray($self->{"po"}{"views"})
exists $self->{"analyzers"}
not $self->__isArray($self->{"po"}{"views"})
Truth table33%1/3
A and not(B)
A= exists $self->{"analyzers"}B= not $self->__isArray($self->{"po"}{"views"})
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | # Has to be done after everything was read. We need the value of | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # case-sensitive. | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 4 | $self->{defaults} = $self->__compileDefaults($self->{defaults}); | |||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | sub ignorePath { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 10 | ▶ | my ($self, $path, $watch) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ignorePath: called CC=8 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | # We only care about regular files and directories. Symbolic links are | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # excluded on purpose. If, however, the file is deleted, we have to | ||||||||||||||||||||||||||||||||||||||||||
| 350 | # do the normal checks. | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 10 | ▶ | if (-e $path && (!-f $path && !-d $path)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
-e $path and not -f $path || -d $path
-f $path || -d $path
MC/DC0%0/3
-e $path and not -f $path || -d $path
-e $path
-f $path
-d $path
Truth table50%2/4
A and not(B || C)
A= -e $pathB= -f $pathC= -d $path
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # Do not ignore the top-level directory. This check is needed because | ||||||||||||||||||||||||||||||||||||||||||
| 356 | # abs2rel() returns a lone dot for it. | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 10 | ▶ | return if $path eq $self->{srcdir}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 8 | my $relpath = File::Spec->abs2rel($path, $self->{srcdir}); | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 8 | ▶ | if ($watch) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | return $self if $self->{__q_exclude_watch}->match($relpath); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 8 | ▶ | return $self if $self->{__q_exclude}->match($relpath); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | sub __isHash { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 51 | ▶ | my ($self, $what) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__isHash: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 51 | ▶ | return unless $what && ref $what && 'HASH' eq reftype $what; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$what and ref $what and "HASH" eq builtin::reftype($what)
$what and ref $what
MC/DC33%1/3
$what and ref $what and "HASH" eq builtin::reftype($what)
$what
ref $what
"HASH" eq builtin::reftype($what)
Truth table50%2/4
A and B and C
A= $whatB= ref $whatC= "HASH" eq builtin::reftype($what)
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 43 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | sub __isArray { | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 17 | ▶ | my ($self, $what) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__isArray: called CC=4 SCAR=17.1
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 17 | ▶ | return unless $what && ref $what && 'ARRAY' eq reftype $what; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$what and ref $what and "ARRAY" eq builtin::reftype($what)
$what and ref $what
MC/DC0%0/3
$what and ref $what and "ARRAY" eq builtin::reftype($what)
$what
ref $what
"ARRAY" eq builtin::reftype($what)
Truth table25%1/4
A and B and C
A= $whatB= ref $whatC= "ARRAY" eq builtin::reftype($what)
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 17 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | sub __isNumber { | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | my ($self, $what) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__isNumber: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | return unless defined $what; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | return $self if looks_like_number $what; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | sub __compileDefaults { | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 7 | ▶ | my ($self, $rules) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__compileDefaults: called CC=8 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 7 | my @defaults; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 7 | foreach my $rule (@$rules) { | |||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | my $pattern = $rule->{files}; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | ▶ | $pattern = '*' if empty $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | ▶ | if (ref $pattern) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if (!$self->__isArray($pattern)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | die __x("'{variable}' must be a scalar or a list", | |||||||||||||||||||||||||||||||||||||||||
| 406 | variable => 'defaults.file'); | ||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | $pattern = [$pattern]; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | $pattern = File::Globstar::ListMatch->new($pattern, | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | $self->{'case-insensitive'}); | |||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | ▶ | if (exists $rule->{values}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 3 | ▶ | if (!$self->__isHash($rule->{values})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | die __x("'{variable}' must be a hash", | |||||||||||||||||||||||||||||||||||||||||
| 417 | variable => 'defaults.value'); | ||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | ▶ | push @defaults, [$pattern, $rule->{values} || {}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rule->{'values'} || {}
MC/DC0%0/1
$rule->{'values'} || {}
$rule->{'values'}
Truth table50%1/2
A
A= $rule->{'values'}
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 7 | return \@defaults; | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||