File Coverage

blib/lib/App/chot/Found.pm
Criterion Covered Total %
statement 5 18 27.7
branch n/a
condition 0 2 0.0
subroutine 2 7 28.5
pod 0 5 0.0
total 7 32 21.8


line stmt bran cond sub pod time code
1             package App::chot::Found;
2 1     1   9 use v5.14;
  1         3  
3 1     1   3 use warnings;
  1         1  
  1         194  
4              
5             =head1 DESCRIPTION
6              
7             Accumulates paths found by each finder during a single C invocation.
8             Replaces the former C<$App::chot::_found_paths> package global.
9              
10             Passed to all finder instances so that later finders (e.g., Python) can
11             see paths found by earlier ones (e.g., Command) for shebang-based
12             interpreter discovery.
13              
14             =cut
15              
16             sub new {
17 0     0 0   my $class = shift;
18 0           bless {
19             paths => [], # all paths found so far (across finders)
20             types => [], # finder types that found results, in order
21             finder_paths => {}, # per-finder results: { type => [@paths] }
22             }, $class;
23             }
24              
25             #
26             # Accessors (return arrayrefs)
27             #
28 0     0 0   sub paths { $_[0]{paths} }
29 0     0 0   sub types { $_[0]{types} }
30              
31             #
32             # Record results from a finder.
33             # Called by the main loop after each successful get_path().
34             #
35             sub add {
36 0     0 0   my($self, $type, @paths) = @_;
37 0           push @{$self->{paths}}, @paths;
  0            
38 0           push @{$self->{types}}, $type;
  0            
39 0           $self->{finder_paths}{$type} = [@paths];
40             }
41              
42             #
43             # Retrieve paths found by a specific finder type.
44             # e.g., $found->paths_for('Perl') returns Perl finder's paths only.
45             #
46             sub paths_for {
47 0     0 0   my($self, $type) = @_;
48 0   0       @{$self->{finder_paths}{$type} // []};
  0            
49             }
50              
51             1;