before it also tried to test them, and transfer (non-existant) dependency
information and description both of which are (probably) wrong because
you just want to modify that code snippet to fit current dataset
my $dir = $self->_code_dir;
my $snippets;
+ my $no_deps;
foreach my $full_path ( glob("$dir/*.pl") ) {
my $path = $full_path;
my $found = -1;
$found += $columns->{$_} foreach @deps;
warn "# depends $depends $found $#deps\n";
- next unless $found == $#deps || $self->param('all_code');
+
+ if ( $found != $#deps ) {
+ $self->param('all_code') ? $no_deps->{$depends}->{$description}++ : next;
+ }
$snippets->{$depends}->{$description} = read_file $full_path, binmode => ':utf8';
}
+warn "# no_deps ",dump($no_deps);
+
$self->render(
snippets => $snippets,
+ no_deps => $no_deps,
);
}
<h2><%= $depends %></h2>
<ul>
% foreach my $desc ( keys %{ $snippets->{$depends} } ) {
+% my $have_deps = ! exists $no_deps->{$depends}->{$desc};
<li>
<form method=post action=/data/items>
-<input type=submit name=test value="Load and test">
+<input type=submit name=test value="<%= $have_deps ? 'Load and test' : 'Load' %>">
% my $path = "$depends.$desc.pl";
<a target=code href="/code/<%= $path %>"><%= $desc %></a>
+% if ( $have_deps ) {
<input type=hidden name=code_depends value="<%= $depends %>">
<input type=hidden name=code_description value="<%= $desc %>">
+% }
<a class=remove href="<%= url_for( action => 'remove' )->query( path => $path ) %>">remove</a>
<br>
% my $code = $snippets->{$depends}->{$desc};