[squeak-dev] The Inbox: System-ul.495.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 14 16:00:10 UTC 2012


A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-ul.495.mcz

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

Name: System-ul.495
Author: ul
Time: 14 September 2012, 2:47:25.624 pm
UUID: c4133398-9e02-a244-afd6-c90922184a3c
Ancestors: System-ul.494

Extracted author information from Utilities into Author, similar to how it's done in Pharo, but fully backwards compatible. It also has some methods for Pharo compatibility.

=============== Diff against System-ul.494 ===============

Item was added:
+ Object subclass: #Author
+ 	instanceVariableNames: 'initials username'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'System-Support'!
+ Author class
+ 	instanceVariableNames: 'instance'!
+ 
+ !Author commentStamp: 'ul 9/14/2012 14:43' prior: 0!
+ I am responsible for the initials and the name used to identify the current code author.
+ 
+ Instance Variables
+ 	initials:		<String>
+ 	username:		<String>
+ 
+ initials
+ 	- a String conatining the initials of the user. It should consist of ascii alphanumeric characters, because it's being used in method stamps and those are not encoded in the changes and sources files.
+ 
+ username
+ 	- a String containing the name of the current user
+ !
+ Author class
+ 	instanceVariableNames: 'instance'!

Item was added:
+ ----- Method: Author class>>changeStamp (in category 'convenience') -----
+ changeStamp
+ 
+ 	^self current changeStamp!

Item was added:
+ ----- Method: Author class>>changeStampPerSe (in category 'convenience') -----
+ changeStampPerSe
+ 
+ 	^self current changeStampPerSe!

Item was added:
+ ----- Method: Author class>>current (in category 'instance creation') -----
+ current
+ 
+ 	^instance ifNil: [ instance := super new ]!

Item was added:
+ ----- Method: Author class>>fullName (in category 'pharo compatibility') -----
+ fullName
+ 
+ 	^self initials!

Item was added:
+ ----- Method: Author class>>fullNamePerSe (in category 'pharo compatibility') -----
+ fullNamePerSe
+ 
+ 	^self initialsPerSe!

Item was added:
+ ----- Method: Author class>>initialize (in category 'class initialization') -----
+ initialize
+ 
+ 	self current initializeFromUtilities!

Item was added:
+ ----- Method: Author class>>initials (in category 'convenience') -----
+ initials
+ 
+ 	^self current initials!

Item was added:
+ ----- Method: Author class>>initialsPerSe (in category 'convenience') -----
+ initialsPerSe
+ 
+ 	^self current initialsPerSe!

Item was added:
+ ----- Method: Author class>>new (in category 'instance creation') -----
+ new
+ 
+ 	self error: 'Use #current'!

Item was added:
+ ----- Method: Author class>>reset (in category 'instance creation') -----
+ reset
+ 
+ 	instance := nil!

Item was added:
+ ----- Method: Author class>>uniqueInstance (in category 'pharo compatibility') -----
+ uniqueInstance
+ 
+ 	^self current!

Item was added:
+ ----- Method: Author class>>useAuthor:during: (in category 'pharo compatibility') -----
+ useAuthor: aString during: aBlock
+ 	
+ 	^self useInitials: aString during: aBlock!

Item was added:
+ ----- Method: Author class>>useInitials:during: (in category 'convenience') -----
+ useInitials: aString during: aBlock
+ 	
+ 	^self current useInitials: aString during: aBlock!

Item was added:
+ ----- Method: Author class>>username (in category 'convenience') -----
+ username
+ 
+ 	^self current username!

Item was added:
+ ----- Method: Author class>>usernamePerSe (in category 'convenience') -----
+ usernamePerSe
+ 
+ 	^self current usernamePerSe!

Item was added:
+ ----- Method: Author>>changeStamp (in category 'accessing') -----
+ changeStamp
+ 
+ 	^self changeStampWithInitials: self initials!

Item was added:
+ ----- Method: Author>>changeStampPerSe (in category 'accessing') -----
+ changeStampPerSe
+ 
+ 	^self changeStampWithInitials: (self initialsPerSe ifEmpty: [ '.' ])!

