Skip to content

Commit 8dc5673

Browse files
committed
Get rid of unused Rowan globals: knowRepositories and knowProjects ... defer to image for queries and platforms that can manage with shared globals can implement support in the platform image class:
58 run, 57 passes, 1 expected defects, 0 failures, 0 errors, 0 unexpected passes
1 parent ec476d5 commit 8dc5673

File tree

5 files changed

+53
-69
lines changed

5 files changed

+53
-69
lines changed

tonel/Rowan-Core/Rowan.class.st

+13-53
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ Class {
88
#name : 'Rowan',
99
#superclass : 'Object',
1010
#classInstVars : [
11-
'knownRepositories',
1211
'configuration',
13-
'platform',
14-
'knownProjects'
12+
'platform'
1513
],
1614
#category : 'Rowan-Core'
1715
}
@@ -24,15 +22,6 @@ Rowan class >> addProject: aRwProjectSpecification [
2422
^ self image addProject: aRwProjectSpecification
2523
]
2624

27-
{ #category : 'public' }
28-
Rowan class >> addRepositoryNamed: urlString [
29-
"Register a repository.
30-
Note that duplicate registrations are ignored, since knownRepositories is a Set"
31-
32-
knownRepositories
33-
add: (CypRepository onUrl: (CypUrl fromString: urlString))
34-
]
35-
3625
{ #category : 'public' }
3726
Rowan class >> configuration [
3827

@@ -79,25 +68,12 @@ Rowan class >> image [
7968

8069
{ #category : 'private' }
8170
Rowan class >> initialize [
82-
"Rowan initialize."
83-
84-
knownRepositories := Set new.
85-
platform := RwPlatform current.
86-
configuration := platform defaultConfiguration.
87-
platform initialize.
88-
knownProjects := Dictionary new
89-
]
9071

91-
{ #category : 'public' }
92-
Rowan class >> knownProjects [
93-
94-
^ knownProjects
95-
]
72+
"Rowan initialize."
9673

97-
{ #category : 'public' }
98-
Rowan class >> knownRepositories [
99-
100-
^knownRepositories
74+
platform := RwPlatform current.
75+
configuration := platform defaultConfiguration.
76+
platform initialize
10177
]
10278

10379
{ #category : 'public' }
@@ -134,30 +110,6 @@ Rowan class >> loadedPackagesNamed: someNames [
134110
^RwPackageSet withAll: (loadedPackages select: [:each | each notNil])
135111
]
136112

137-
{ #category : 'public' }
138-
Rowan class >> packageNamed: aName [
139-
"Answer a PackageReference, if the given package name is unique in all registered repositories. If the name resolves 0 or >=2 times, error."
140-
141-
| token resolutions |
142-
token := 'notFound'.
143-
resolutions := (self knownRepositories
144-
collect: [:repo | repo packageNamed: aName ifAbsent: [token]])
145-
select: [:each | each ~~ token].
146-
resolutions isEmpty ifTrue: [self error: 'Named package not found'].
147-
resolutions size > 1
148-
ifTrue: [self error: 'Package name is not unique in registered repositories.'].
149-
^resolutions any
150-
]
151-
152-
{ #category : 'public' }
153-
Rowan class >> packagesNamed: someNames [
154-
"Create a PackageSet by names only, resolved from known repositories"
155-
156-
| packageRefs |
157-
packageRefs := someNames collect: [:aName | self packageNamed: aName].
158-
^RwPackageSet withAll: packageRefs
159-
]
160-
161113
{ #category : 'public tools' }
162114
Rowan class >> packageTools [
163115

@@ -188,6 +140,14 @@ Rowan class >> projectNamed: aString ifAbsent: absentBlock [
188140
^ self image projectNamed: aString ifAbsent: absentBlock
189141
]
190142

143+
{ #category : 'public' }
144+
Rowan class >> projectNames [
145+
146+
"Return list of project names"
147+
148+
^ self image projectNames
149+
]
150+
191151
{ #category : 'public tools' }
192152
Rowan class >> projectTools [
193153

tonel/Rowan-GemStone/RwGsImage.class.st

+20
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,26 @@ RwGsImage class >> projectNamed: aString ifAbsent: absentBlock [
161161
^ absentBlock value ]
162162
]
163163

164+
{ #category : 'querying' }
165+
RwGsImage class >> projectNames [
166+
167+
"Return list of project names"
168+
169+
| currentUserId projectNames |
170+
currentUserId = self currentUserId.
171+
projectNames := Set new.
172+
projectNames addAll: self _projectRegistry keys.
173+
AllUsers
174+
do: [ :userProfile |
175+
| userId |
176+
userId := userProfile userId.
177+
userId ~= currentUserId
178+
ifTrue: [
179+
(self _projectRegistryForUserId: userId)
180+
ifNotNil: [ :projectRegistry | projectNames addAll: projectRegistry keys ] ] ].
181+
^ projectNames
182+
]
183+
164184
{ #category : 'querying' }
165185
RwGsImage class >> removeProject: aRwProjectSpecification [
166186

tonel/Rowan-Tode/RwPrjRegistryTool.class.st

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ EXAMPLES
2828

2929
{ #category : 'smalltalk api' }
3030
RwPrjRegistryTool >> registeredSpecNames [
31-
^ self registry keys
31+
32+
^ Rowan projectNames
3233
]
3334

3435
{ #category : 'smalltalk api' }
3536
RwPrjRegistryTool >> registeredSpecs [
36-
^ self registry values
37+
38+
^ Rowan projectNames collect: [ :aString | Rowan projectNamed: aString ]
3739
]
3840

3941
{ #category : 'smalltalk api' }

tonel/Rowan-Tode/RwSpecification.class.st

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,6 @@ RwSpecification >> registerForced [
110110

111111
{ #category : 'registering' }
112112
RwSpecification >> unregister [
113-
Rowan knownProjects removeKey: self specName ifAbsent: [ ]
113+
114+
Rowan removeProject: self
114115
]

tonel/Rowan-Tode/RwUrlTest.class.st

+14-13
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ RwUrlTest >> sampleUrlStrings [
4747

4848
{ #category : 'tests' }
4949
RwUrlTest >> testAsRwRepository [
50-
| repos loadSpec repoRoot testRepoPath |
51-
loadSpec := Rowan projectTools registry registry at: 'Rowan' ifAbsent: [ ^ self ].
52-
repoRoot := loadSpec repoSpec repositoryRootPath.
53-
testRepoPath := repoRoot , '/testRepositories'.
54-
repos := {('cypress:' , testRepoPath , '/cypress/').
55-
('filetree://' , testRepoPath , '/filetree/').
56-
('tonel:' , testRepoPath , '/tonel/')}
57-
collect: [ :urlString | urlString -> urlString asRwRepository ].
58-
repos
59-
do: [ :assoc |
60-
| repo x y |
61-
repo := assoc value.
62-
self assert: (x := repo url) = (y := assoc key) ]
50+
51+
| repos loadSpec repoRoot testRepoPath |
52+
loadSpec := Rowan projectNamed: 'Rowan' ifAbsent: [ ^ self ].
53+
repoRoot := loadSpec repoSpec repositoryRootPath.
54+
testRepoPath := repoRoot , '/testRepositories'.
55+
repos := {('cypress:' , testRepoPath , '/cypress/').
56+
('filetree://' , testRepoPath , '/filetree/').
57+
('tonel:' , testRepoPath , '/tonel/')}
58+
collect: [ :urlString | urlString -> urlString asRwRepository ].
59+
repos
60+
do: [ :assoc |
61+
| repo x y |
62+
repo := assoc value.
63+
self assert: (x := repo url) = (y := assoc key) ]
6364
]
6465

6566
{ #category : 'tests' }

0 commit comments

Comments
 (0)