diff --git a/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st b/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st index 95ca750..a700e79 100644 --- a/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st +++ b/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st @@ -8,7 +8,7 @@ Class { #category : #'Grafoscopio-Utils' } -{ #category : #'as yet unclassified' } +{ #category : #utilities } GrafoscopioUtils class >> checksumFor: aFileReference [ ^ (SHA1 new hashMessage: aFileReference binaryReadStream contents) hex. ] @@ -51,6 +51,17 @@ GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [ ^ client contents. ] +{ #category : #utilities } +GrafoscopioUtils class >> perform: aString on: anObject [ + + | msg | + msg := self selectorAndArgumentsFrom: aString. + msg + at: 'args' + ifPresent: [ ^ anObject perform: (msg at: 'selector') withArguments: (msg at: 'args') ] + ifAbsent: [ ^ anObject perform: (msg at: 'selector') ] +] + { #category : #private } GrafoscopioUtils class >> sanitize: url [ "I remove white spaces in url's and prepend 'http://' to urls when it is ommited, so @@ -65,6 +76,25 @@ GrafoscopioUtils class >> sanitize: url [ ^ sanitized ] +{ #category : #utilities } +GrafoscopioUtils class >> selectorAndArgumentsFrom: aString [ + "I return from aString a symbol that contains a message and an array of arguments used in it" + | msgArray answer | + answer := OrderedDictionary new. + msgArray := aString splitOn: ':'. + msgArray size = 1 + ifTrue: [ + ^ answer + at: 'selector' put: (msgArray at: 1) asSymbol; + yourself ]. + msgArray size = 2 + ifTrue: [ + ^ answer + at: 'selector' put: ((msgArray at: 1),':') asSymbol; + at: 'args' put: (Array with: (msgArray at: 2)); + yourself ]. +] + { #category : #updating } GrafoscopioUtils class >> update [ "Updates GrafoscopioUtils with new versions of itself take from the source code repository."