author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 18 Sep 2012 18:24:44 +0000 | |
changeset 16 | 25ac697dc747 |
parent 14 | f01fe37493e9 |
permissions | -rw-r--r-- |
11
d354ac2af7ec
Metacello package refactoring - phase 2~
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10
diff
changeset
|
1 |
"{ Package: 'stx:goodies/metacello/core' }" |
1 | 2 |
|
3 |
MetacelloSpec subclass:#MetacelloVersionSpec |
|
4 |
instanceVariableNames:'versionString blessing description author timestamp preLoadDoIt |
|
14
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
5 |
postLoadDoIt' |
1 | 6 |
classVariableNames:'' |
7 |
poolDictionaries:'' |
|
8 |
category:'Metacello-Core-Specs' |
|
9 |
! |
|
10 |
||
11 |
||
12 |
!MetacelloVersionSpec methodsFor:'accessing'! |
|
13 |
||
14 |
author |
|
15 |
||
16 |
author == nil |
|
17 |
ifTrue: [ |
|
18 |
^self project valueHolderSpec |
|
19 |
value: ''; |
|
20 |
yourself]. |
|
21 |
^ author |
|
22 |
! |
|
23 |
||
24 |
author: anObject |
|
25 |
||
26 |
anObject setAuthorInMetacelloVersion: self |
|
27 |
! |
|
28 |
||
29 |
blessing |
|
30 |
||
31 |
blessing == nil |
|
32 |
ifTrue: [ |
|
33 |
^self project valueHolderSpec |
|
34 |
value: self project defaultBlessing; |
|
35 |
yourself]. |
|
36 |
^ blessing |
|
37 |
! |
|
38 |
||
39 |
blessing: anObject |
|
40 |
||
41 |
anObject setBlessingInMetacelloVersion: self |
|
42 |
! |
|
43 |
||
44 |
description |
|
45 |
||
46 |
description == nil |
|
47 |
ifTrue: [ |
|
48 |
^self project valueHolderSpec |
|
49 |
value: ''; |
|
50 |
yourself]. |
|
51 |
^ description |
|
52 |
! |
|
53 |
||
54 |
description: anObject |
|
55 |
||
56 |
anObject setDescriptionInMetacelloVersion: self |
|
57 |
! |
|
58 |
||
59 |
getAuthor |
|
60 |
^author |
|
61 |
! |
|
62 |
||
63 |
getBlessing |
|
64 |
^blessing |
|
65 |
! |
|
66 |
||
67 |
getDescription |
|
68 |
^description |
|
69 |
! |
|
70 |
||
71 |
getPostLoadDoIt |
|
72 |
^postLoadDoIt |
|
73 |
! |
|
74 |
||
75 |
getPreLoadDoIt |
|
76 |
^preLoadDoIt |
|
77 |
! |
|
78 |
||
79 |
getTimestamp |
|
80 |
^timestamp |
|
81 |
! |
|
82 |
||
83 |
postLoadDoIt: anObject |
|
84 |
||
85 |
anObject setPostLoadDoItInMetacelloSpec: self |
|
86 |
! |
|
87 |
||
88 |
preLoadDoIt: anObject |
|
89 |
||
90 |
anObject setPreLoadDoItInMetacelloSpec: self |
|
91 |
! |
|
92 |
||
93 |
projectLabel |
|
94 |
||
95 |
^self project label |
|
96 |
! |
|
97 |
||
98 |
setAuthor: anObject |
|
99 |
author := anObject |
|
100 |
! |
|
101 |
||
102 |
setBlessing: anObject |
|
103 |
blessing := anObject |
|
104 |
! |
|
105 |
||
106 |
setDescription: anObject |
|
107 |
description := anObject |
|
108 |
! |
|
109 |
||
110 |
setPostLoadDoIt: aSymbol |
|
111 |
||
112 |
postLoadDoIt := aSymbol |
|
113 |
! |
|
114 |
||
115 |
setPreLoadDoIt: aSymbol |
|
116 |
||
117 |
preLoadDoIt := aSymbol |
|
118 |
! |
|
119 |
||
120 |
setTimestamp: anObject |
|
121 |
timestamp := anObject |
|
122 |
! |
|
123 |
||
124 |
timestamp |
|
125 |
||
126 |
timestamp == nil |
|
127 |
ifTrue: [ |
|
128 |
^self project valueHolderSpec |
|
129 |
value: ''; |
|
130 |
yourself]. |
|
131 |
^ timestamp |
|
132 |
! |
|
133 |
||
134 |
timestamp: anObject |
|
135 |
||
136 |
anObject setTimestampInMetacelloVersion: self |
|
137 |
! |
|
138 |
||
139 |
versionString: anObject |
|
140 |
versionString := anObject |
|
141 |
! ! |
|
142 |
||
16
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
143 |
!MetacelloVersionSpec methodsFor:'construction'! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
144 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
145 |
author: aBlockOrString constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
146 |
aVersionConstructor authorForVersion: aBlockOrString |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
147 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
148 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
149 |
blessing: aBlockOrString constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
150 |
aVersionConstructor blessingForVersion: aBlockOrString |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
151 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
152 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
153 |
description: aBlockOrString constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
154 |
aVersionConstructor descriptionForVersion: aBlockOrString |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
155 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
156 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
157 |
postLoadDoIt: aSymbol constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
158 |
aVersionConstructor postLoadDoItForVersion: aSymbol |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
159 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
160 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
161 |
preLoadDoIt: aSymbol constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
162 |
aVersionConstructor preLoadDoItForVersion: aSymbol |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
163 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
164 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
165 |
repositories: aBlock constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
166 |
aVersionConstructor repositoriesForVersion: aBlock |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
167 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
168 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
169 |
repository: anObject constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
170 |
aVersionConstructor repositoryForVersion: anObject |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
171 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
172 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
173 |
repository: aString username: username password: password constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
174 |
aVersionConstructor repositoryForVersion: aString username: username password: password |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
175 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
176 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
177 |
timestamp: aBlockOrStringOrDateAndTime constructor: aVersionConstructor |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
178 |
aVersionConstructor timestampForVersion: aBlockOrStringOrDateAndTime |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
179 |
! ! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
180 |
|
1 | 181 |
!MetacelloVersionSpec methodsFor:'copying'! |
182 |
||
183 |
postCopy |
|
184 |
||
185 |
super postCopy. |
|
186 |
blessing := blessing copy. |
|
187 |
description := description copy. |
|
188 |
author := author copy. |
|
189 |
timestamp := timestamp copy. |
|
190 |
||
191 |
! ! |
|
192 |
||
193 |
!MetacelloVersionSpec methodsFor:'merging'! |
|
194 |
||
195 |
mergeMap |
|
196 |
||
197 |
| map | |
|
198 |
map := super mergeMap. |
|
199 |
map at: #versionString put: versionString. |
|
200 |
map at: #blessing put: blessing. |
|
201 |
map at: #description put: description. |
|
202 |
map at: #author put: author. |
|
203 |
map at: #timestamp put: timestamp. |
|
204 |
map at: #preLoadDoIt put: preLoadDoIt. |
|
205 |
map at: #postLoadDoIt put: postLoadDoIt. |
|
206 |
^map |
|
207 |
! ! |
|
208 |
||
209 |
!MetacelloVersionSpec methodsFor:'printing'! |
|
210 |
||
211 |
configMethodOn: aStream for: spec selector: selector last: last indent: indent |
|
212 |
spec == nil |
|
213 |
ifTrue: [ ^ self ]. |
|
214 |
aStream |
|
215 |
tab: indent; |
|
216 |
nextPutAll: 'spec ' , selector , ' ['; |
|
217 |
cr. |
|
218 |
spec configMethodOn: aStream indent: indent + 1. |
|
219 |
aStream nextPutAll: ' ].'. |
|
220 |
last |
|
221 |
ifFalse: [ aStream cr ] |
|
222 |
! |
|
223 |
||
224 |
configMethodOn: aStream indent: indent |
|
225 |
||
226 |
self configMethodOn: aStream last: true indent: indent |
|
227 |
! |
|
228 |
||
229 |
configMethodOn: aStream last: last indent: indent |
|
230 |
| values lastIndex lastBlock | |
|
231 |
last |
|
232 |
ifTrue: [ |
|
233 |
"need to calculate last statement with a value" |
|
234 |
values := {(self getBlessing). |
|
235 |
(self getDescription). |
|
236 |
(self getPreLoadDoIt). |
|
237 |
(self getPostLoadDoIt). |
|
238 |
(self getAuthor). |
|
239 |
(self getTimestamp)}. |
|
240 |
1 to: values size do: [ :index | |
|
241 |
(values at: index) ~~ nil |
|
242 |
ifTrue: [ lastIndex := index ] ]. |
|
243 |
lastBlock := [ :arg | arg = lastIndex ] ] |
|
244 |
ifFalse: [ lastBlock := [ :arg | false ] ]. |
|
245 |
self |
|
246 |
configMethodValueOn: aStream |
|
247 |
for: self getBlessing |
|
248 |
selector: 'blessing:' |
|
249 |
last: (lastBlock value: 1) |
|
250 |
indent: indent. |
|
251 |
self |
|
252 |
configMethodValueOn: aStream |
|
253 |
for: self getDescription |
|
254 |
selector: 'description:' |
|
255 |
last: (lastBlock value: 2) |
|
256 |
indent: indent. |
|
257 |
self |
|
258 |
configMethodValueOn: aStream |
|
259 |
for: self getPreLoadDoIt |
|
260 |
selector: 'preLoadDoIt:' |
|
261 |
last: (lastBlock value: 3) |
|
262 |
indent: indent. |
|
263 |
self |
|
264 |
configMethodValueOn: aStream |
|
265 |
for: self getPostLoadDoIt |
|
266 |
selector: 'postLoadDoIt:' |
|
267 |
last: (lastBlock value: 4) |
|
268 |
indent: indent. |
|
269 |
self |
|
270 |
configMethodValueOn: aStream |
|
271 |
for: self getAuthor |
|
272 |
selector: 'author:' |
|
273 |
last: (lastBlock value: 5) |
|
274 |
indent: indent. |
|
275 |
self |
|
276 |
configMethodValueOn: aStream |
|
277 |
for: self getTimestamp |
|
278 |
selector: 'timestamp:' |
|
279 |
last: (lastBlock value: 6) |
|
280 |
indent: indent |
|
281 |
! |
|
282 |
||
283 |
configMethodValueOn: aStream for: spec selector: selector last: last indent: indent |
|
284 |
| valuePrintString | |
|
285 |
spec == nil |
|
286 |
ifTrue: [ ^ self ]. |
|
287 |
valuePrintString := spec value isSymbol |
|
288 |
ifTrue: [ '#' , spec value asString printString ] |
|
289 |
ifFalse: [ spec value printString ]. |
|
290 |
aStream |
|
291 |
tab: indent; |
|
292 |
nextPutAll: 'spec ' , selector , ' ' , valuePrintString , '.'. |
|
293 |
last |
|
294 |
ifFalse: [ aStream cr ] |
|
295 |
! |
|
296 |
||
297 |
configSpawnMethodOn: aStream indent: indent |
|
298 |
||
299 |
self configMethodValueOn: aStream for: self getBlessing selector: 'blessing:' last: false indent: indent. |
|
300 |
self configMethodValueOn: aStream for: self getAuthor selector: 'author:' last: false indent: indent. |
|
301 |
self configMethodValueOn: aStream for: self getTimestamp selector: 'timestamp:' last: false indent: indent. |
|
302 |
||
303 |
! |
|
304 |
||
305 |
label |
|
306 |
||
307 |
^self versionString, ' [', self projectLabel, ']' |
|
308 |
! ! |
|
309 |
||
310 |
!MetacelloVersionSpec methodsFor:'private'! |
|
311 |
||
312 |
createVersion |
|
313 |
||
314 |
^self versionClass fromSpec: self |
|
315 |
! |
|
316 |
||
317 |
versionClass |
|
318 |
||
319 |
^MetacelloVersion |
|
16
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
320 |
! |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
321 |
|
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
322 |
versionNumber |
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
323 |
^ self project versionNumberClass fromString: self versionString |
1 | 324 |
! ! |
325 |
||
326 |
!MetacelloVersionSpec methodsFor:'querying'! |
|
327 |
||
328 |
postLoadDoIt |
|
329 |
||
330 |
^postLoadDoIt |
|
331 |
! |
|
332 |
||
333 |
preLoadDoIt |
|
334 |
||
335 |
^preLoadDoIt |
|
336 |
! |
|
337 |
||
338 |
versionString |
|
339 |
versionString == nil ifTrue: [ ^'' ]. |
|
340 |
^ versionString |
|
341 |
! ! |
|
342 |
||
343 |
!MetacelloVersionSpec methodsFor:'testing'! |
|
344 |
||
345 |
isPartiallyCurrent: notLoadedMatters useEquality: useEquality |
|
346 |
||
347 |
self subclassResponsibility |
|
348 |
! |
|
349 |
||
350 |
isPossibleBaseline |
|
16
25ac697dc747
- Updated from branch master
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
351 |
self subclassResponsibility |
1 | 352 |
! ! |
353 |
||
354 |
!MetacelloVersionSpec class methodsFor:'documentation'! |
|
355 |
||
356 |
version_SVN |
|
357 |
^ '$Id:: $' |
|
358 |
! ! |