forked from SeasideSt/Grease
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGRPackage.class.st
More file actions
193 lines (160 loc) · 5.44 KB
/
GRPackage.class.st
File metadata and controls
193 lines (160 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
"
I am a platform independent package representation. I know my name, description, my dependencies, the license and the repository URL. Packages are declared by creating a class side extension method that answers a configured package instance. The expression
GRPackage packages
answers the collection of the complete package graph.
"
Class {
#name : #GRPackage,
#superclass : #GRObject,
#instVars : [
'name',
'description',
'dependencies',
'license',
'url'
],
#category : 'Grease-Core'
}
{ #category : #querying }
GRPackage class >> grPackages [
"Answer a list of all registered packages. A package is registered by adding a class extension to the receiving class answering an instance of the receiving class."
| packages package |
packages := Dictionary new.
self class selectors do: [ :each |
(each numArgs = 0 and: [ each ~= #grPackages ]) ifTrue: [
package := self perform: each.
packages at: package name put: package ] ].
packages do: [ :each | each resolveWith: packages ].
^ packages values
]
{ #category : #accessing }
GRPackage class >> greaseCore [
^ self new
name: 'Grease-Core';
description: 'The main package of the Grease compatibility layer.';
url: #greaseUrl;
yourself
]
{ #category : #private }
GRPackage >> addDependenciesTo: aCollection [
(aCollection includes: self) ifFalse: [
self dependencies
do: [ :each | each addDependenciesTo: aCollection ].
aCollection add: self ].
^ aCollection
]
{ #category : #dependencies }
GRPackage >> addDependency: aString [
dependencies add: aString
]
{ #category : #dependencies }
GRPackage >> allDependencies [
"Answer all dependencies on which this package depends."
^ self addDependenciesTo: OrderedCollection new
]
{ #category : #dependencies }
GRPackage >> dependencies [
"Return a collection of package names on which this package depends."
^ dependencies
]
{ #category : #accessing }
GRPackage >> description [
"Answer a short description of the package."
^ description
]
{ #category : #accessing }
GRPackage >> description: aString [
description := aString
]
{ #category : #'accessing-repositories' }
GRPackage >> greaseUrl [
^ 'http://smalltalkhub.com/mc/Seaside/Grease11/main'
]
{ #category : #initialization }
GRPackage >> initialize [
super initialize.
dependencies := OrderedCollection new.
license := #MIT
]
{ #category : #testing }
GRPackage >> isLGPL [
^ self license = #LGPL
]
{ #category : #testing }
GRPackage >> isMIT [
^ self license = #MIT
]
{ #category : #accessing }
GRPackage >> license [
"Answer the current license of this package, by default MIT is used."
^ license
]
{ #category : #accessing }
GRPackage >> license: aSymbol [
license := aSymbol
]
{ #category : #accessing }
GRPackage >> name [
"Answer the name of the package. This string should be useable to identify the platform specific native package object, e.g. the Monticello package name."
^ name
]
{ #category : #accessing }
GRPackage >> name: aString [
name := aString
]
{ #category : #printing }
GRPackage >> printOn: aStream [
super printOn: aStream.
aStream nextPut: $(; nextPutAll: self name; nextPut: $)
]
{ #category : #dependencies }
GRPackage >> resolveWith: aDictionary [
dependencies := dependencies
collect: [ :each |
aDictionary at: each ifAbsent: [
"if Foo-Pharo-Bar fails try Foo-Pharo20-Bar and Foo-Pharo30-Bar"
(each indexOfSubCollection: '-Pharo-' startingAt: 1) ~= 0 ifTrue: [
"try -Pharo40-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Pharo40-') ifAbsent: [
"try -Pharo50-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Pharo50-') ifAbsent: [
"try -Pharo60-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Pharo60-') ifAbsent: [
"try -Pharo70-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Pharo70-') ifAbsent: [
"try -Pharo90-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Pharo90-') ifAbsent: [
"try -Squeak-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Squeak-') ifAbsent: [
"try -Squeak5-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Squeak5-') ifAbsent: [
"try -Squeak6-"
aDictionary at: (each copyReplaceAll: '-Pharo-' with: '-Squeak6-') ifAbsent: [
"specific for Grease-Slime"
aDictionary at: (each copyReplaceAll: 'Grease-Pharo-Slime' with: 'Grease-Slime') ifAbsent: [
self error: self name printString , ' depends on unknown package ' , each printString ] ] ] ] ] ] ] ] ] ] ] ]
]
{ #category : #'accessing-repositories' }
GRPackage >> seasideAddonsUrl [
^ 'http://smalltalkhub.com/mc/Seaside/Seaside30Addons/main'
]
{ #category : #'accessing-repositories' }
GRPackage >> seasideLGPLUrl [
^ 'http://smalltalkhub.com/mc/Seaside/Seaside30LGPL/main'
]
{ #category : #'accessing-repositories' }
GRPackage >> seasideUrl [
^ 'http://smalltalkhub.com/mc/Seaside/Seaside31/main'
]
{ #category : #accessing }
GRPackage >> url [
"Answer the base-URL of the package. This string is only meaningful for platforms that can directly access Monticello repositories."
^ url isSymbol
ifTrue: [ self perform: url ]
ifFalse: [ url ]
]
{ #category : #accessing }
GRPackage >> url: aStringOrSymbol [
"Set the base-URL of the package, or a symbol referring to a method in this class that answers the URL. This setting is only meaningful for platforms that can directly access Monticello repositories."
url := aStringOrSymbol
]