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