Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: adc11251ae
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (59 sloc) 1.7 kb
class Ecosystem;
has $projects-dir; # no twigil because ?
has %!project-info;
method new(:$projects-dir!) {
self.bless(
self.CREATE(),
projects-dir => $projects-dir,
project-info => load-project-list('projects.list'),
);
}
method contains-project($project) {
# RAKUDO: :exists [perl #59794]
return %!project-info.exists($project);
}
method get-info-on($project) {
return %!project-info{$project};
}
method regular-projects() {
return %!project-info.keys.grep:
{ !%!project-info{$_}.exists('type')
|| !(%!project-info{$_}<type> eq 'pseudo'|'bootstrap') };
}
method installed-projects() {
return self.regular-projects.grep: { "$projects-dir/$_" ~~ :d };
}
method uninstalled-projects() {
return self.regular-projects.grep: { "$projects-dir/$_" !~~ :d };
}
method is-installed( Str $project ) {
return "$projects-dir/$project" ~~ :d;
}
sub load-project-list(Str $filename) {
my $fh = open($filename)
or die "Can't open '$filename': $!";
my %overall;
my $current-name;
my %current;
for $fh.lines {
when / ^ \s* ['#' | $ ] / { next };
when / ^ (\S+) \: \s* ['#' | $ ] / {
if $current-name.defined {
%overall{$current-name} = %current.clone;
}
%current = ();
$current-name = ~$0;
}
when / ^ \s+ (\S+) ':' \s* (\S+) \s* ['#' | $ ] / {
%current{~$0} = ~$1;
}
default {
warn "don't know how to parse the line «$_», ignoring it"
}
}
if %current {
%overall{$current-name} = %current;
}
return %overall;
}
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.