Skip to content

Commit 1a8f4e8

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.
1 parent 51d5e12 commit 1a8f4e8

11 files changed

+160
-105
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Extension { #name : #CmCommandDecorator }
2+
3+
{ #category : #'*Commander2-Deprecations' }
4+
CmCommandDecorator >> basicDescription [
5+
self deprecated: 'Use #description instead.' transformWith: '`@receiver basicDescription' -> '`@receiver description'.
6+
^ self description
7+
]
8+
9+
{ #category : #'*Commander2-Deprecations' }
10+
CmCommandDecorator >> basicDescription: anObject [
11+
self deprecated: 'Use #description: instead.' transformWith: '`@receiver basicDescription: `@arg' -> '`@receiver description: `@arg'.
12+
^ self description: anObject
13+
]
14+
15+
{ #category : #'*Commander2-Deprecations' }
16+
CmCommandDecorator >> basicName [
17+
self deprecated: 'Use #name instead.' transformWith: '`@receiver basicName' -> '`@receiver name'.
18+
^ self name
19+
]
20+
21+
{ #category : #'*Commander2-Deprecations' }
22+
CmCommandDecorator >> basicName: anObject [
23+
self deprecated: 'Use #name: instead.' transformWith: '`@receiver basicName: `@arg' -> '`@receiver name: `@arg'.
24+
^ self name: anObject
25+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Extension { #name : #CmTWithBasicNameAndDescription }
2+
3+
{ #category : #'*Commander2-Deprecations' }
4+
CmTWithBasicNameAndDescription >> basicDescription [
5+
self deprecated: 'Use #description instead.' transformWith: '`@receiver basicDescription' -> '`@receiver description'.
6+
^ self description
7+
]
8+
9+
{ #category : #'*Commander2-Deprecations' }
10+
CmTWithBasicNameAndDescription >> basicDescription: anObject [
11+
self deprecated: 'Use #description: instead.' transformWith: '`@receiver basicDescription: `@arg' -> '`@receiver description: `@arg'.
12+
^ self description: anObject
13+
]
14+
15+
{ #category : #'*Commander2-Deprecations' }
16+
CmTWithBasicNameAndDescription >> basicName [
17+
self deprecated: 'Use #name instead.' transformWith: '`@receiver basicName' -> '`@receiver name'.
18+
^ self name
19+
]
20+
21+
{ #category : #'*Commander2-Deprecations' }
22+
CmTWithBasicNameAndDescription >> basicName: anObject [
23+
self deprecated: 'Use #name: instead.' transformWith: '`@receiver basicName: `@arg' -> '`@receiver name: `@arg'.
24+
^ self name: anObject
25+
]

src/Commander2-Tests/CmCommandDecoratorTest.class.st

+13-8
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@ CmCommandDecoratorTest >> setUp [
1717
commandToBeDecorated := CmCommand new.
1818

1919
commandToBeDecorated
20-
basicName: 'command for test';
21-
basicDescription: 'This command is only cerated for the purpose of unit tests.';
20+
name: 'command for test';
21+
description: 'This command is only cerated for the purpose of unit tests.';
2222
context: Object new.
2323

2424
decorator := CmCommandDecorator decorate: commandToBeDecorated
2525
]
2626

27-
{ #category : #test }
28-
CmCommandDecoratorTest >> testBasicName [
29-
self assert: decorator basicName equals: commandToBeDecorated basicName
30-
]
31-
3227
{ #category : #test }
3328
CmCommandDecoratorTest >> testContext [
3429
self assert: decorator context equals: commandToBeDecorated context
@@ -47,7 +42,17 @@ CmCommandDecoratorTest >> testDecoratedCommand [
4742

4843
{ #category : #test }
4944
CmCommandDecoratorTest >> testDescription [
50-
self assert: decorator basicDescription equals: commandToBeDecorated basicDescription
45+
self assert: decorator description equals: commandToBeDecorated description
46+
]
47+
48+
{ #category : #test }
49+
CmCommandDecoratorTest >> testDynamicDescription [
50+
self assert: decorator description equals: commandToBeDecorated description
51+
]
52+
53+
{ #category : #test }
54+
CmCommandDecoratorTest >> testDynamicName [
55+
self assert: decorator dynamicName equals: commandToBeDecorated dynamicName
5156
]
5257

5358
{ #category : #test }

src/Commander2-Tests/CmCommandTest.class.st

+14-14
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ CmCommandTest >> setUp [
1313
command := CmFakeCommand new.
1414
]
1515

16-
{ #category : #test }
17-
CmCommandTest >> testBasicDescription [
18-
self assert: command basicDescription equals: 'I am a fake command for testing purposes.'.
19-
]
20-
21-
{ #category : #test }
22-
CmCommandTest >> testBasicName [
23-
self assert: command basicName equals: 'Fake command'.
24-
]
25-
2616
{ #category : #test }
2717
CmCommandTest >> testCanBeExecuted [
2818
command context: 0. "Need to set context before because the command expects it."
@@ -47,9 +37,21 @@ CmCommandTest >> testContext [
4737

4838
{ #category : #test }
4939
CmCommandTest >> testDescription [
40+
self assert: command description equals: 'I am a fake command for testing purposes.'.
41+
]
42+
43+
{ #category : #test }
44+
CmCommandTest >> testDynamicDescription [
45+
command context: 42.
46+
47+
self assert: command dynamicDescription equals: command description , ' 42'
48+
]
49+
50+
{ #category : #test }
51+
CmCommandTest >> testDynamicName [
5052
command context: 42.
5153

52-
self assert: command description equals: command basicDescription , ' 42'
54+
self assert: command dynamicName equals: command name , ' 42'
5355
]
5456

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

6870
{ #category : #test }
6971
CmCommandTest >> testName [
70-
command context: 42.
71-
72-
self assert: command name equals: command basicName , ' 42'
72+
self assert: command name equals: 'Fake command'.
7373
]

src/Commander2-Tests/CmCommandsGroupTest.class.st

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ CmCommandsGroupTest >> setUp [
1919
super setUp.
2020
group := CmCommandGroup named: 'main group'.
2121
firstCommand := CmBlockCommand new
22-
basicName: 'first command';
22+
name: 'first command';
2323
block: [ :x | x ];
2424
context: [ 1 ];
2525
yourself.
2626

2727

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

99-
self assert: newGroup basicName equals: CmCommandGroup defaultName.
99+
self assert: newGroup name equals: CmCommandGroup defaultName.
100100
self assert: newGroup entries isEmpty
101101
]
102102

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

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

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

135135
secondCommandWithSameName := CmBlockCommand new
136-
basicName: 'second command';
136+
name: 'second command';
137137
block: [ :x | x ];
138138
context: [ ];
139139
yourself.

src/Commander2-Tests/CmFakeCommand.class.st

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ CmFakeCommand >> canBeExecuted [
1010
]
1111

1212
{ #category : #accessing }
13-
CmFakeCommand >> description [
14-
^ super description , ' ' , self context asString
13+
CmFakeCommand >> dynamicDescription [
14+
^ super dynamicDescription , ' ' , self context asString
15+
]
16+
17+
{ #category : #accessing }
18+
CmFakeCommand >> dynamicName [
19+
^ super dynamicName , ' ' , self context asString
1520
]
1621

1722
{ #category : #initialization }
1823
CmFakeCommand >> initialize [
1924
super initialize.
2025
self
21-
basicName: 'Fake command';
22-
basicDescription: 'I am a fake command for testing purposes.'
23-
]
24-
25-
{ #category : #accessing }
26-
CmFakeCommand >> name [
27-
^ super name , ' ' , self context asString
26+
name: 'Fake command';
27+
description: 'I am a fake command for testing purposes.'
2828
]

src/Commander2/CmCommand.class.st

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ CmCommand >> hasContext [
5858
{ #category : #initialization }
5959
CmCommand >> initialize [
6060
super initialize.
61-
self basicName: self class defaultName.
62-
self basicDescription: self class defaultDescription
61+
self name: self class defaultName.
62+
self description: self class defaultDescription
6363
]

src/Commander2/CmCommandDecorator.class.st

+20-20
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,6 @@ Class {
1414
#category : #'Commander2-Commands'
1515
}
1616

17-
{ #category : #accessing }
18-
CmCommandDecorator >> basicDescription [
19-
^ self decoratedCommand basicDescription
20-
]
21-
22-
{ #category : #accessing }
23-
CmCommandDecorator >> basicDescription: aString [
24-
self decoratedCommand basicDescription: aString
25-
]
26-
27-
{ #category : #accessing }
28-
CmCommandDecorator >> basicName [
29-
^ self decoratedCommand basicName
30-
]
31-
32-
{ #category : #accessing }
33-
CmCommandDecorator >> basicName: aString [
34-
self decoratedCommand basicName: aString
35-
]
36-
3717
{ #category : #testing }
3818
CmCommandDecorator >> canBeExecuted [
3919
"This hook allows the command decide if it can be run with the context it holds or not.
@@ -72,6 +52,21 @@ CmCommandDecorator >> description [
7252
^ self decoratedCommand description
7353
]
7454

55+
{ #category : #accessing }
56+
CmCommandDecorator >> description: aString [
57+
self decoratedCommand description: aString
58+
]
59+
60+
{ #category : #accessing }
61+
CmCommandDecorator >> dynamicDescription [
62+
^ self decoratedCommand dynamicDescription
63+
]
64+
65+
{ #category : #accessing }
66+
CmCommandDecorator >> dynamicName [
67+
^ self decoratedCommand dynamicName
68+
]
69+
7570
{ #category : #executing }
7671
CmCommandDecorator >> execute [
7772
self decoratedCommand execute
@@ -81,3 +76,8 @@ CmCommandDecorator >> execute [
8176
CmCommandDecorator >> name [
8277
^ self decoratedCommand name
8378
]
79+
80+
{ #category : #accessing }
81+
CmCommandDecorator >> name: aString [
82+
self decoratedCommand name: aString
83+
]

src/Commander2/CmCommandGroup.class.st

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CmCommandGroup class >> defaultName [
2929
{ #category : #'instance creation' }
3030
CmCommandGroup class >> named: aString [
3131
^ self new
32-
basicName: aString;
32+
name: aString;
3333
yourself
3434
]
3535

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

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

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

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

100100
{ #category : #testing }
@@ -105,8 +105,8 @@ CmCommandGroup >> hasGroup: aCommandGroup [
105105
{ #category : #initialization }
106106
CmCommandGroup >> initialize [
107107
super initialize.
108-
self basicName: self class defaultName.
109-
self basicDescription: self class defaultDescription.
108+
self name: self class defaultName.
109+
self description: self class defaultDescription.
110110
entries := OrderedCollection new
111111
]
112112

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

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

138138
entries at: commandToReplaceIndex put: aCommandOrGroup

0 commit comments

Comments
 (0)