Skip to content
Permalink
Browse files

Did migration with the following renamings (order is important):

#name -> #dynamicName.
#description -> #dynamicDescription.
#basicName -> #name.
#basicDescription -> #description.

Also did some renamings for test methods.
  • Loading branch information...
juliendelplanque committed Aug 14, 2019
1 parent 51d5e12 commit 1a8f4e8a1b7da5bdcc44c2a1d952557a71b6f351
@@ -0,0 +1,25 @@
Extension { #name : #CmCommandDecorator }

{ #category : #'*Commander2-Deprecations' }
CmCommandDecorator >> basicDescription [
self deprecated: 'Use #description instead.' transformWith: '`@receiver basicDescription' -> '`@receiver description'.
^ self description
]

{ #category : #'*Commander2-Deprecations' }
CmCommandDecorator >> basicDescription: anObject [
self deprecated: 'Use #description: instead.' transformWith: '`@receiver basicDescription: `@arg' -> '`@receiver description: `@arg'.
^ self description: anObject
]

{ #category : #'*Commander2-Deprecations' }
CmCommandDecorator >> basicName [
self deprecated: 'Use #name instead.' transformWith: '`@receiver basicName' -> '`@receiver name'.
^ self name
]

{ #category : #'*Commander2-Deprecations' }
CmCommandDecorator >> basicName: anObject [
self deprecated: 'Use #name: instead.' transformWith: '`@receiver basicName: `@arg' -> '`@receiver name: `@arg'.
^ self name: anObject
]
@@ -0,0 +1,25 @@
Extension { #name : #CmTWithBasicNameAndDescription }

{ #category : #'*Commander2-Deprecations' }
CmTWithBasicNameAndDescription >> basicDescription [
self deprecated: 'Use #description instead.' transformWith: '`@receiver basicDescription' -> '`@receiver description'.
^ self description
]

{ #category : #'*Commander2-Deprecations' }
CmTWithBasicNameAndDescription >> basicDescription: anObject [
self deprecated: 'Use #description: instead.' transformWith: '`@receiver basicDescription: `@arg' -> '`@receiver description: `@arg'.
^ self description: anObject
]

{ #category : #'*Commander2-Deprecations' }
CmTWithBasicNameAndDescription >> basicName [
self deprecated: 'Use #name instead.' transformWith: '`@receiver basicName' -> '`@receiver name'.
^ self name
]

{ #category : #'*Commander2-Deprecations' }
CmTWithBasicNameAndDescription >> basicName: anObject [
self deprecated: 'Use #name: instead.' transformWith: '`@receiver basicName: `@arg' -> '`@receiver name: `@arg'.
^ self name: anObject
]
@@ -17,18 +17,13 @@ CmCommandDecoratorTest >> setUp [
commandToBeDecorated := CmCommand new.

commandToBeDecorated
basicName: 'command for test';
basicDescription: 'This command is only cerated for the purpose of unit tests.';
name: 'command for test';
description: 'This command is only cerated for the purpose of unit tests.';
context: Object new.

decorator := CmCommandDecorator decorate: commandToBeDecorated
]

{ #category : #test }
CmCommandDecoratorTest >> testBasicName [
self assert: decorator basicName equals: commandToBeDecorated basicName
]

{ #category : #test }
CmCommandDecoratorTest >> testContext [
self assert: decorator context equals: commandToBeDecorated context
@@ -47,7 +42,17 @@ CmCommandDecoratorTest >> testDecoratedCommand [

{ #category : #test }
CmCommandDecoratorTest >> testDescription [
self assert: decorator basicDescription equals: commandToBeDecorated basicDescription
self assert: decorator description equals: commandToBeDecorated description
]

{ #category : #test }
CmCommandDecoratorTest >> testDynamicDescription [
self assert: decorator description equals: commandToBeDecorated description
]

{ #category : #test }
CmCommandDecoratorTest >> testDynamicName [
self assert: decorator dynamicName equals: commandToBeDecorated dynamicName
]

{ #category : #test }
@@ -13,16 +13,6 @@ CmCommandTest >> setUp [
command := CmFakeCommand new.
]

{ #category : #test }
CmCommandTest >> testBasicDescription [
self assert: command basicDescription equals: 'I am a fake command for testing purposes.'.
]

{ #category : #test }
CmCommandTest >> testBasicName [
self assert: command basicName equals: 'Fake command'.
]

{ #category : #test }
CmCommandTest >> testCanBeExecuted [
command context: 0. "Need to set context before because the command expects it."
@@ -47,9 +37,21 @@ CmCommandTest >> testContext [

{ #category : #test }
CmCommandTest >> testDescription [
self assert: command description equals: 'I am a fake command for testing purposes.'.
]

{ #category : #test }
CmCommandTest >> testDynamicDescription [
command context: 42.

self assert: command dynamicDescription equals: command description , ' 42'
]

{ #category : #test }
CmCommandTest >> testDynamicName [
command context: 42.

self assert: command description equals: command basicDescription , ' 42'
self assert: command dynamicName equals: command name , ' 42'
]

{ #category : #test }
@@ -67,7 +69,5 @@ CmCommandTest >> testHasContext [

{ #category : #test }
CmCommandTest >> testName [
command context: 42.

self assert: command name equals: command basicName , ' 42'
self assert: command name equals: 'Fake command'.
]
@@ -19,14 +19,14 @@ CmCommandsGroupTest >> setUp [
super setUp.
group := CmCommandGroup named: 'main group'.
firstCommand := CmBlockCommand new
basicName: 'first command';
name: 'first command';
block: [ :x | x ];
context: [ 1 ];
yourself.


subCommand1 := CmBlockCommand new
basicName: 'sub command 1';
name: 'sub command 1';
block: [ :x | x ];
context: [ 11 ];
yourself.
@@ -96,7 +96,7 @@ CmCommandsGroupTest >> testInitialize [
| newGroup |
newGroup := CmCommandGroup new.

self assert: newGroup basicName equals: CmCommandGroup defaultName.
self assert: newGroup name equals: CmCommandGroup defaultName.
self assert: newGroup entries isEmpty
]

@@ -106,7 +106,7 @@ CmCommandsGroupTest >> testRegisterCommandWithContext [
self deny: (group hasEntryNamed: 'second command').

secondCommand := CmBlockCommand new
basicName: 'second command';
name: 'second command';
block: [ :x | x ];
context: 42;
yourself.
@@ -123,7 +123,7 @@ CmCommandsGroupTest >> testRegisterCommandWithContextBlock [
self deny: (group hasEntryNamed: 'second command').

secondCommand := CmBlockCommand new
basicName: 'second command';
name: 'second command';
block: [ :x | x ];
context: [ 42 ];
yourself.
@@ -133,7 +133,7 @@ CmCommandsGroupTest >> testRegisterCommandWithContextBlock [
self assert: (group commandOrGroupNamed: 'second command') equals: secondCommand.

secondCommandWithSameName := CmBlockCommand new
basicName: 'second command';
name: 'second command';
block: [ :x | x ];
context: [ ];
yourself.
@@ -10,19 +10,19 @@ CmFakeCommand >> canBeExecuted [
]

{ #category : #accessing }
CmFakeCommand >> description [
^ super description , ' ' , self context asString
CmFakeCommand >> dynamicDescription [
^ super dynamicDescription , ' ' , self context asString
]

{ #category : #accessing }
CmFakeCommand >> dynamicName [
^ super dynamicName , ' ' , self context asString
]

{ #category : #initialization }
CmFakeCommand >> initialize [
super initialize.
self
basicName: 'Fake command';
basicDescription: 'I am a fake command for testing purposes.'
]

{ #category : #accessing }
CmFakeCommand >> name [
^ super name , ' ' , self context asString
name: 'Fake command';
description: 'I am a fake command for testing purposes.'
]
@@ -58,6 +58,6 @@ CmCommand >> hasContext [
{ #category : #initialization }
CmCommand >> initialize [
super initialize.
self basicName: self class defaultName.
self basicDescription: self class defaultDescription
self name: self class defaultName.
self description: self class defaultDescription
]
@@ -14,26 +14,6 @@ Class {
#category : #'Commander2-Commands'
}

{ #category : #accessing }
CmCommandDecorator >> basicDescription [
^ self decoratedCommand basicDescription
]

{ #category : #accessing }
CmCommandDecorator >> basicDescription: aString [
self decoratedCommand basicDescription: aString
]

{ #category : #accessing }
CmCommandDecorator >> basicName [
^ self decoratedCommand basicName
]

{ #category : #accessing }
CmCommandDecorator >> basicName: aString [
self decoratedCommand basicName: aString
]

{ #category : #testing }
CmCommandDecorator >> canBeExecuted [
"This hook allows the command decide if it can be run with the context it holds or not.
@@ -72,6 +52,21 @@ CmCommandDecorator >> description [
^ self decoratedCommand description
]

{ #category : #accessing }
CmCommandDecorator >> description: aString [
self decoratedCommand description: aString
]

{ #category : #accessing }
CmCommandDecorator >> dynamicDescription [
^ self decoratedCommand dynamicDescription
]

{ #category : #accessing }
CmCommandDecorator >> dynamicName [
^ self decoratedCommand dynamicName
]

{ #category : #executing }
CmCommandDecorator >> execute [
self decoratedCommand execute
@@ -81,3 +76,8 @@ CmCommandDecorator >> execute [
CmCommandDecorator >> name [
^ self decoratedCommand name
]

{ #category : #accessing }
CmCommandDecorator >> name: aString [
self decoratedCommand name: aString
]
@@ -29,7 +29,7 @@ CmCommandGroup class >> defaultName [
{ #category : #'instance creation' }
CmCommandGroup class >> named: aString [
^ self new
basicName: aString;
name: aString;
yourself
]

@@ -43,7 +43,7 @@ CmCommandGroup >> allCommands [

{ #category : #'public-api' }
CmCommandGroup >> commandOrGroupNamed: aString [
^ (entries detect: [ :commandOrRegister | commandOrRegister basicName = aString ])
^ (entries detect: [ :commandOrRegister | commandOrRegister name = aString ])
]

{ #category : #'public-api' }
@@ -56,8 +56,8 @@ CmCommandGroup >> ensureNotDuplicated: aCommandOrGroup [
"Check that aCommandOrGroup's #basicName is not already used by one of my entries.
If it is, raises a CmDuplicatedEntryName error.
"
(self hasEntryNamed: aCommandOrGroup basicName)
ifTrue: [ CmDuplicatedEntryName signalEntryNamed: aCommandOrGroup basicName ]
(self hasEntryNamed: aCommandOrGroup name)
ifTrue: [ CmDuplicatedEntryName signalEntryNamed: aCommandOrGroup name ]
]

{ #category : #'public-api' }
@@ -94,7 +94,7 @@ CmCommandGroup >> hasEntryNamed: aString [
"Returns true if one of my entries (command, registry, ...) is named aString.
Else returns false.
"
^ entries anySatisfy: [ :any | any basicName = aString ]
^ entries anySatisfy: [ :any | any name = aString ]
]

{ #category : #testing }
@@ -105,8 +105,8 @@ CmCommandGroup >> hasGroup: aCommandGroup [
{ #category : #initialization }
CmCommandGroup >> initialize [
super initialize.
self basicName: self class defaultName.
self basicDescription: self class defaultDescription.
self name: self class defaultName.
self description: self class defaultDescription.
entries := OrderedCollection new
]

@@ -132,7 +132,7 @@ CmCommandGroup >> register: aCommandOrGroup insteadOf: anotherCommandOrGroup [
| commandToReplaceIndex |
commandToReplaceIndex := self entriesIndexOf: anotherCommandOrGroup.

((self commands collect: #basicName) \ { (entries at: commandToReplaceIndex) } includes: aCommandOrGroup name)
((self commands collect: #name) \ { (entries at: commandToReplaceIndex) } includes: aCommandOrGroup name)
ifTrue: [ CmDuplicatedEntryName signalEntryNamed: aCommandOrGroup name ].

entries at: commandToReplaceIndex put: aCommandOrGroup

0 comments on commit 1a8f4e8

Please sign in to comment.
You can’t perform that action at this time.