Skip to content

Commit

Permalink
Reorder methods and annotate
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Apr 14, 2015
1 parent ba38b45 commit c379643
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions lib/Module/Path/Simplify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,39 @@ sub inc {
return @{ $self->{inc} ||= [@INC] };
}

# Iterates @$tries
# and returns a {} if $try[n] is a prefix.
sub _find_in_set {
my ( undef, $path, $tries ) = @_;
my ( $shortest, $match_target );
for my $try ( @{$tries} ) {
next unless $try->valid and my $short = $try->matched_suffix($path);
next if defined $shortest and length $short >= length $shortest;
$shortest = $short;
$match_target = $try;
}
return unless defined $shortest;
return {
relative_path => $shortest,
match_target => $match_target,
};
}

# Private lazy accessor
sub _tests_config {
my ($self) = @_;
return @{ $self->{_tests_config} ||= [ $self->_gen_tests_config ] };
}

# Private lazy accessor
# Cache + saves on first use unless nonfrozen.
sub _tests_inc {
my ($self) = @_;
## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
return @{ $self->{_tests_inc} ||= [ $self->_gen_tests_user_inc( '$INC', [ $self->inc ] ) ] } unless $self->inc_dynamic;
return $self->_gen_tests_user_inc( '$INC', \@INC );
}

sub _gen_tests_config {
my (@try) = (
{ display => 'SA', key => 'sitearch' },
Expand Down Expand Up @@ -155,30 +183,6 @@ sub _gen_tests_user_inc {
} 0 .. $#u_inc;
}

# Cache + saves on first use unless nonfrozen.
sub _tests_inc {
my ($self) = @_;
## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
return @{ $self->{_tests_inc} ||= [ $self->_gen_tests_user_inc( '$INC', [ $self->inc ] ) ] } unless $self->inc_dynamic;
return $self->_gen_tests_user_inc( '$INC', \@INC );
}

sub _find_in_set {
my ( undef, $path, $tries ) = @_;
my ( $shortest, $match_target );
for my $try ( @{$tries} ) {
next unless $try->valid and my $short = $try->matched_suffix($path);
next if defined $shortest and length $short >= length $shortest;
$shortest = $short;
$match_target = $try;
}
return unless defined $shortest;
return {
relative_path => $shortest,
match_target => $match_target,
};
}

sub _abs_unix_path {
my ($path) = @_;
return q{} unless defined $path;
Expand Down

0 comments on commit c379643

Please sign in to comment.