1
|
1 |
"{ Package: 'stx:goodies/metacello' }"
|
|
2 |
|
|
3 |
Object subclass:#MetacelloProjectRegistry
|
|
4 |
instanceVariableNames:'baselineRegistry configurationRegistry'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Metacello-Core-Scripts'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MetacelloProjectRegistry methodsFor:'accessing'!
|
|
12 |
|
|
13 |
baselineProjectSpecs
|
|
14 |
"MetacelloProjectRegistration baselineProjectSpecs"
|
|
15 |
|
|
16 |
| projectSpecs |
|
|
17 |
projectSpecs := OrderedCollection new.
|
|
18 |
self baselineRegistry
|
|
19 |
keysAndValuesDo: [ :className :registration | projectSpecs add: (self projectSpecForClassNamed: className ifAbsent: [ self error: 'not expected' ]) ].
|
|
20 |
^ projectSpecs asArray
|
|
21 |
!
|
|
22 |
|
|
23 |
baselineRegistry
|
|
24 |
baselineRegistry ifNil: [ baselineRegistry := Dictionary new ].
|
|
25 |
^ baselineRegistry
|
|
26 |
!
|
|
27 |
|
|
28 |
configurationProjectSpecs
|
|
29 |
"MetacelloProjectRegistration configurationProjectSpecs"
|
|
30 |
|
|
31 |
| projectSpecs |
|
|
32 |
projectSpecs := OrderedCollection new.
|
|
33 |
self configurationRegistry
|
|
34 |
keysAndValuesDo: [ :className :registration | projectSpecs add: (self projectSpecForClassNamed: className ifAbsent: [ self error: 'not expected' ]) ].
|
|
35 |
^ projectSpecs asArray
|
|
36 |
!
|
|
37 |
|
|
38 |
configurationRegistry
|
|
39 |
configurationRegistry ifNil: [ configurationRegistry := Dictionary new ].
|
|
40 |
^ configurationRegistry
|
|
41 |
!
|
|
42 |
|
|
43 |
projectSpecs
|
|
44 |
"MetacelloProjectRegistration projectSpecs"
|
|
45 |
|
|
46 |
^ self configurationProjectSpecs , self baselineProjectSpecs
|
|
47 |
! !
|
|
48 |
|
|
49 |
!MetacelloProjectRegistry methodsFor:'copying'!
|
|
50 |
|
|
51 |
postCopy
|
|
52 |
super postCopy.
|
|
53 |
baselineRegistry := self baselineRegistry copy.
|
|
54 |
configurationRegistry := self configurationRegistry copy
|
|
55 |
! !
|
|
56 |
|
|
57 |
!MetacelloProjectRegistry methodsFor:'initialization'!
|
|
58 |
|
|
59 |
primeRegistryFromImage
|
|
60 |
"MetacelloProjectRegistration primeRegistryFromImage"
|
|
61 |
|
|
62 |
MetacelloProjectRegistration configurationClasses
|
|
63 |
do: [ :cl |
|
|
64 |
(self configurationRegistry includesKey: cl name asString)
|
|
65 |
ifFalse: [
|
|
66 |
"not registered"
|
|
67 |
cl project currentVersion
|
|
68 |
ifNotNil: [ :version |
|
|
69 |
| projectSpec |
|
|
70 |
projectSpec := (version project projectSpec
|
|
71 |
name: (MetacelloScriptEngine baseNameOf: cl name asString);
|
|
72 |
className: cl name asString;
|
|
73 |
versionString: version versionString;
|
|
74 |
repositories: version project projectPackage repositories copy;
|
|
75 |
yourself) asConfigurationProjectSpec.
|
|
76 |
projectSpec asProjectRegistration
|
|
77 |
loadedInImage: true;
|
|
78 |
registerProject ] ] ].
|
|
79 |
MetacelloProjectRegistration baselineClasses
|
|
80 |
do: [ :cl |
|
|
81 |
(self baselineRegistry includesKey: cl name asString)
|
|
82 |
ifFalse: [
|
|
83 |
"not registered"
|
|
84 |
cl project currentVersion
|
|
85 |
ifNotNil: [ :version |
|
|
86 |
| projectSpec |
|
|
87 |
projectSpec := (version project projectSpec
|
|
88 |
name: (MetacelloScriptEngine baseNameOf: cl name asString);
|
|
89 |
repositories: version project projectPackage repositories copy;
|
|
90 |
yourself) asBaselineProjectSpec.
|
|
91 |
projectSpec asProjectRegistration
|
|
92 |
loadedInImage: true;
|
|
93 |
registerProject ] ] ]
|
|
94 |
! !
|
|
95 |
|
|
96 |
!MetacelloProjectRegistry methodsFor:'querying'!
|
|
97 |
|
|
98 |
projectSpecForClassNamed: aClassName ifAbsent: absentBlock
|
|
99 |
^ (self configurationRegistry
|
|
100 |
at: aClassName
|
|
101 |
ifAbsent: [ ^ (self baselineRegistry at: aClassName ifAbsent: [^absentBlock value]) baselineProjectSpec ])
|
|
102 |
configurationProjectSpec
|
|
103 |
!
|
|
104 |
|
|
105 |
registrationForClassNamed: aClassName ifAbsent: absentBlock
|
|
106 |
| baseName |
|
|
107 |
baseName := MetacelloScriptEngine baseNameOf: aClassName.
|
|
108 |
self configurationRegistry at: aClassName ifPresent: [ :registration | ^ registration ].
|
|
109 |
self baselineRegistry at: aClassName ifPresent: [ :registration | ^ registration ].
|
|
110 |
self configurationRegistry at: 'ConfigurationOf' , baseName ifPresent: [ :registration | ^ registration ].
|
|
111 |
self baselineRegistry at: 'BaselineOf' , baseName ifPresent: [ :registration | ^ registration ].
|
|
112 |
^ absentBlock value
|
|
113 |
! !
|
|
114 |
|
|
115 |
!MetacelloProjectRegistry methodsFor:'registration'!
|
|
116 |
|
|
117 |
registerProjectRegistration: aMetacelloProjectRegistration
|
|
118 |
"unconditionally register <newRegistration> ... use with care"
|
|
119 |
|
|
120 |
aMetacelloProjectRegistration configurationProjectSpec
|
|
121 |
ifNotNil: [ :spec |
|
|
122 |
self configurationRegistry
|
|
123 |
at: spec className
|
|
124 |
ifPresent: [ :existing |
|
|
125 |
(existing configurationProjectSpec registrationsCompareEqual: spec)
|
|
126 |
ifFalse: [
|
|
127 |
Transcript
|
|
128 |
cr;
|
|
129 |
show:
|
|
130 |
'REGISTRATION OF INCOMPATABLE PROJECTS: ' , existing printString , ' REPLACED BY '
|
|
131 |
, aMetacelloProjectRegistration printString ] ].
|
|
132 |
spec immutable.
|
|
133 |
self configurationRegistry at: spec className put: aMetacelloProjectRegistration ].
|
|
134 |
aMetacelloProjectRegistration baselineProjectSpec
|
|
135 |
ifNotNil: [ :spec |
|
|
136 |
self baselineRegistry
|
|
137 |
at: spec className
|
|
138 |
ifPresent: [ :existing |
|
|
139 |
(existing baselineProjectSpec registrationsCompareEqual: spec)
|
|
140 |
ifFalse: [
|
|
141 |
Transcript
|
|
142 |
cr;
|
|
143 |
show:
|
|
144 |
'REGISTRATION OF INCOMPATABLE PROJECTS: ' , existing printString , ' REPLACED BY '
|
|
145 |
, aMetacelloProjectRegistration printString ] ].
|
|
146 |
spec immutable.
|
|
147 |
self baselineRegistry at: spec className put: aMetacelloProjectRegistration ].
|
|
148 |
aMetacelloProjectRegistration immutable
|
|
149 |
!
|
|
150 |
|
|
151 |
registrationFor: aMetacelloProjectRegistration ifPresent: presentBlock ifAbsent: absentBlock
|
|
152 |
| baseName |
|
|
153 |
baseName := aMetacelloProjectRegistration baseName.
|
|
154 |
aMetacelloProjectRegistration configurationProjectSpec
|
|
155 |
ifNotNil: [ :spec | self configurationRegistry at: spec className ifPresent: [ :existing | ^ presentBlock value: existing ] ].
|
|
156 |
aMetacelloProjectRegistration baselineProjectSpec
|
|
157 |
ifNotNil: [ :spec | self baselineRegistry at: spec className ifPresent: [ :existing | ^ presentBlock value: existing ] ].
|
|
158 |
self configurationRegistry
|
|
159 |
at: 'ConfigurationOf' , baseName
|
|
160 |
ifPresent: [ :existing | ^ presentBlock value: existing ].
|
|
161 |
self baselineRegistry at: 'BaselineOf' , baseName ifPresent: [ :existing | ^ presentBlock value: existing ].
|
|
162 |
^ absentBlock value
|
|
163 |
!
|
|
164 |
|
|
165 |
unregisterProjectRegistration: aMetacelloProjectRegistration
|
|
166 |
aMetacelloProjectRegistration configurationProjectSpec
|
|
167 |
ifNotNil: [ :spec |
|
|
168 |
self configurationRegistry
|
|
169 |
removeKey: spec className
|
|
170 |
ifAbsent: [ self error: 'unexpectedly missing project registration' ] ].
|
|
171 |
aMetacelloProjectRegistration baselineProjectSpec
|
|
172 |
ifNotNil: [ :spec | self baselineRegistry removeKey: spec className ifAbsent: [ self error: 'unexpectedly missing project registration' ] ]
|
|
173 |
! !
|
|
174 |
|
|
175 |
!MetacelloProjectRegistry class methodsFor:'documentation'!
|
|
176 |
|
|
177 |
version_SVN
|
|
178 |
^ '$Id:: $'
|
|
179 |
! !
|