lib/Skilletor/Bundles.pm

filter: Statementstmt 99.5% 211 / 212 Branchbran 95.4% 84 / 88 Conditioncond 71.4% 30 / 42 MC/DCmcdc 57.6% 15 / 26 Subroutinesub 100% 29 / 29 Podpod 100% 7 / 7 totaltotal 93.0% 376 / 404 CC 69 SCAR 23.0
CC
69
Cov
95%
parse_bundle
18.1
_foreign_entry
16.3
__ANON__
16.0
CRAP 10.0
« lib/Skilletor/Source/Url.pm ↑ Summary lib/Skilletor/CLI.pm »
1 package Skilletor::Bundles;
2 # ABSTRACT: Bundle files (spec §15), their expansion, and name patterns
3  
4 403 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 403 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 403 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 403 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 403 ▶use Skilletor::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 403 ▶use Skilletor::Error::Bundle;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 403 ▶use Skilletor::Error::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 403 ▶use Skilletor::Frontmatter qw( parse_yaml_document is_yaml_float );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 403 ▶use Skilletor::JSON qw( js_ordered js_stringify js_type );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 403 ▶use Skilletor::JSString qw( js_lc js_trim );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 403 ▶use Skilletor::Spec qw( resolve_spec );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 403 our $VERSION = '0.008000';
18  
19 403 our @EXPORT_OK = qw(
20 PATTERN_CHAR is_pattern matches_pattern same_identity match_entry
21 parse_bundle expand_bundle entry_miss
22 );
23  
24 # The character that makes a name a pattern (spec §3).
25 403 ▶use constant PATTERN_CHAR => '*';
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 403 my $DOT = qr/[^\n\r\x{2028}\x{2029}]/; # JavaScript's `.`
28  
29 403 my @TYPE_KEYS = ( skills => 'skill', agents => 'agent', rules => 'rule' );
30 403 my @KEYS = qw( description skills agents rules bundles vars );
31 403 my %KEY = map { $_ => 1 } @KEYS;
32  
33 284 ▶sub is_pattern {
Subroutine is_pattern: called CC=2 SCAR=6.9
Pod documented
34 284 my ( $name ) = @_;
35 284 ▶ return index( $name, PATTERN_CHAR ) >= 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
index($name, '*') != -1 ? : 61 223 284
36 }
37  
38 # `*` matches any run of characters but a line terminator (JavaScript's `.*`); the rest is literal.
39 451 ▶sub matches_pattern {
Subroutine matches_pattern: called CC=2 SCAR=6.9
Pod documented
40 451 my ( $pattern, $name ) = @_;
41 451 my $re = join "$DOT*", map { quotemeta } split /\Q${\PATTERN_CHAR}\E/, $pattern, -1;
42 451 ▶ return $name =~ /\A$re\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /\A$re\z/ ? : 441 10 451
43 }
44  
45 # Two source identities (`git`/`url` values) are the same modulo a trailing `/`, `.git` and host case.
46 522 ▶sub same_identity {
Subroutine same_identity: called CC=2 SCAR=6.9
Pod documented
47 522 my ( $a, $b ) = @_;
48 522 ▶ return _normalize_identity($a) eq _normalize_identity($b) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
_normalize_identity($a) eq _normalize_identity($b) ? : 304 218 522
49 }
50  
51 1044 ▶sub _normalize_identity {
Subroutine _normalize_identity: called CC=2 SCAR=6.9
52 1044 my ( $u ) = @_;
53 1044 ( my $s = js_trim($u) ) =~ s{/+\z}{};
54 1044 $s =~ s/\.git\z//;
55 1044 ▶ if ( $s =~ m{\A([a-z][a-z0-9+.\-]*://)([^/]*)($DOT*)\z}i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ m[\A([a-z][a-z0-9+.\-]*://)([^/]*)($DOT*)\z]i) 1040 4 1044
56 1040 $s = js_lc($1).js_lc($2).$3;
57 }
58 1044 return $s;
59 }
60  
61 # Catalog items of $type a name or pattern names (spec §3).
62 255 ▶sub match_entry {
Subroutine match_entry: called CC=4 SCAR=13.9
Pod documented
63 255 my ( $cat, $type, $entry ) = @_;
64 255 ▶ return [ grep { $_->{type} eq $type && matches_pattern( $entry, $_->{name} ) } @{ $cat->{items} } ] if is_pattern($entry);
Branch: 1 branch
BranchTrueFalseTotal
if is_pattern($entry) 58 197 255
Condition100%3/3
$_->{'type'} eq $type && matches_pattern($entry, $_->{'name'})
!ll&&!rl&&r
18258
MC/DC100%2/2
$_->{'type'} eq $type && matches_pattern($entry, $_->{'name'})
$_->{'type'} eq $type matches_pattern($entry, $_->{'name'})
Truth table100%3/3
A && B
A= $_->{'type'} eq $typeB= matches_pattern($entry, $_->{'name'})
ABresult
0X0
100
111
65 197 ▶ return [ grep { $_->{type} eq $type && $_->{name} eq $entry } @{ $cat->{items} } ];
Condition100%3/3
$_->{'type'} eq $type && $_->{'name'} eq $entry
!ll&&!rl&&r
5843196
MC/DC100%2/2
$_->{'type'} eq $type && $_->{'name'} eq $entry
$_->{'type'} eq $type $_->{'name'} eq $entry
Truth table100%3/3
A && B
A= $_->{'type'} eq $typeB= $_->{'name'} eq $entry
ABresult
0X0
100
111
66 }
67  
68 # The warning for an entry that matched $count items, if any (a bare `*` stays silent, spec §3).
69 255 ▶sub entry_miss {
Subroutine entry_miss: called CC=4 SCAR=13.9
Pod documented
70 255 my ( $type, $entry, $count ) = @_;
71 255 ▶ return undef if $count > 0 || $entry eq PATTERN_CHAR;
Branch: 1 branch
BranchTrueFalseTotal
if $count > 0 or $entry eq "*" 253 2 255
Condition66%2/3
$count > 0 or $entry eq "*"
l!l&&r!l&&!r
25302
MC/DC50%1/2
$count > 0 or $entry eq "*"
$count > 0 $entry eq "*"
Truth table66%2/3
A or B
A= $count > 0B= $entry eq "*"
ABresult
1X1
011
000
72 2 ▶ return is_pattern($entry) ? 'pattern '.$type.':'.$entry.' matches nothing' : $type.' '.$entry.' not found in the source';
Branch: 1 branch
BranchTrueFalseTotal
is_pattern($entry) ? : 1 1 2
73 }
74  
75 272 ▶sub _fail { Skilletor::Error::Bundle->throw( $_[0] ) }
Subroutine _fail: called CC=1 SCAR=0.0
76  
77 1 ▶sub _message { my ( $err ) = @_; return blessed $err && $err->can('message') ? $err->message : "$err" =~ s/ at \S+ line \d+\.?\n?\z//r }
Subroutine _message: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($err) && $err->can('message') ? : 1 0 1
Condition33%1/3
builtin::blessed($err) and $err->can("message")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($err) and $err->can("message")
builtin::blessed($err) $err->can("message")
Truth table33%1/3
A and B
A= builtin::blessed($err)B= $err->can("message")
ABresult
0X0
100
111
78  
79 # A YAML value as plain JSON-like data (floats become numbers).
80 41 ▶sub _plain {
Subroutine _plain: called CC=4 SCAR=13.9
81 41 my ( $v ) = @_;
82 41 ▶ return $v->value if is_yaml_float($v);
Branch: 1 branch
BranchTrueFalseTotal
if is_yaml_float($v) 3 38 41
83 38 ▶ return [ map { _plain($_) } @$v ] if ref $v eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "ARRAY" 1 37 38
84 37 ▶ return js_ordered( map { ( $_ => _plain( $v->{$_} ) ) } keys %$v ) if ref $v eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "HASH" 13 24 37
85 24 return $v;
86 }
87  
88 2849 ▶sub _string_list {
Subroutine _string_list: called CC=5 SCAR=16.1
89 2849 my ( $value, $key ) = @_;
90 2849 ▶ return [] unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 2117 732 2849
91 732 ▶ _fail( $key.' must be a list' ) unless ref $value eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "ARRAY" 2 730 732
92 return [
93 map {
94 730 ▶ _fail( $key.' entries must be strings (got '.js_stringify( _plain($_) ).')' ) unless _is_string($_);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_string($_) 5 771 776
95 771 ▶ _fail( $key.' has an empty entry' ) if js_trim($_) eq '';
Branch: 1 branch
BranchTrueFalseTotal
if js_trim($_) eq "" 3 768 771
96 768 js_trim($_);
97 } @$value
98 ];
99 }
100  
101 1512 ▶sub _is_string { my ( $v ) = @_; return !ref $v && js_type($v) eq 'string' }
Subroutine _is_string: called CC=2 SCAR=6.9
Condition100%3/3
!ref($v) && js_type($v) eq 'string'
!ll&&!rl&&r
441504
MC/DC100%2/2
!ref($v) && js_type($v) eq 'string'
!ref($v) js_type($v) eq 'string'
Truth table100%3/3
not(A) && B
A= !ref($v)B= js_type($v) eq 'string'
ABresult
0X0
100
111
102  
103 # `name@<spec>` resolved without a probe (spec §15.6): local paths, generic hosts, an address
104 # config load would refuse as a source and a ref or a path pinned by the address are errors.
105 654 ▶sub _foreign_entry {
Subroutine _foreign_entry: called CC=16 SCAR=27.9
106 654 my ( $type, $entry, $key ) = @_;
107 654 my $at = index $entry, '@';
108 654 my $name = substr $entry, 0, $at;
109 654 my $spec = substr $entry, $at + 1;
110 654 ▶ _fail( $key.': "'.$entry.'" has an empty name or address' ) if $name eq '' || $spec eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "" or $spec eq "" 2 652 654
Condition100%3/3
$name eq "" or $spec eq ""
l!l&&r!l&&!r
11652
MC/DC100%2/2
$name eq "" or $spec eq ""
$name eq "" $spec eq ""
Truth table100%3/3
A or B
A= $name eq ""B= $spec eq ""
ABresult
1X1
011
000
111 652 my $r;
112 652 my $ok = eval {
113 652 ▶ $r = resolve_spec( $spec, sub { Skilletor::Error::Spec->throw('probe') } );
Subroutine __ANON__: called CC=1 SCAR=0.0
114 650 ▶ if ( $r->{kind} eq 'local' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r->{"kind"} eq "local") 1 649 650
115 1 _fail( $key.': "'.$entry.'" names a local path; a bundle can only name remote sources' );
116 }
117 649 ▶ if ( defined $r->{ref} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"ref"}) 2 647 649
118 2 ▶ my $pins = 'ref '.js_stringify( $r->{ref} ).( defined $r->{path} ? ' and path '.js_stringify( $r->{path} ) : '' );
Branch: 1 branch
BranchTrueFalseTotal
defined $r->{'path'} ? : 1 1 2
119 2 _fail( $key.': "'.$entry.'" pins '.$pins.', but an entry names its source by address alone: write '.$name.'@'.$r->{value} );
120 }
121 647 1;
122 };
123 652 ▶ unless ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 5 647 652
124 5 my $err = $@;
125 5 ▶ die $err if blessed $err && $err->isa('Skilletor::Error::Bundle');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($err) and $err->isa("Skilletor::Error::Bundle") 3 2 5
Condition66%2/3
builtin::blessed($err) and $err->isa("Skilletor::Error::Bundle")
!ll&&!rl&&r
023
MC/DC50%1/2
builtin::blessed($err) and $err->isa("Skilletor::Error::Bundle")
builtin::blessed($err) $err->isa("Skilletor::Error::Bundle")
Truth table66%2/3
A and B
A= builtin::blessed($err)B= $err->isa("Skilletor::Error::Bundle")
ABresult
0X0
100
111
126 2 ▶ if ( blessed $err && $err->isa('Skilletor::Error::Spec') && $err->message eq 'probe' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($err) and $err->isa("Skilletor::Error::Spec") and $err->message eq "probe") 1 1 2
Condition50%3/6
builtin::blessed($err) and $err->isa("Skilletor::Error::Spec") and $err->message eq "probe"
!ll&&!rl&&r
011
builtin::blessed($err) and $err->isa("Skilletor::Error::Spec")
!ll&&!rl&&r
002
MC/DC33%1/3
builtin::blessed($err) and $err->isa("Skilletor::Error::Spec") and $err->message eq "probe"
builtin::blessed($err) $err->isa("Skilletor::Error::Spec") $err->message eq "probe"
Truth table50%2/4
A and B and C
A= builtin::blessed($err)B= $err->isa("Skilletor::Error::Spec")C= $err->message eq "probe"
ABCresult
0XX0
10X0
1100
1111
127 1 _fail( $key.': "'.$entry.'": a generic host must be written as a full https:// URL' );
128 }
129 1 _fail( $key.': "'.$entry.'": '._message($err) );
130 }
131 647 ▶ my $field = $r->{kind} eq 'git' ? { git => $r->{value} } : { url => $r->{value} };
Branch: 1 branch
BranchTrueFalseTotal
$r->{'kind'} eq 'git' ? : 617 30 647
132 647 ▶ unless ( eval { Skilletor::Config->source_fields( $field, 'sources.'.$r->{derivedName} ); 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { "Skilletor::Config"->source_fields($field, 'sources.' . $r->{"derivedName"}); 1 } }) 29 618 647
133 29 my $err = $@;
134 29 ▶ die $err unless blessed $err && $err->isa('Skilletor::Error::Config');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($err) and $err->isa("Skilletor::Error::Config") 0 29 29
Condition33%1/3
builtin::blessed($err) and $err->isa("Skilletor::Error::Config")
!ll&&!rl&&r
0029
MC/DC0%0/2
builtin::blessed($err) and $err->isa("Skilletor::Error::Config")
builtin::blessed($err) $err->isa("Skilletor::Error::Config")
Truth table33%1/3
A and B
A= builtin::blessed($err)B= $err->isa("Skilletor::Error::Config")
ABresult
0X0
100
111
135 29 _fail( $key.': "'.$entry.'" cannot be added as a source: '.$err->message );
136 }
137 return {
138 type => $type,
139 entry => $entry,
140 name => $name,
141 spec => $spec,
142 url => $r->{value},
143 kind => $r->{kind},
144 derivedName => $r->{derivedName},
145 618 };
146 }
147  
148 915 ▶sub parse_bundle {
Subroutine parse_bundle: called CC=18 SCAR=29.0
Pod documented
149 915 my ( $text ) = @_;
150 915 my $data;
151 915 ▶ unless ( eval { $data = parse_yaml_document($text); 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $data = parse_yaml_document($text); 1 } }) 150 765 915
152 150 my $err = $@;
153 150 ▶ _fail( $err->message ) if blessed $err && $err->isa('Skilletor::Error::Frontmatter');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($err) and $err->isa("Skilletor::Error::Frontmatter") 150 0 150
Condition33%1/3
builtin::blessed($err) and $err->isa("Skilletor::Error::Frontmatter")
!ll&&!rl&&r
00150
MC/DC0%0/2
builtin::blessed($err) and $err->isa("Skilletor::Error::Frontmatter")
builtin::blessed($err) $err->isa("Skilletor::Error::Frontmatter")
Truth table33%1/3
A and B
A= builtin::blessed($err)B= $err->isa("Skilletor::Error::Frontmatter")
ABresult
0X0
100
111
154 0 die $err;
155 }
156 765 for my $key ( keys %$data ) {
157 1515 ▶ _fail( 'unknown key "'.$key.'" (allowed: '.join( ', ', @KEYS ).')' ) unless $KEY{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $KEY{$key} 18 1497 1515
158 }
159 747 my $description = $data->{description};
160 747 ▶ _fail('description is required (a string)') unless defined $description && _is_string($description) && js_trim($description) ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $description and _is_string($description) and js_trim($description) ne "" 15 732 747
Condition100%6/6
defined $description and _is_string($description) and js_trim($description) ne ""
!ll&&!rl&&r
141732
defined $description and _is_string($description)
!ll&&!rl&&r
113733
MC/DC100%3/3
defined $description and _is_string($description) and js_trim($description) ne ""
defined $description _is_string($description) js_trim($description) ne ""
Truth table100%4/4
A and B and C
A= defined $descriptionB= _is_string($description)C= js_trim($description) ne ""
ABCresult
0XX0
10X0
1100
1111
161 732 my %def = ( description => $description, items => [], foreign => [], bundles => [], vars => js_ordered() );
162 732 my @pairs = @TYPE_KEYS;
163 732 ▶ while ( my ( $key, $type ) = splice @pairs, 0, 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@pairs, 0, 2)) 2162 687 2849
164 2162 for my $entry ( @{ _string_list( $data->{$key}, $key ) } ) {
165 739 ▶ if ( index( $entry, '@' ) >= 0 ) { push @{ $def{foreign} }, _foreign_entry( $type, $entry, $key ) }
Branch: 1 branch
BranchTrueFalseTotal
if (index($entry, '@') != -1) { } 654 85 739
166 85 else { push @{ $def{items} }, { type => $type, entry => $entry } }
167 }
168 }
169 687 for my $name ( @{ _string_list( $data->{bundles}, 'bundles' ) } ) {
170 29 ▶ _fail( 'bundles: "'.$name.'" must be a bare name of this source' ) if index( $name, '@' ) >= 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($name, "\@") != -1 2 27 29
171 27 ▶ _fail( 'bundles: "'.$name.'": patterns over bundle names are not supported' ) if is_pattern($name);
Branch: 1 branch
BranchTrueFalseTotal
if is_pattern($name) 2 25 27
172 25 push @{ $def{bundles} }, $name;
173 }
174 682 my $vars = $data->{vars};
175 682 ▶ if ( defined $vars ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vars) 15 667 682
176 15 ▶ _fail('vars must be a mapping') unless ref $vars eq 'HASH' && !blessed $vars;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $vars eq "HASH" and not builtin::blessed($vars) 4 11 15
Condition66%2/3
ref $vars eq "HASH" and not builtin::blessed($vars)
!ll&&!rl&&r
4011
MC/DC50%1/2
ref $vars eq "HASH" and not builtin::blessed($vars)
ref $vars eq "HASH" not builtin::blessed($vars)
Truth table66%2/3
A and not(B)
A= ref $vars eq "HASH"B= not builtin::blessed($vars)
ABresult
0X0
100
111
177 11 $def{vars} = _plain($vars);
178 }
179 678 return \%def;
180 }
181  
182 #### Expansion (spec §15.2) ############################################
183  
184 4 ▶sub _label_path { join '/', @{ $_[0] } }
Subroutine _label_path: called CC=1 SCAR=0.0
185  
186 653 ▶sub expand_bundle {
Subroutine expand_bundle: called CC=2 SCAR=6.9
Pod documented
187 653 my ( $cat, $name ) = @_;
188 653 my %by_name = map { ( $_->{name} => $_ ) } @{ $cat->{bundles} };
189 653 my ( %members, @order );
190 653 my $out = { items => [], foreign => [], warnings => [] };
191  
192 653 my $visit;
193 663 ▶ $visit = sub {
Subroutine __ANON__: called CC=16 SCAR=27.7
194 663 my ( $bundle, $path, $outer ) = @_;
195 663 my $cb = $by_name{$bundle};
196 663 ▶ my $where = @$path ? 'bundle '.$bundle.' (included by '.$path->[-1].')' : 'bundle '.$bundle;
Branch: 1 branch
BranchTrueFalseTotal
@$path ? : 10 653 663
197 663 ▶ _fail( $where.' not found' ) unless $cb;
Branch: 1 branch
BranchTrueFalseTotal
unless $cb 2 661 663
198 661 ▶ _fail( $where.': '.$cb->{error} ) if defined $cb->{error};
Branch: 1 branch
BranchTrueFalseTotal
if defined $cb->{"error"} 32 629 661
199 629 my $here = [ @$path, $bundle ];
200 629 my $def = $cb->{def};
201 # Inner vars first, then the outer chain on top: the outer bundle wins.
202 629 my $chain = { path => $here, vars => js_ordered( map { ( $_ => $def->{vars}{$_} ) } keys %{ $def->{vars} } ), setters => {} };
203 629 $chain->{setters}{$_} = $bundle for keys %{ $def->{vars} };
204 629 ▶ if ($outer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outer) 8 621 629
205 8 $chain->{vars}{$_} = $outer->{vars}{$_} for keys %{ $outer->{vars} };
206 8 $chain->{setters}{$_} = $outer->{setters}{$_} for keys %{ $outer->{setters} };
207 }
208 629 for my $it ( @{ $def->{items} } ) {
209 27 my $found = match_entry( $cat, $it->{type}, $it->{entry} );
210 27 my $miss = entry_miss( $it->{type}, $it->{entry}, scalar @$found );
211 27 ▶ push @{ $out->{warnings} }, { bundle => $bundle, message => $miss } if defined $miss;
Branch: 1 branch
BranchTrueFalseTotal
if defined $miss 2 25 27
212 27 for my $ci (@$found) {
213 26 my $key = $ci->{type}.'/'.$ci->{name};
214 26 ▶ unless ( $members{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($members{$key}) 24 2 26
215 24 $members{$key} = { type => $ci->{type}, name => $ci->{name}, chains => [] };
216 24 push @order, $key;
217 }
218 26 my $m = $members{$key};
219 26 ▶ push @{ $m->{chains} }, $chain unless grep { _label_path( $_->{path} ) eq _label_path($here) } @{ $m->{chains} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {_label_path($_->{"path"}) eq _label_path($here);} @{$$m{"chains"};} 26 0 26
220 }
221 }
222 629 push @{ $out->{foreign} }, { %$_, chain => $chain } for @{ $def->{foreign} };
223 629 for my $inner ( @{ $def->{bundles} } ) {
224 11 my ($at) = grep { $here->[$_] eq $inner } 0 .. $#$here;
225 11 ▶ _fail( 'bundle cycle '.join( " \x{2192} ", @{$here}[ $at .. $#$here ], $inner ) ) if defined $at;
Branch: 1 branch
BranchTrueFalseTotal
if defined $at 1 10 11
226 10 $visit->( $inner, $here, { %$chain, path => $here } );
227 }
228 653 };
229 653 my $ok = eval { $visit->( $name, [], undef ); 1 };
230 653 my $err = $@;
231 653 undef $visit; # the closure refers to itself
232 653 ▶ die $err unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 35 618 653
233 618 $out->{items} = [ map { $members{$_} } @order ];
234 618 return $out;
235 }
236  
237 403 1;
238  
239 __END__
« lib/Skilletor/Source/Url.pm ↑ Summary lib/Skilletor/CLI.pm »