author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 18 Sep 2012 13:10:10 +0000 | |
changeset 14 | f01fe37493e9 |
parent 11 | d354ac2af7ec |
child 16 | 25ac697dc747 |
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 |
Object subclass:#MetacelloProject |
|
14
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
4 |
instanceVariableNames:'versionMap symbolicVersionMap loader loaderClass loadType |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
5 |
configuration projectAttributes' |
1 | 6 |
classVariableNames:'' |
7 |
poolDictionaries:'' |
|
8 |
category:'Metacello-Core-Model' |
|
9 |
! |
|
10 |
||
11 |
||
12 |
!MetacelloProject class methodsFor:'instance creation'! |
|
13 |
||
14 |
new |
|
15 |
||
16 |
| inst | |
|
17 |
inst := self basicNew. |
|
18 |
^inst configuration: inst; yourself |
|
19 |
! |
|
20 |
||
21 |
on: aConfig |
|
22 |
||
23 |
^self basicNew configuration: aConfig; yourself |
|
24 |
! ! |
|
25 |
||
26 |
!MetacelloProject methodsFor:'accessing'! |
|
27 |
||
28 |
configuration |
|
29 |
^ configuration |
|
30 |
! |
|
31 |
||
32 |
configuration: anObject |
|
33 |
configuration := anObject |
|
34 |
! |
|
35 |
||
36 |
defaultBlessing |
|
37 |
||
38 |
^#release |
|
39 |
! |
|
40 |
||
41 |
label |
|
42 |
||
43 |
^self configuration class name |
|
44 |
! |
|
45 |
||
46 |
loadType |
|
47 |
"#atomic or #linear" |
|
48 |
||
49 |
loadType == nil ifTrue: [ ^#atomic ]. |
|
50 |
^loadType |
|
51 |
! |
|
52 |
||
53 |
loadType: aSymbol |
|
54 |
"#atomic or #linear" |
|
55 |
||
56 |
loadType := aSymbol |
|
57 |
! |
|
58 |
||
59 |
map |
|
60 |
versionMap ifNil: [ ^ Dictionary new ]. |
|
61 |
^ versionMap |
|
62 |
! |
|
63 |
||
64 |
map: aDictionary |
|
65 |
||
66 |
versionMap := aDictionary |
|
67 |
! |
|
68 |
||
69 |
project |
|
70 |
||
71 |
^self |
|
72 |
! |
|
73 |
||
74 |
symbolicVersionMap |
|
75 |
||
76 |
^symbolicVersionMap |
|
77 |
||
78 |
||
79 |
! |
|
80 |
||
81 |
symbolicVersionMap: aDictionary |
|
82 |
||
83 |
symbolicVersionMap := aDictionary |
|
84 |
||
85 |
||
86 |
! ! |
|
87 |
||
88 |
!MetacelloProject methodsFor:'loading'! |
|
89 |
||
90 |
load: aVersionString |
|
91 |
||
92 |
^(self version: aVersionString) load |
|
93 |
! ! |
|
94 |
||
95 |
!MetacelloProject methodsFor:'printing'! |
|
96 |
||
97 |
printOn: aStream |
|
98 |
| label | |
|
99 |
self configuration class printOn: aStream. |
|
100 |
aStream nextPut: $(. |
|
101 |
self versions |
|
102 |
do: [ :vrsn | |
|
103 |
aStream nextPutAll: vrsn versionString. |
|
104 |
vrsn spec ~~ nil |
|
105 |
ifTrue: [ |
|
106 |
(label := vrsn spec projectLabel) isEmpty |
|
107 |
ifFalse: [ aStream nextPutAll: ' [' , label , ']' ] ]. |
|
108 |
aStream |
|
109 |
nextPut: $,; |
|
110 |
space ]. |
|
111 |
aStream nextPut: $) |
|
112 |
! ! |
|
113 |
||
114 |
!MetacelloProject methodsFor:'private'! |
|
115 |
||
116 |
attributes |
|
117 |
||
118 |
^(OrderedCollection with: #common) |
|
119 |
addAll: self platformAttributes; |
|
120 |
yourself |
|
121 |
! |
|
122 |
||
123 |
defaultPlatformAttributes |
|
124 |
||
125 |
^ MetacelloPlatform current defaultPlatformAttributes |
|
126 |
! |
|
127 |
||
128 |
excludeFromLatestVersion |
|
129 |
||
130 |
^#(development broken baseline) |
|
131 |
! |
|
132 |
||
133 |
platformAttributes |
|
134 |
||
135 |
^self projectPlatformAttributes |
|
136 |
! |
|
137 |
||
138 |
pragmaKeywords |
|
139 |
||
140 |
^#(version:attribute: blessing:attribute: description:attribute: required:attribute: groups:attribute: doits:attribute:) |
|
141 |
! |
|
142 |
||
143 |
projectAttributes |
|
144 |
||
145 |
projectAttributes ~~ nil ifTrue: [ ^projectAttributes ]. |
|
146 |
^#() |
|
147 |
! |
|
148 |
||
149 |
projectAttributes: aList |
|
150 |
||
151 |
projectAttributes := aList |
|
152 |
! |
|
153 |
||
154 |
projectPlatformAttributes |
|
155 |
||
156 |
| list aBlock | |
|
157 |
list := OrderedCollection new. |
|
158 |
(aBlock := self projectAttributes) ~~ nil |
|
159 |
ifTrue: [ list addAll: aBlock value ]. |
|
160 |
^self defaultPlatformAttributes, list |
|
161 |
! |
|
162 |
||
163 |
sortedAndFilteredVersions |
|
164 |
||
165 |
^(self map values asArray sort: [:a :b | a >= b ]) select: [:vrsn | (#(broken baseline) includes: vrsn blessing) not ]. |
|
166 |
! ! |
|
167 |
||
168 |
!MetacelloProject methodsFor:'spec classes'! |
|
169 |
||
170 |
defaultLoaderClass |
|
171 |
||
172 |
^MetacelloSpecLoader |
|
173 |
! |
|
174 |
||
175 |
groupSpec |
|
176 |
||
177 |
^self groupSpecClass for: self |
|
178 |
! |
|
179 |
||
180 |
groupSpecClass |
|
181 |
||
182 |
^MetacelloGroupSpec |
|
183 |
! |
|
184 |
||
185 |
loader |
|
186 |
||
187 |
^loader |
|
188 |
! |
|
189 |
||
190 |
loader: aLoader |
|
191 |
||
192 |
loader := aLoader |
|
193 |
! |
|
194 |
||
195 |
loaderClass |
|
196 |
||
197 |
loaderClass == nil ifTrue: [ loaderClass := self defaultLoaderClass ]. |
|
198 |
^loaderClass |
|
199 |
! |
|
200 |
||
201 |
loaderClass: aMetacelloSpecLoader |
|
202 |
||
203 |
loaderClass := aMetacelloSpecLoader |
|
204 |
! |
|
205 |
||
206 |
packagesSpec |
|
207 |
||
208 |
^self packagesSpecClass for: self |
|
209 |
! |
|
210 |
||
211 |
packagesSpecClass |
|
212 |
||
213 |
^MetacelloPackagesSpec |
|
214 |
! |
|
215 |
||
216 |
projectReferenceSpec |
|
217 |
||
218 |
^self projectReferenceSpecClass for: self |
|
219 |
! |
|
220 |
||
221 |
projectReferenceSpecClass |
|
222 |
||
223 |
^MetacelloProjectReferenceSpec |
|
224 |
! |
|
225 |
||
226 |
projectSpec |
|
227 |
||
228 |
^self projectSpecClass for: self |
|
229 |
! |
|
230 |
||
231 |
projectSpecClass |
|
14
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
232 |
|
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
233 |
^self subclassResponsibility |
1 | 234 |
! |
235 |
||
236 |
valueHolderSpec |
|
237 |
||
238 |
^self valueHolderSpecClass for: self |
|
239 |
! |
|
240 |
||
241 |
valueHolderSpecClass |
|
242 |
||
243 |
^MetacelloValueHolderSpec |
|
244 |
! |
|
245 |
||
246 |
versionSpec |
|
247 |
||
248 |
^self versionSpecClass for: self |
|
249 |
! |
|
250 |
||
251 |
versionSpecClass |
|
252 |
||
253 |
^MetacelloVersionSpec |
|
254 |
! ! |
|
255 |
||
256 |
!MetacelloProject methodsFor:'versions'! |
|
257 |
||
258 |
bleedingEdge |
|
259 |
||
260 |
^self version: #bleedingEdge |
|
261 |
! |
|
262 |
||
263 |
currentVersion |
|
264 |
| cacheKey cv | |
|
265 |
cacheKey := self configuration class. |
|
266 |
^ MetacelloPlatform current |
|
267 |
stackCacheFor: #currentVersion |
|
268 |
at: cacheKey |
|
269 |
doing: [ :cache | |
|
270 |
cv := self currentVersionAgainst: nil. |
|
271 |
^ cache at: cacheKey put: cv ] |
|
272 |
! |
|
273 |
||
274 |
currentVersionAgainst: resolvedPackageAndProjectNames |
|
275 |
| cacheKey | |
|
276 |
cacheKey := resolvedPackageAndProjectNames isNil |
|
277 |
ifTrue: [ Array with: self configuration class with: nil ] |
|
278 |
ifFalse: [ Array with: self configuration class with: (resolvedPackageAndProjectNames sort: [ :a :b | a <= b ]) ]. |
|
279 |
^ MetacelloPlatform current |
|
280 |
stackCacheFor: #currentVersionAgainst: |
|
281 |
at: cacheKey |
|
282 |
doing: [ :cache | |
|
283 |
| cv versions latestSomethingLoaded | |
|
284 |
cv := nil. |
|
285 |
versions := self sortedAndFilteredVersions. |
|
286 |
versions |
|
287 |
do: [ :version | |
|
288 |
| status matchBlock | |
|
289 |
status := resolvedPackageAndProjectNames isNil |
|
290 |
ifTrue: [ version spec isPartiallyCurrent ] |
|
291 |
ifFalse: [ version spec isPartiallyCurrentAgainst: resolvedPackageAndProjectNames ]. |
|
292 |
matchBlock := [ :matchStatus | |
|
293 |
cv := version copy. |
|
294 |
cv versionStatus: matchStatus. |
|
295 |
^ cache at: cacheKey put: cv ]. |
|
296 |
status isAllLoadedToSpec: matchBlock. |
|
297 |
status isLoadedToSpec: matchBlock. |
|
298 |
status isLoadedMatchConstraints: matchBlock. |
|
299 |
status |
|
300 |
isSomethingLoaded: [ :matchStatus | |
|
301 |
latestSomethingLoaded isNil |
|
302 |
ifTrue: [ |
|
303 |
cv := version copy. |
|
304 |
cv versionStatus: matchStatus. |
|
305 |
latestSomethingLoaded := cv ] ] ]. |
|
306 |
latestSomethingLoaded ifNotNil: [ ^ cache at: cacheKey put: latestSomethingLoaded ]. |
|
307 |
^ cache at: cacheKey put: nil ] |
|
308 |
! |
|
309 |
||
310 |
development |
|
311 |
||
312 |
^self version: #development |
|
313 |
! |
|
314 |
||
315 |
hasVersion: versionString |
|
316 |
||
317 |
self version: versionString ifAbsent: [ ^false ]. |
|
318 |
^true |
|
319 |
! |
|
320 |
||
321 |
lastVersion |
|
322 |
||
323 |
| coll | |
|
324 |
coll := (self map values asArray sort: [:a :b | a <= b ]) asOrderedCollection. |
|
325 |
coll isEmpty ifTrue: [ ^nil ]. |
|
326 |
^coll last |
|
327 |
! |
|
328 |
||
329 |
latestVersion |
|
330 |
||
331 |
| excluded | |
|
332 |
" self deprecated: 'Please use #stableVersion instead.'. |
|
333 |
" self flag: 'deprecate after version 1.0'. |
|
334 |
excluded := self excludeFromLatestVersion. |
|
335 |
^(self map values select: [:version | |
|
336 |
(excluded includes: version blessing) not ]) detectMax: [:version | version ] |
|
337 |
! |
|
338 |
||
339 |
latestVersion: blessing |
|
340 |
||
341 |
^(self map values select: [:version | blessing = version blessing ]) detectMax: [:version | version ] |
|
342 |
! |
|
343 |
||
344 |
latestVersionMatching: versionPatternString |
|
345 |
"Answer whether the version number of the receiver matches the given pattern string. |
|
346 |
||
347 |
A Metacello version number is made up of version sequences delimited by the characters $. and $-. |
|
348 |
The $. introduces a numeric version sequence and $- introduces an alphanumeric version sequence. |
|
349 |
||
350 |
A version pattern is made up of version pattern match sequences. also delimited by the characters $. |
|
351 |
and $-.. Each pattern match sequence is tested against the corresponding version sequence of the |
|
352 |
receiver, using the 'standard' pattern matching rules. All sequences must answer true for a match. |
|
353 |
||
354 |
The special pattern sequence '?' is a match for the corresponding version sequence and all subsequent |
|
355 |
version sequences. '?' as the version pattern matches all versions. No more version pattern |
|
356 |
sequences are permitted once the '?' sequence is used. If used, it is the last version pattern |
|
357 |
sequence." |
|
358 |
||
359 |
^self |
|
360 |
latestVersionMatching: versionPatternString |
|
361 |
includedBlessings: #() |
|
362 |
excludedBlessings: self excludeFromLatestVersion |
|
363 |
! |
|
364 |
||
365 |
latestVersionMatching: versionPatternString excludedBlessings: excluded |
|
366 |
||
367 |
^self |
|
368 |
latestVersionMatching: versionPatternString |
|
369 |
includedBlessings: #() |
|
370 |
excludedBlessings: excluded |
|
371 |
! |
|
372 |
||
373 |
latestVersionMatching: versionPatternString includedBlessings: included |
|
374 |
||
375 |
^self |
|
376 |
latestVersionMatching: versionPatternString |
|
377 |
includedBlessings: included |
|
378 |
excludedBlessings: self excludeFromLatestVersion |
|
379 |
! |
|
380 |
||
381 |
latestVersionMatching: versionPatternString includedBlessings: included excludedBlessings: excludedBlessings |
|
382 |
||
383 |
| excluded | |
|
384 |
excluded := excludedBlessings asSet copy. |
|
385 |
excluded removeAllFoundIn: included. |
|
386 |
^(self map values select: [:version | |
|
387 |
(included isEmpty or: [ included includes: version blessing ]) |
|
388 |
and: [ (excluded includes: version blessing) not |
|
389 |
and: [ version versionNumber match: versionPatternString ]]]) |
|
390 |
detectMax: [:version | version ] |
|
391 |
! |
|
392 |
||
393 |
stableVersion |
|
394 |
||
395 |
^self version: #stable |
|
396 |
! |
|
397 |
||
398 |
symbolicVersionSymbols |
|
399 |
||
400 |
^self symbolicVersionMap keys asArray sort: [:a :b | a <= b ] |
|
401 |
! |
|
402 |
||
403 |
version: aVersionString |
|
14
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
404 |
| vrsn | |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
405 |
aVersionString isSymbol |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
406 |
ifTrue: [ |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
407 |
| symbolicVersionString | |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
408 |
symbolicVersionString := self symbolicVersionMap |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
409 |
at: aVersionString |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
410 |
ifAbsent: [ (MetacelloSymbolicVersionDoesNotExistError project: self project versionString: aVersionString) signal ]. |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
411 |
symbolicVersionString == #notDefined |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
412 |
ifTrue: [ (MetacelloSymbolicVersionNotDefinedError project: self project versionString: aVersionString) signal ]. |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
413 |
^ self map |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
414 |
at: symbolicVersionString |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
415 |
ifAbsent: [ (MetacelloSymbolicVersionDoesNotExistError project: self project versionString: symbolicVersionString) signal ] ]. |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
416 |
^ self map |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
417 |
at: aVersionString |
f01fe37493e9
- MetacelloProjectSpecForLoad
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11
diff
changeset
|
418 |
ifAbsent: [ (MetacelloVersionDoesNotExistError project: self project versionString: aVersionString) signal ] |
1 | 419 |
! |
420 |
||
421 |
version: aVersionString ifAbsent: aBlock |
|
422 |
||
423 |
^[ self version: aVersionString ] on: MetacelloVersionDoesNotExistError do: [:ex | aBlock value ]. |
|
424 |
! |
|
425 |
||
426 |
versions |
|
427 |
||
428 |
^self map values asArray sort: [:a :b | a <= b ] |
|
429 |
! ! |
|
430 |
||
431 |
!MetacelloProject class methodsFor:'documentation'! |
|
432 |
||
433 |
version_SVN |
|
434 |
^ '$Id:: $' |
|
435 |
! ! |