[Pkg] Sake : Sake-Core-kph.108.mcz

squeak-dev-noreply at lists.squeakfoundation.org squeak-dev-noreply at lists.squeakfoundation.org
Fri Jul 3 02:37:14 UTC 2009


A new version of Sake-Core was added to project Sake :
http://www.squeaksource.com/Sake/Sake-Core-kph.108.mcz

==================== Summary ====================

Name: Sake-Core-kph.108
Author: kph
Time: 3 July 2009, 3:37:12 am
UUID: f04a1c2f-813d-46ba-9df4-363a33a5a851
Ancestors: Sake-Core-kph.107

+ tasks are always realised through tasksFromList:
+ The setOfTasks is propagated to actions as well as priors, enabling actions dependents to work
+ what handles dependency loops better

=============== Diff against Sake-Core-kph.107 ===============

Item was changed:
  ----- Method: SakeTask>>hasRun (in category 'as yet unclassified') -----
  hasRun
  
+ 	^ hasRun = true!
- 	^ hasRun ifNil: [ false ]!

Item was changed:
  ----- Method: SakeTask>>tasksFromList: (in category 'as yet unclassified') -----
  tasksFromList: list
   			 
+ 	| newTask |
+ 	^ (list ifNil: [ ^ #()]) collect: [ :task | 
+ 		
+ 			newTask := (self taskFrom: task) withExtensions.
+ 			
+ 			(setOfTasks like: newTask) ifNil: [ setOfTasks add: newTask ].
+ 	
+ 		]
- 	^ (list ifNil: [ ^ #()]) collect: [ :task | (self taskFrom: task) withExtensions ]
  	 
  	 !

Item was added:
+ ----- Method: SakeTask>>privateRun (in category 'as yet unclassified') -----
+ privateRun
+ 
+ 	| priorTasks blocked wasBlocked |
+ 	
+  	"this is the way that Rake orders tasks"
+ 	
+ 	"we ensure that we obtain the task to run from the overall set of tasks"
+ 	
+ 	self hasRun ifTrue: [ ^ result ].
+ 	
+ 	priorTasks := self tasksFromList: self dependsOn.
+ 
+ 	"anyting it runs that is blocked is added to the block set, anything that suceeds is removed form the blocked set.
+ 	at the end, we shall have a list of blocked tasks that can be retried, if that list is the same as the list that was blocked
+ 	before stop and complain"
+ 	
+ 	blocked := Set new.	
+ 
+ 	[		
+ 		wasBlocked := blocked copy.
+ 
+ 		priorTasks do: [ :each | 
+ 			each runLevel: runLevel. 
+ 			[ 
+ 				each useSetOfTasks: setOfTasks during: [ each privateRun].
+ 				blocked remove: each ifAbsent: [ ].
+ 			] on: SakeBlock do: [ :ex | blocked add: ex task ].
+ 		].
+ 
+ 		(blocked notEmpty and: [ blocked = wasBlocked ]) ifTrue: [ SakeBlock signalTask: self ].
+   
+ 	] doWhileFalse: [ blocked isEmpty ].
+ 
+ 	
+ 	(self isNeeded: priorTasks) 
+ 		ifTrue: [ 
+ 			self trace. 
+ 			self doAction: priorTasks.
+ 			self hasRunSet.
+ 			 
+ 			^ result.
+ 		].
+ 	
+ 	^ false
+  !

Item was changed:
  ----- Method: SakeTask>>what (in category 'coercion') -----
  what
  
+ 	^ self whatOn: Set new!
- 	| what |
- 	what := SakeWhat new.
- 	
- 	what task: self.
- 	
- 	ifBlock ifNotNil: [
- 		( ifBlock isBlock ) 
- 			ifTrue: [ what if: ifBlock decompileString ]
- 			ifFalse: [ 
- 				what if: ((self tasksFromList: ifBlock) collect: [ :ea | ea what ]).
- 			].
-  	].
-  
- 	what prior: (self priorTasks collect: [ :ea | ea what ]).
- 
- 	(self action respondsTo: #decompileString) 
- 		ifTrue: [ what action: self action decompileString ]
- 		ifFalse: [ 
- 			what action: ((self tasksFromList: self action) collect: [ :ea | ea what ]).
- 		].
- 	
- 	^ what!

Item was added:
+ ----- Method: SakeTask>>whatOn: (in category 'coercion') -----
+ whatOn: set
+ 
+ 	| what |
+ 	what := SakeWhat new.
+ 	
+ 	set add: self.
+ 	
+ 	what task: self.
+ 	
+ 	ifBlock ifNotNil: [
+ 		( ifBlock isBlock ) 
+ 			ifTrue: [ what if: ifBlock decompileString ]
+ 			ifFalse: [ 
+ 				what if: ((self tasksFromList: ifBlock) collect: [ :ea | 
+ 					ea whatOn: set ]).
+ 			].
+  	].
+  
+ 	what prior: (self priorTasks collect: [ :ea | (set includes: ea) ifFalse: [ ea whatOn: set ]]).
+ 
+ 	(self action respondsTo: #decompileString) 
+ 		ifTrue: [ what action: self action decompileString ]
+ 		ifFalse: [ 
+ 			what action: ((self tasksFromList: self action) collect: [ :ea | ea whatOn: set ]).
+ 		].
+ 	
+ 	^ what!

Item was added:
+ ----- Method: SakeTask>>useSetOfTasks:during: (in category 'as yet unclassified') -----
+ useSetOfTasks: aSetOfTasks during: aBlock
+ 
+ 	| old |
+ 	
+ 	[
+ 	old := setOfTasks.
+ 		
+ 	setOfTasks := aSetOfTasks.
+ 	
+ 	^ aBlock value.
+ 	
+ 	]	ensure: [ setOfTasks := old ].!

Item was changed:
  Object subclass: #SakeTask
+ 	instanceVariableNames: 'args context info priors ifBlock actionBlock answers hasRun result runLevel target author setOfTasks'
- 	instanceVariableNames: 'args context info priors ifBlock actionBlock answers hasRun result runLevel target author'
  	classVariableNames: 'LastStatus Count'
  	poolDictionaries: ''
  	category: 'Sake-Core'!
  SakeTask class
  	instanceVariableNames: 'status'!
  
  !SakeTask commentStamp: 'kph 4/22/2008 22:42' prior: 0!
  SakeTasks are typically defined as class side methods, which return an instance of SakeTask.
  
  To obtain a list of available tasks, do "Senders of #define: "
  
  MyClass-task1: aParameter
  
  	^ SakeTask define: [ :task |
  		 	task dependsOn: {self ruleL3.}.
  			task if: [ <return true if action is needed> ].
  	     	task action: [ <do something> ]
  	  ]
  
  The 'unique id' of a task is the method context in which it is instanciated, and its paramters.
  Therefore only one task should be instanciated per method.
  
  Note: Sake tasks can have parameters, Rake tasks dont.
  
  To execute a task...
  
  (MyClass task1: 'param') run.
  
  Results of the prior tasks are available via #results.
  
  FAQ
  ====
  How can I call one Sake task from inside another task?
  
  Generally, if you want invoke one task from another task, the proper way to do that is to include the task to be invoked as a prerequisite of the task doing the invoking.
  
  For example:
  
  MyTasks-c-#taskPrimary
  
  ^ SakeTask define: [ :task |
  	task dependsOn: { self taskSecondary }.
  	task action: [ self log sake: 'Doing Primary Task'. ].
  ]
  
  MyTasks-c-#taskSecondary
  ^ SakeTask define: [ :task |
  	task action: [ self log sake: 'Doing Secondary Task' ].
  ]
  
  In this case, if the secondary task fails, the whole task stops. 
  
  Secondary tasks can also be passed to the ifBlock. In that case, if the task succeeds then the action is performed, if the task fails then the action is considered not needed.
  
  ^ SakeTask define: [ :task |
  	task if: { self taskSecondary }.
  	task action: [ self log sake: 'Doing Primary Task'. ].
  ]
  
  Action, can also take a list of tasks.	
  	
  ^ SakeTask define: [ :task |
  	task action: {
  	                 self taskSecondary. 
  	                 [ self log sake: 'Doing Primary Task' ].  "a block task"
  				} 
  ].
  	
  	
  !

Item was changed:
  ----- Method: SakeTask>>doTasks: (in category 'as yet unclassified') -----
  doTasks: list
  
+ 	(self tasksFromList: list) do: [ :task | 
+ 		task useSetOfTasks: setOfTasks during: [ 
+ 			result := task perform: runLevel 
+ 		].
+ 	].
- 	(self tasksFromList: list) do: [ :task | result := task perform: runLevel ].
  	
   !

Item was changed:
  ----- Method: SakeTask>>runInteractively (in category 'running') -----
  runInteractively
  
  	runLevel ifNil: [ runLevel := #runInteractively ].
  
+ 	^ self useSetOfTasks: (setOfTasks ifNil: [ self withAllPriorTasks ]) during: [ self privateRun ]!
- 	^ self privateRun: (self withAllPriorTasks)!

Item was added:
+ ----- Method: SakeTask>>hasRunSet (in category 'as yet unclassified') -----
+ hasRunSet
+ 
+ 	hasRun := true!

Item was removed:
- ----- Method: SakeTask>>privateRun: (in category 'as yet unclassified') -----
- privateRun: setOfTasks
- 
- 	| priorTasks blocked wasBlocked |
- 	
-  	"this is the way that Rake orders tasks"
- 	
- 	"we ensure that we obtain the task to run from the overall set of tasks"
- 	
- 	self hasRun ifTrue: [ ^ result ].
- 		
- 	priorTasks := self dependsOn collect: [ :prior | setOfTasks like: (self taskFrom: prior) ] thenSelect: [ :ea | ea notNil ].
- 
- 	"anyting it runs that is blocked is added to the block set, anything that suceeds is removed form the blocked set.
- 	at the end, we shall have a list of blocked tasks that can be retried, if that list is the same as the list that was blocked
- 	before stop and complain"
- 	
- 	blocked := Set new.	
- 
- 	[		
- 		wasBlocked := blocked copy.
- 
- 		priorTasks do: [ :each | 
- 			each runLevel: runLevel. 
- 			[ 
- 				each privateRun: setOfTasks.
- 				blocked remove: each ifAbsent: [ ].
- 			] on: SakeBlock do: [ :ex | blocked add: ex task ].
- 		].
- 
- 		(blocked notEmpty and: [ blocked = wasBlocked ]) ifTrue: [ SakeBlock signalTask: self ].
-   
- 	] doWhileFalse: [ blocked isEmpty ].
- 
- 	
- 	(self isNeeded: priorTasks) 
- 		ifTrue: [ 
- 			self trace. 
- 			self doAction: priorTasks.
- 			hasRun := true.
- 			 
- 			^ result.
- 		].
- 	
- 	^ false
-  !



More information about the Packages mailing list