Question about ConfigurationOf...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about ConfigurationOf...

Juan Pablo Sandoval
Hi,

I am trying to list all MCWorkingCopy of a ConfigurationOf...

packageNames := ConfigurationOf... project versions last
defaultPackageNamesToLoad select: [ : p | (p = 'default') not].
mcWorkingCopies := packageNames collect: [ :aPackageName|
MCWorkingCopy allManagers
                detect: [ :each | aPackageName = each packageName ]
                ifNone: [ self error: 'Working copy for ' , self name , ' not
found' ]
].

But this only works for some configurations.
I hope that someone can help me XD

Regards and thanks in advance,
Juan Pablo
Reply | Threaded
Open this post in threaded view
|

Re: Question about ConfigurationOf...

Dale Henrichs
Juan,

I assume that when an error is thrown, it is because you get a group name into the mix?

In Metacello, the list of package names is not always restricted to mc package names ... group names (or an alias for a list of internal package names) and project names (an alias for the an external list of package names) may be included.

The list #defaultPackageNamesToLoad is not (yet) resolved to a list of mc packages.

If you want the working copies for all of the mc packages for a particular version, the following should do the trick:

  ConfigurationOfMetacello project versions last packages
    collect: [:packageSpec | packageSpec workingCopy ].

This should work for all configurations.

If you want to restrict the set of mc package to those that would be loaded for a particular group or package, then something like the following should work:

  | version packages packagesAndProjects |
  version := ConfigurationOfMetacello project versions last.
  packages := version packages.
  packagesAndProjects := version resolveToLoadableSpecs: #('default').
  (packagesAndProjects select: [:spec | packages includes: spec ])
    collect: [:packageSpec | packageSpec workingCopy].

If you want to expand the list of packages to include packages loaded by required projects, then you should start looking at using #record: and traversing the directives list (package specs are associated with directives...).

Hope this helps,

Dale
----- Original Message -----
| From: "Juan Pablo" <[hidden email]>
| To: "Metacello" <[hidden email]>
| Sent: Friday, February 24, 2012 5:16:38 PM
| Subject: [Metacello] Question about ConfigurationOf...
|
| Hi,
|
| I am trying to list all MCWorkingCopy of a ConfigurationOf...
|
| packageNames := ConfigurationOf... project versions last
| defaultPackageNamesToLoad select: [ : p | (p = 'default') not].
| mcWorkingCopies := packageNames collect: [ :aPackageName|
| MCWorkingCopy allManagers
| detect: [ :each | aPackageName = each packageName ]
| ifNone: [ self error: 'Working copy for ' , self name , ' not
| found' ]
| ].
|
| But this only works for some configurations.
| I hope that someone can help me XD
|
| Regards and thanks in advance,
| Juan Pablo
|