-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPyramidSaveModelVerifier.class.st
More file actions
161 lines (125 loc) · 3.9 KB
/
PyramidSaveModelVerifier.class.st
File metadata and controls
161 lines (125 loc) · 3.9 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
Class {
#name : #PyramidSaveModelVerifier,
#superclass : #Object,
#instVars : [
'nextVerifiers',
'showBlock',
'verifyBlock'
],
#category : #'Pyramid-Bloc-plugin-save'
}
{ #category : #constructor }
PyramidSaveModelVerifier class >> classIsValid [
^ self new
verifyBlock: [ :model | model savingClassName isValidGlobalName ];
showBlock: [ :view | view showClassIsNotValidError ];
yourself.
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> classPackageIsEqual [
^ self new
verifyBlock: [ :model |
Smalltalk globals
at: model savingClassName asSymbol
ifPresent: [ :class | "
Model = class package >> OK
Model = class package '-' class packageTag >> OK
KO"
class package name = model savingPackageName
ifTrue: [ true ]
ifFalse: [
(model savingPackageName endsWith: class packageTag name)
ifFalse: [ false ]
ifTrue: [
model savingPackageName = (class package name , '-'
, class packageTag name) ] ] ]
ifAbsent: [ true ] ];
showBlock: [ :view | view showClassPackageIsNotEqualError ];
yourself
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> methodIsValid [
^ self new
verifyBlock: [ :model | model savingMethodName isValidSelector ];
showBlock: [ :view | view showMethodIsNotValidError ];
yourself.
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> modelNotNil [
^ self new
verifyBlock: [ :model | model isNotNil ];
showBlock: [ :view | view showModelNilError ];
yourself
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> packageIsValid [
^ self new
verifyBlock: [ :model |
($- split: model savingPackageName) first isValidGlobalName ];
showBlock: [ :view | view showPackageIsNotValidError ];
yourself
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> projectModelNotNil [
^ self new
verifyBlock: [ :model | model projectModel isNotNil ];
showBlock: [ :view | view showProjectModelNilError ];
yourself
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> verifierNoError [
^ self modelNotNil addNext: (self projectModelNotNil addNext:
(self methodIsValid addNext: (self packageIsValid addNext:
(self classIsValid addNext: self classPackageIsEqual))))
]
{ #category : #constructor }
PyramidSaveModelVerifier class >> verifierNoErrorForInputsView [
^ self modelNotNil addNext: (self projectModelNotNil addNext:
self methodIsValid;
addNext: self classIsValid;
addNext: (self packageIsValid addNext:
(self classIsValid addNext: self classPackageIsEqual)))
]
{ #category : #initialization }
PyramidSaveModelVerifier >> addNext: aVerifier [
self nextVerifiers add: aVerifier
]
{ #category : #'as yet unclassified' }
PyramidSaveModelVerifier >> allErrors: aSaveModel [
(self verifyBlock value: aSaveModel) ifFalse: [ ^ { self } ].
^ self nextVerifiers flatCollect: [ :each | each allErrors: aSaveModel ]
]
{ #category : #'as yet unclassified' }
PyramidSaveModelVerifier >> initialize [
super initialize.
nextVerifiers := OrderedCollection new
]
{ #category : #'as yet unclassified' }
PyramidSaveModelVerifier >> nextVerifiers [
^ nextVerifiers
]
{ #category : #accessing }
PyramidSaveModelVerifier >> showBlock [
^ showBlock
]
{ #category : #accessing }
PyramidSaveModelVerifier >> showBlock: anObject [
showBlock := anObject
]
{ #category : #'as yet unclassified' }
PyramidSaveModelVerifier >> showOn: aView [
self showBlock value: aView.
]
{ #category : #drawing }
PyramidSaveModelVerifier >> verify: aModel [
(self verifyBlock value: aModel) ifFalse: [ ^ false ].
^ self nextVerifiers allSatisfy: [ :each | each verify: aModel ]
]
{ #category : #accessing }
PyramidSaveModelVerifier >> verifyBlock [
^ verifyBlock.
]
{ #category : #accessing }
PyramidSaveModelVerifier >> verifyBlock: anObject [
verifyBlock := anObject
]