Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

the ecosystem may now suggest projects based on name similarity

currently only compares the names case-insensitively and removes
all -, _ and : before comparing.
  • Loading branch information...
commit 0e28b8183f2c96bd9241356088978bac06618f37 1 parent 6b2cc0d
timo authored
Showing with 15 additions and 2 deletions.
  1. +6 −2 lib/Panda.pm
  2. +9 −0 lib/Panda/Ecosystem.pm
8 lib/Panda.pm
View
@@ -118,8 +118,12 @@ class Panda {
$.ecosystem.add-project($p);
$proj = $p.name;
}
- my $bone = $.ecosystem.get-project($proj)
- or die "Project $proj not found in the ecosystem";
+ my $bone = $.ecosystem.get-project($proj);
+ if not $bone {
+ my $suggestion = $.ecosystem.suggest-project($proj);
+ die "Project $proj not found in the ecosystem. Maybe you meant $suggestion?" if $suggestion;
+ die "Project $proj not found in the ecosystem";
+ }
unless $nodeps {
my @deps = self.get-deps($bone).uniq;
@deps.=grep: {
9 lib/Panda/Ecosystem.pm
View
@@ -73,6 +73,15 @@ class Panda::Ecosystem {
%!projects{$p}
}
+ method suggest-project($p as Str) {
+ my &canonical = *.subst(/ <[\- _ :]>+ /, "", :g);
+ my $cpname = canonical($p);
+ for %!projects.keys {
+ return $_ if canonical($_) eq $cpname;
+ }
+ return Nil;
+ }
+
method project-get-state(Panda::Project $p) {
%!states{$p.name} // Panda::Project::absent
}
Please sign in to comment.
Something went wrong with that request. Please try again.