class library: Volume - remove debug message
[supercollider.git] / SCClassLibrary / Common / Quarks / LocalQuarks.sc
blobaffa3df5642533681a5aeb202dcf91bbc883a620
1 /**
2   *
3   * Subversion based package repository and package manager
4   * a work in progress.  sk, cx, lfsaw
5   *
6   */
8 // Local Quarks are those that have been checked out from the repository.
9 // and are stored in build/quarks prior to being actually installed
11 LocalQuarks
13         classvar >globalPath; // where the "Quarks.global" checkout is stored
15         var <path;
16         var <parent; // the Quarks
17         var all; // contains nil, or all local quarks
19         *new { | path, parent |
20                 ^super.newCopyArgs((path ?? {this.globalPath}), parent)
21         }
23         *globalPath {
24                 ^ globalPath ?? { globalPath = Platform.userAppSupportDir ++ "/quarks"}
25         }
27         name {
28                 ^PathName(path).fileName;
29         }
30         quarks {
31                 var paths, quarks;
32                 all.isNil.if{
33                         // check through each quark in repos/directory
34                         paths = (path ++ "/DIRECTORY/*.quark").pathMatch;
35                         quarks = Array(paths.size);
36                         paths.do { |p|
37                                 try
38                                 { var q = Quark.fromFile(p, parent); quarks add: q }
39                                 { |e| e.errorString.postln }
40                         };
41                         // check paths that do exist locally
42                         all = quarks.select({ |q| (path ++ "/" ++ q.path).pathMatch.notEmpty })
43                 };
44                 ^all
45         }
46         findQuark { arg name, version;
47                 var matches;
48                 matches = this.quarks.select({ |q| q.name == name });
49                 if(version.notNil,{
50                         matches = matches.select({ |q| q.version >= version });
51                 });
52                 ^matches.sort({ |a,b| a.version > b.version }).first
53         }
54         findPath { arg name, version;
55                 var q;
56                 if((q = this.findQuark(name, version)).isNil,{
57                         Error("Local Quark % not Found.".format(name.quote)).throw;
58                 });
59                 ^path ++ "/" ++ q.path;
60         }
61         openFolder { arg name, version;
62                 if(name.isNil) {
63                         openOS(path)
64                 } {
65                         openOS(this.findPath(name, version))
66                 }
67         }
69         /// reread local quarks directory
70         reread {
71                 all = nil;
72                 this.quarks;
73         }
75                 // stupid path has to be escaped above???
76                 // well sometimes you need the raw path...
77         simplePath {
78                 var     out = path.copy;
79                 path.findAll("\\").reverseDo({ |i|
80                         path.removeAt(i);
81                 });
82                 ^path
83         }