MetacelloScriptApiExecutor.st
author jv
Mon, 03 Sep 2012 11:13:41 +0000
changeset 1 9e312de5f694
permissions -rw-r--r--
- Initial commit

"{ Package: 'stx:goodies/metacello' }"

MetacelloScriptExecutor subclass:#MetacelloScriptApiExecutor
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Metacello-Core-Scripts'
!


!MetacelloScriptApiExecutor methodsFor:'execution callback'!

executeBlock: selectBlock do: projectSpecBlock
    (self projectSpecsFromRepositoryArg select: selectBlock)
        do: [ :projectSpec | projectSpecBlock value: (self applyArgsToProjectSpec: projectSpec copy) ]
!

executeCollection: aCollection do: projectSpecBlock
    self projectSpecsFromRepositoryArg
        do: [ :projectSpec | 
            (aCollection includes: (MetacelloScriptEngine baseNameOf: projectSpec className))
                ifTrue: [ projectSpecBlock value: (self applyArgsToProjectSpec: projectSpec copy) ] ]
!

executeString: aString do: projectSpecBlock
    self singleRoot: true.
    (projectSpecGenerator projectSpecCreationBlock value: aString)
        do: [ :projectSpec | projectSpec ifNotNil: [ projectSpecBlock value: (self applyArgsToProjectSpec: projectSpec copy) ] ]
!

projectSpecsFromRepositoryArg
    | spec repo projectSpecs |
    repositoryArg ifNil: [ ^ #() ].
    spec := (projectSpecGenerator projectSpecCreationBlock value: 'xxx') first.
    repo := spec project createRepository: (spec project repositorySpec description: repositoryArg).
    projectSpecs := OrderedCollection new.
    ((Gofer new disablePackageCache
        repository: repo;
        allResolved) collect: [ :resolvedReference | resolvedReference packageName ]) asSet
        do: [ :packageName | 
            (projectSpecGenerator projectSpecCreationBlock value: (MetacelloScriptEngine baseNameOf: packageName))
                do: [ :projectSpec | 
                    projectSpec className = packageName
                        ifTrue: [ projectSpecs add: (self applyArgsToProjectSpec: projectSpec copy) ] ] ].
    ^ projectSpecs
! !

!MetacelloScriptApiExecutor class methodsFor:'documentation'!

version_SVN
    ^ '$Id::                                                                                                                        $'
! !