Item was added:
+ ----- Method: Author>>changeStampWithInitials: (in category 'utility') -----
+ changeStampWithInitials: aString
+ 
+ 	^String streamContents: [ :stream |
+ 		stream
+ 			nextPutAll: aString;
+ 			space;
+ 			nextPutAll: Date today mmddyyyy;
+ 			space.
+ 		Time now print24: true showSeconds: false on: stream ]			!

Item was added:
+ ----- Method: Author>>fullName (in category 'pharo compatibility') -----
+ fullName
+ 
+ 	^self initials!

Item was added:
+ ----- Method: Author>>fullNamePerSe (in category 'pharo compatibility') -----
+ fullNamePerSe
+ 
+ 	^self initialsPerSe!

Item was added:
+ ----- Method: Author>>ifUnknownAuthorUse:during: (in category 'pharo compatibility') -----
+ ifUnknownAuthorUse: aString during: aBlock
+ 
+ 	initials ifEmpty: [ 
+ 		^self
+ 			useAuthor: aString
+ 			during: aBlock ].
+ 	^aBlock value!

Item was added:
+ ----- Method: Author>>initialize (in category 'initialize-release') -----
+ initialize
+ 
+ 	super initialize.
+ 	initials := String new.
+ 	username := String new
+ 	!

Item was added:
+ ----- Method: Author>>initializeFromUtilities (in category 'migration') -----
+ initializeFromUtilities
+ 
+ 	(Smalltalk classNamed: #Utilities) ifNotNil: [ :utilities |
+ 		(utilities respondsTo: #authorInitialsPerSe) ifTrue: [
+ 			initials := utilities authorInitialsPerSe ].
+ 		(utilities respondsTo: #authorNamePerSe) ifTrue: [
+ 			username := utilities authorNamePerSe ] ]!

Item was added:
+ ----- Method: Author>>initials (in category 'accessing') -----
+ initials
+ 
+ 	^initials ifEmpty: [ self requestAndSetInitials ]!

Item was added:
+ ----- Method: Author>>initials: (in category 'accessing') -----
+ initials: aString
+ 
+ 	initials := aString!

Item was added:
+ ----- Method: Author>>initialsPerSe (in category 'accessing') -----
+ initialsPerSe
+ 
+ 	^initials!

Item was added:
+ ----- Method: Author>>requestAndSetInitials (in category 'accessing') -----
+ requestAndSetInitials
+ 
+ 	^initials := (UIManager default
+ 		request: 'Please type your initials: ' translated
+ 		initialAnswer: initials) select: [ :each |
+ 			#(
+ 				($A $Z)
+ 				($a $z)
+ 				($0 $9)) anySatisfy: [ :range |
+ 					each between: range first and: range second ] ]!

Item was added:
+ ----- Method: Author>>requestAndSetUsername (in category 'accessing') -----
+ requestAndSetUsername
+ 
+ 	^username := UIManager default 
+ 		request: 'Please type your name:' translated
+ 		initialAnswer: (username
+ 			ifEmpty: [ 'Your Name' translated ]
+ 			ifNotEmpty: [ username ])!

Item was added:
+ ----- Method: Author>>useAuthor:during: (in category 'pharo compatibility') -----
+ useAuthor: aString during: aBlock
+ 	
+ 	^self useInitials: aString during: aBlock!

Item was added:
+ ----- Method: Author>>useInitials:during: (in category 'accessing') -----
+ useInitials: aString during: aBlock
+ 	"Use aString as initials while aBlock is being evaluated."
+ 	
+ 	| originalInitials |
+ 	originalInitials := initials.
+ 	initials := aString.
+ 	^aBlock ensure: [ initials := originalInitials ]!

Item was added:
+ ----- Method: Author>>username (in category 'accessing') -----
+ username
+ 
+ 	^username ifEmpty: [ self requestAndSetUsername ]!

Item was added:
+ ----- Method: Author>>username: (in category 'accessing') -----
+ username: aString
+ 
+ 	username := aString!

Item was added:
+ ----- Method: Author>>usernamePerSe (in category 'accessing') -----
+ usernamePerSe
+ 
+ 	^username!



More information about the Squeak-dev mailing list