base/Metacello.st
changeset 10 fd87600067b8
parent 1 9e312de5f694
child 11 d354ac2af7ec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/Metacello.st	Mon Sep 10 20:55:47 2012 +0000
@@ -0,0 +1,259 @@
+"{ Package: 'stx:goodies/metacello' }"
+
+Object subclass:#Metacello
+	instanceVariableNames:'executorSpec statements'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Metacello-Base'
+!
+
+
+!Metacello class methodsFor:'instance creation'!
+
+classic
+    "set the options such that the load performed will be identical to the classic ConfigurationOf load:
+	(ConfigurationOfExample project version: '1.0') load
+	
+	#classic forces Metacello to look at image state to determine which version of a project is loaded instead of using
+		the registry to tell us explicitly which version of a project is loaded .. image state is not PRECISE"
+
+    "useCurrentVersion is a 'private' option for enforcing classic rules, so it's not part of scripting api"
+
+    ^ self new
+        onUpgrade: [ :ex | ex allow ];
+        onConflict: [ :ex | ex allow ];
+        addStatement: #'useCurrentVersion:' args: {true};
+        yourself
+!
+
+image
+    ^ self new
+        executorSpec: #'MetacelloScriptImageExecutor' -> 'batch';
+        yourself
+!
+
+registry
+    ^ self new
+        executorSpec: #'MetacelloScriptRegistryExecutor' -> 'batch';
+        yourself
+! !
+
+!Metacello class methodsFor:'private'!
+
+scriptExecutorClass
+    ^ self scriptExecutorClass: {(#'MetacelloScriptApiExecutor' -> 'batch')}
+!
+
+scriptExecutorClass: anExecutorSpec
+    Smalltalk at: anExecutorSpec key ifAbsent: [ ConfigurationOf ensureMetacello: anExecutorSpec value ].
+    ^ Smalltalk at: anExecutorSpec key
+! !
+
+!Metacello methodsFor:'accessing'!
+
+executorSpec
+    executorSpec ifNil: [ executorSpec := #'MetacelloScriptApiExecutor' -> 'batch' ].
+    ^ executorSpec
+!
+
+executorSpec: anAssoc
+    executorSpec := anAssoc
+!
+
+scriptExecutor
+    ^ (self class scriptExecutorClass: self executorSpec) new
+!
+
+statements
+    statements ifNil: [ statements := OrderedCollection new ].
+    ^ statements
+!
+
+statements: anObject
+	statements := anObject
+! !
+
+!Metacello methodsFor:'api actions'!
+
+fetch
+    self addStatement: #'fetch:' args: #(#()).
+    ^ self execute
+!
+
+fetch: required
+    self addStatement: #'fetch:' args: {required}.
+    ^ self execute
+!
+
+get
+    "resolve project name in given repository and return an instance of MetacelloProject resolved from a ConfigurationOf or BaselineOf"
+
+    self addStatement: #'get' args: #().
+    ^ self execute
+!
+
+list
+    "list projects in registry"
+
+    self addStatement: #'list' args: #().
+    ^ self execute
+!
+
+load
+    self addStatement: #'load:' args: #(#()).
+    ^ self execute
+!
+
+load: required
+    self addStatement: #'load:' args: {required}.
+    ^ self execute
+!
+
+lock
+    "lock projects in registry"
+
+    self addStatement: #'lock' args: #().
+    ^ self execute
+!
+
+record
+    self addStatement: #'record:' args: #(#()).
+    ^ self execute
+!
+
+record: required
+    self addStatement: #'record:' args: {required}.
+    ^ self execute
+!
+
+unlock
+    "unlock projects in registry"
+
+    self addStatement: #'unlock' args: #().
+    ^ self execute
+! !
+
+!Metacello methodsFor:'api options'!
+
+cacheRepository: aRepositoryDescription
+    self addStatement: #'cacheRepository:' args: {aRepositoryDescription}
+!
+
+ignoreImage
+    "ignore image state"
+
+    self addStatement: #'ignoreImage:' args: {true}
+!
+
+onConflict: aBlock
+    self addStatement: #'onConflict:' args: {aBlock}
+!
+
+onDowngrade: aBlock
+    self addStatement: #'onDowngrade:' args: {aBlock}
+!
+
+onUpgrade: aBlock
+    self addStatement: #'onUpgrade:' args: {aBlock}
+!
+
+repositoryOverrides: aRepositoryDescriptionCollection
+    self addStatement: #'repositoryOverrides:' args: {aRepositoryDescriptionCollection}
+!
+
+silently
+    "no progress bars"
+
+    self addStatement: #'silently:' args: {true}
+! !
+
+!Metacello methodsFor:'api projectSpec'!
+
+baseline: projectName
+    self addStatement: #'baselineArg:' args: {projectName}
+!
+
+className: className
+    self addStatement: #'classNameArg:' args: {className}
+!
+
+configuration: projectName
+    self addStatement: #'configurationArg:' args: {projectName}
+!
+
+project: projectName
+    self addStatement: #'projectArg:' args: {projectName}
+!
+
+repository: repositoryDescription
+    self addStatement: #'repositoryArg:' args: {repositoryDescription}
+!
+
+version: versionString
+    self addStatement: #'versionArg:' args: {versionString}
+! !
+
+!Metacello methodsFor:'api repository shortcuts'!
+
+blueplane: projectName
+    self repository: 'http://squeaksource.blueplane.jp/' , projectName
+!
+
+croquet: projectName
+    self repository: 'http://hedgehog.software.umn.edu:8888/' , projectName
+!
+
+gemsource: projectName
+    self repository: 'http://seaside.gemstone.com/ss/' , projectName
+!
+
+impara: projectName
+    self repository: 'http://source.impara.de/' , projectName
+!
+
+renggli: projectName
+    self repository: 'http://source.lukas-renggli.ch/' , projectName
+!
+
+saltypickle: projectName
+    self repository: 'http://squeak.saltypickle.com/' , projectName
+!
+
+squeakfoundation: projectName
+    self repository: 'http://source.squeakfoundation.org/' , projectName
+!
+
+squeaksource3: projectName
+    self repository: 'http://ss3.gemstone.com/ss/' , projectName
+!
+
+squeaksource: projectName
+    self repository: 'http://www.squeaksource.com/' , projectName
+!
+
+ss3: projectName
+    self squeaksource3: projectName
+!
+
+wiresong: projectName
+    self repository: 'http://source.wiresong.ca/' , projectName
+! !
+
+!Metacello methodsFor:'private'!
+
+addStatement: selector args: args
+    self statements add: selector -> args
+!
+
+execute
+    | script |
+    script := self statements.
+    self statements: nil.
+    ^ self scriptExecutor execute: script
+! !
+
+!Metacello class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id::                                                                                                                        $'
+! !