Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 72 lines (59 sloc) 1.7 kb
3c5cea0d »
2009-05-14 [Ecosystem] factored out project-related info
1 class Ecosystem;
2
252db76b »
2009-05-17 refactored make_pir_modules, added is-installed($project) to Ecosystem
3 has $projects-dir; # no twigil because ?
3c5cea0d »
2009-05-14 [Ecosystem] factored out project-related info
4 has %!project-info;
5
6 method new(:$projects-dir!) {
7 self.bless(
7b2103a6 »
2009-05-31 New branch bleeding for tracking features of bleeding Rakudo
8 self.CREATE(),
3c5cea0d »
2009-05-14 [Ecosystem] factored out project-related info
9 projects-dir => $projects-dir,
10 project-info => load-project-list('projects.list'),
11 );
12 }
13
14 method contains-project($project) {
15 # RAKUDO: :exists [perl #59794]
16 return %!project-info.exists($project);
17 }
18
19 method get-info-on($project) {
20 return %!project-info{$project};
21 }
22
23 method regular-projects() {
24 return %!project-info.keys.grep:
25 { !%!project-info{$_}.exists('type')
26 || !(%!project-info{$_}<type> eq 'pseudo'|'bootstrap') };
27 }
28
29 method installed-projects() {
30 return self.regular-projects.grep: { "$projects-dir/$_" ~~ :d };
31 }
32
33 method uninstalled-projects() {
34 return self.regular-projects.grep: { "$projects-dir/$_" !~~ :d };
35 }
36
252db76b »
2009-05-17 refactored make_pir_modules, added is-installed($project) to Ecosystem
37 method is-installed( Str $project ) {
38 return "$projects-dir/$project" ~~ :d;
39 }
40
3c5cea0d »
2009-05-14 [Ecosystem] factored out project-related info
41 sub load-project-list(Str $filename) {
42 my $fh = open($filename)
43 or die "Can't open '$filename': $!";
44
45 my %overall;
46 my $current-name;
47 my %current;
48 for $fh.lines {
49 when / ^ \s* ['#' | $ ] / { next };
50 when / ^ (\S+) \: \s* ['#' | $ ] / {
51 if $current-name.defined {
52 %overall{$current-name} = %current.clone;
53 }
54 %current = ();
55 $current-name = ~$0;
56 }
57 when / ^ \s+ (\S+) ':' \s* (\S+) \s* ['#' | $ ] / {
58 %current{~$0} = ~$1;
59 }
60 default {
61 warn "don't know how to parse the line «$_», ignoring it"
62 }
63 }
64 if %current {
65 %overall{$current-name} = %current;
66 }
67
68 return %overall;
69 }
70
71 # vim: ft=perl6
Something went wrong with that request. Please try again.