Skip to content

Commit f2d3f67

Browse files
authored
Merge pull request #39 from jecisc/13-Add-a-way-to-select-cleaners-to-call
13-Add-a-way-to-select-cleaners-to-call
2 parents 731a013 + 0def672 commit f2d3f67

File tree

5 files changed

+61
-27
lines changed

5 files changed

+61
-27
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ packages := ((IceRepository registry select: [ :e | e name includesSubstring: 'M
4141
Chanel perfume: packages
4242
```
4343

44+
It is also possible to run only some cleaners selecting them manually.
45+
46+
```Smalltalk
47+
Chanel perfume: packages using: { ChanelTestEqualityCleaner . ChanelProtocolsCleaner }.
48+
```
49+
50+
You can find the full list of cleaners running `ChanelAbstractCleaner cleaners asArray`.
51+
It is advised to keep the cleaner in the given order of this snippet since some of them needs to run before the others.
52+
4453
> **WARNING**: Some cleaning are making sense in most cases but might cause troubles in some edge cases. Please, read the documentation to see the list of possible problems it might introduce.
4554
4655
## Documentation

resources/doc/documentation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ packages := ((IceRepository registry select: [ :e | e name includesSubstring: 'M
1313
Chanel perfume: packages
1414
```
1515

16+
It is also possible to run only some cleaners selecting them manually.
17+
18+
```Smalltalk
19+
Chanel perfume: packages using: { ChanelTestEqualityCleaner . ChanelProtocolsCleaner }.
20+
```
21+
22+
You can find the full list of cleaners running `ChanelAbstractCleaner cleaners asArray`.
23+
It is advised to keep the cleaner in the given order of this snippet since some of them needs to run before the others.
24+
1625
## Tests equality
1726

1827
Chanel iterates on all the tests of the packages and clean equality assertions.

src/Chanel-Tests/ChanelProtocolsCleanerTest.class.st

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ChanelProtocolsCleanerTest >> setUp [
1313
class := self createClassNamed: #ChanelProtocolsFake
1414
]
1515

16-
{ #category : #running }
16+
{ #category : #tests }
1717
ChanelProtocolsCleanerTest >> testDoesNotUpdateCloseProtocolIfAlreadyRight [
1818
class compile: 'method' classified: 'instance creation'.
1919

@@ -22,7 +22,7 @@ ChanelProtocolsCleanerTest >> testDoesNotUpdateCloseProtocolIfAlreadyRight [
2222
self assert: (class >> #method) protocol equals: 'instance creation'
2323
]
2424

25-
{ #category : #running }
25+
{ #category : #tests }
2626
ChanelProtocolsCleanerTest >> testMethodInSpecificProtocol [
2727
class compile: 'initialize' classified: 'random'.
2828

@@ -31,7 +31,7 @@ ChanelProtocolsCleanerTest >> testMethodInSpecificProtocol [
3131
self assert: (class >> #initialize) protocol equals: 'initialization'
3232
]
3333

34-
{ #category : #running }
34+
{ #category : #tests }
3535
ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfExtension [
3636
class compile: 'initialize' classified: self extensionProtocol.
3737

@@ -40,7 +40,7 @@ ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfExtension [
4040
self assert: (class >> #initialize) protocol equals: self extensionProtocol
4141
]
4242

43-
{ #category : #running }
43+
{ #category : #tests }
4444
ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfNotInTheList [
4545
class compile: 'initialize2' classified: 'random'.
4646

@@ -49,7 +49,7 @@ ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfNotInTheLis
4949
self assert: (class >> #initialize2) protocol equals: 'random'
5050
]
5151

52-
{ #category : #running }
52+
{ #category : #tests }
5353
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocol [
5454
class := self createTestCaseNamed: #ChanelProtocolsFake.
5555
class compile: 'setUp' classified: 'random'.
@@ -59,7 +59,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocol [
5959
self assert: (class >> #setUp) protocol equals: 'running'
6060
]
6161

62-
{ #category : #running }
62+
{ #category : #tests }
6363
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfExtension [
6464
class := self createTestCaseNamed: #ChanelProtocolsFake.
6565
class compile: 'setUp' classified: self extensionProtocol.
@@ -69,7 +69,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfExtens
6969
self assert: (class >> #setUp) protocol equals: self extensionProtocol
7070
]
7171

72-
{ #category : #running }
72+
{ #category : #tests }
7373
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInTestCase [
7474
class compile: 'setUp' classified: 'random'.
7575

@@ -78,7 +78,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInT
7878
self assert: (class >> #setUp) protocol equals: 'random'
7979
]
8080

81-
{ #category : #running }
81+
{ #category : #tests }
8282
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInTheList [
8383
class := self createTestCaseNamed: #ChanelProtocolsFake.
8484
class compile: 'toto' classified: 'random'.
@@ -88,7 +88,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInT
8888
self assert: (class >> #toto) protocol equals: 'random'
8989
]
9090

91-
{ #category : #running }
91+
{ #category : #tests }
9292
ChanelProtocolsCleanerTest >> testTestMethodsAreInRightProtocol [
9393
class := self createTestCaseNamed: #ChanelProtocolsFake.
9494
class compile: 'testMethod' classified: 'not a test'.
@@ -98,7 +98,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsAreInRightProtocol [
9898
self assert: (class >> #testMethod) protocol equals: 'tests'
9999
]
100100

101-
{ #category : #running }
101+
{ #category : #tests }
102102
ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfExtension [
103103
class := self createTestCaseNamed: #ChanelProtocolsFake.
104104
class compile: 'testMethod' classified: self extensionProtocol.
@@ -108,7 +108,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfExtension [
108108
self assert: (class >> #testMethod) protocol equals: self extensionProtocol
109109
]
110110

111-
{ #category : #running }
111+
{ #category : #tests }
112112
ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfNotInTestCase [
113113
class compile: 'testMethod' classified: 'not a test'.
114114

@@ -117,7 +117,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfNotInTestCase
117117
self assert: (class >> #testMethod) protocol equals: 'not a test'
118118
]
119119

120-
{ #category : #running }
120+
{ #category : #tests }
121121
ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfStartingByTest [
122122
class := self createTestCaseNamed: #ChanelProtocolsFake.
123123
class compile: 'testMethod' classified: 'test - protocols'.
@@ -127,7 +127,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfStartingByTes
127127
self assert: (class >> #testMethod) protocol equals: 'test - protocols'
128128
]
129129

130-
{ #category : #running }
130+
{ #category : #tests }
131131
ChanelProtocolsCleanerTest >> testUpdateCloseProtocol [
132132
class compile: 'method' classified: 'instance-creation'.
133133

src/Chanel/Chanel.class.st

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ Examples
1414
flatCollect: [ :e | e workingCopy packageNames collect: [:s | s asPackageIfAbsent: [ nil ] ]]) reject: #isNil.
1515
1616
Chanel perfume: packages
17+
18+
""You can also choose the list of cleaners to run:""
1719
20+
Chanel perfume: packages using: { ChanelTestEqualityCleaner . ChanelProtocolsCleaner }.
21+
22+
""You can find the full list of cleaners running:""
23+
24+
ChanelAbstractCleaner cleaners asArray
25+
1826
Internal Representation and Key Implementation Points.
1927
--------------------
2028
@@ -33,23 +41,29 @@ Class {
3341

3442
{ #category : #cleaning }
3543
Chanel class >> perfume: aCollectionOfPackages [
44+
^ self perfume: aCollectionOfPackages using: ChanelAbstractCleaner cleaners
45+
]
46+
47+
{ #category : #cleaning }
48+
Chanel class >> perfume: aCollectionOfPackages using: aCollectionOfCleaners [
3649
^ self new
3750
packages: aCollectionOfPackages;
38-
clean
51+
cleanUsing: aCollectionOfCleaners
3952
]
4053

4154
{ #category : #cleaning }
42-
Chanel >> clean [
43-
| cleaners |
44-
cleaners := ChanelAbstractCleaner cleanersFor: self.
45-
46-
UIManager default displayProgress: 'Running Chanel' from: 1 to: cleaners size during: [ :bar |
47-
cleaners
48-
doWithIndex: [ :cleaner :index |
49-
bar
50-
value: index;
51-
title: '(' , index asString , '/' , cleaners size asString , ') Running ' , cleaner printString.
52-
cleaner clean ] ]
55+
Chanel >> cleanUsing: cleaners [
56+
UIManager default
57+
displayProgress: 'Running Chanel'
58+
from: 1
59+
to: cleaners size
60+
during: [ :bar |
61+
cleaners
62+
doWithIndex: [ :cleaner :index |
63+
bar
64+
value: index;
65+
title: '(' , index asString , '/' , cleaners size asString , ') Running ' , cleaner printString.
66+
(cleaner configuration: self) clean ] ]
5367
]
5468

5569
{ #category : #accessing }

src/Chanel/ChanelAbstractCleaner.class.st

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Each of my subclasses represents a kind of cleaning to apply on the project to c
88
99
I am configured with an instance of Chanel to get the elements to clean.
1010
11+
You can find the full list of cleaners running `ChanelAbstractCleaner cleaners`.
12+
1113
Public API and Key Messages
1214
--------------------
1315
@@ -30,8 +32,8 @@ Class {
3032
}
3133

3234
{ #category : #'instance creation' }
33-
ChanelAbstractCleaner class >> cleanersFor: aConfiguration [
34-
^ ((self allSubclasses reject: #isAbstract) sort: #priority ascending) collect: [ :class | class configuration: aConfiguration ]
35+
ChanelAbstractCleaner class >> cleaners [
36+
^ (self allSubclasses reject: #isAbstract) sort: #priority ascending
3537
]
3638

3739
{ #category : #accessing }

0 commit comments

Comments
 (0)