MCMockDependency.st
changeset 100 187cf0de502a
child 246 190bb2979dad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCMockDependency.st	Wed Nov 22 14:19:27 2006 +0100
@@ -0,0 +1,91 @@
+"{ Package: 'stx:goodies/monticello' }"
+
+Object subclass:#MCMockDependency
+	instanceVariableNames:'name children hasResolution'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Monticello-Mocks'
+!
+
+
+!MCMockDependency class methodsFor:'instance creation'!
+
+fromTree: anArray 
+	^ self new initializeWithTree: anArray
+! !
+
+!MCMockDependency methodsFor:'accessing'!
+
+children
+	^ children collect: [:ea | self class fromTree: ea]
+!
+
+initializeWithTree: expr
+	expr isSymbol
+		ifTrue: [name _ expr.
+				children _ Array new.
+				hasResolution _ true.]
+		ifFalse: [name _ expr first.
+				expr second isSymbol
+					ifTrue: [hasResolution _ false.
+							children _ Array new]
+					ifFalse: [hasResolution _ true.
+							children _ expr second]]
+!
+
+name
+	^ name
+! !
+
+!MCMockDependency methodsFor:'comparing'!
+
+= other
+	^ self name = other name
+!
+
+hash
+	^ self name hash
+! !
+
+!MCMockDependency methodsFor:'mocks'!
+
+mockVersionInfo
+	^ MCVersionInfo
+		name: self name
+		id: (self uuidForName: name)
+		message: ''
+		date: nil
+		time: nil
+		author: ''
+		ancestors: #()
+!
+
+uuidForName: aName 
+	| nm id |
+	nm := aName asString.
+	id := '00000000-0000-0000-0000-0000000000' 
+				, (nm size = 1 ifTrue: [nm , '0'] ifFalse: [nm]).
+	^UUID fromString: id
+! !
+
+!MCMockDependency methodsFor:'resolving'!
+
+hasResolution
+	^ hasResolution
+!
+
+resolve
+	^ self hasResolution
+		ifTrue: [MCVersion new
+					setPackage: MCSnapshotResource mockPackage
+					info: self mockVersionInfo
+					snapshot: MCSnapshotResource current snapshot
+					dependencies: self children]
+		ifFalse: [nil]
+! !
+
+!MCMockDependency class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCMockDependency.st,v 1.1 2006-11-22 13:19:27 cg Exp $'
+! !