author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 05 Oct 2015 18:24:43 +0100 | |
changeset 25 | 0ab1d8f0f793 |
parent 21 | c88f472e1c23 |
permissions | -rw-r--r-- |
15
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1 |
"{ Package: 'stx:goodies/cypress' }" |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
2 |
|
25
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
4 |
|
15
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
5 |
CypressAbstractReaderWriter subclass:#CypressAbstractReader |
18 | 6 |
instanceVariableNames:'packageId' |
15
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
7 |
classVariableNames:'' |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
8 |
poolDictionaries:'' |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
9 |
category:'Cypress-New-Reader & Writer' |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
10 |
! |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
11 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
12 |
!CypressAbstractReader class methodsFor:'documentation'! |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
13 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
14 |
documentation |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
15 |
" |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
16 |
Base abstract class for reading Cypress packages. Subclasses may |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
17 |
implement various versions of the 'standard'. |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
18 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
19 |
[author:] |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
20 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
21 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
[instance variables:] |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
[class variables:] |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
25 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
26 |
[see also:] |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
27 |
CypressReader |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
28 |
CypressFiletreeReader |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
29 |
|
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
30 |
" |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
31 |
! ! |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
32 |
|
25
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
33 |
!CypressAbstractReader class methodsFor:'reading'! |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
34 |
|
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
35 |
readPackageFrom: aDirectory |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
36 |
| repository pkgName | |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
37 |
|
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
38 |
repository := CypressRepository on: aDirectory directory. |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
39 |
pkgName := aDirectory baseName. |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
40 |
(pkgName endsWith: '.package') ifTrue:[ |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
41 |
pkgName := pkgName copyTo: (pkgName size - "'.package' size"8) |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
42 |
]. |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
43 |
^ repository read: pkgName |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
44 |
|
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
45 |
"Created: / 05-10-2015 / 18:17:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
46 |
! ! |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
47 |
|
18 | 48 |
!CypressAbstractReader methodsFor:'reading'! |
49 |
||
21 | 50 |
readPackage: name as: packageIdOrNil from: directory |
51 |
| pkgdir pkg | |
|
52 |
||
53 |
pkgdir := CypressRepository packageDirectoryForPackageName: name in: directory. |
|
54 |
pkgdir isNil ifTrue:[ |
|
55 |
self error: 'No package named ', name ,' found in ', directory pathName. |
|
56 |
]. |
|
18 | 57 |
|
21 | 58 |
packageId := packageIdOrNil. |
59 |
||
60 |
pkg := CypressPackage new. |
|
61 |
self |
|
62 |
readPropertiesFor: pkg from: pkgdir; |
|
63 |
readClassesFor: pkg from: pkgdir; |
|
64 |
readExtensionsFor: pkg from: pkgdir. |
|
65 |
^pkg |
|
66 |
||
67 |
"Created: / 18-09-2012 / 13:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
18 | 68 |
! |
69 |
||
70 |
readPackage: name from: directory |
|
71 |
^self readPackage: name as: nil from: directory |
|
72 |
||
73 |
"Created: / 18-09-2012 / 09:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
74 |
! ! |
|
75 |
||
21 | 76 |
!CypressAbstractReader methodsFor:'reading-private'! |
77 |
||
78 |
readClass: name from: directory |
|
79 |
| clsdir cls | |
|
80 |
||
81 |
clsdir := directory / name. |
|
82 |
clsdir exists ifFalse:[ |
|
83 |
clsdir := clsdir withSuffix: self defaultFileSuffixForClass. |
|
84 |
]. |
|
85 |
clsdir exists ifFalse:[ |
|
86 |
self error: 'No such class in ', directory pathName. |
|
87 |
^nil. |
|
88 |
]. |
|
89 |
||
90 |
cls := CypressClass new. |
|
91 |
self |
|
92 |
readPropertiesFor: cls from: clsdir; |
|
93 |
readMethodsFor: cls from: clsdir. |
|
94 |
^cls |
|
95 |
||
96 |
"Created: / 18-09-2012 / 09:54:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
97 |
! |
|
98 |
||
99 |
readClassesFor: pkg from: directory |
|
100 |
||
101 |
directory directoryContentsAsFilenamesDo:[:each| |
|
102 |
each suffix = self defaultFileSuffixForClass ifTrue:[ |
|
103 |
pkg classes add: (self readClass: each baseName from: directory) |
|
104 |
] |
|
105 |
] |
|
106 |
||
107 |
"Created: / 18-09-2012 / 09:52:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
108 |
! |
|
109 |
||
110 |
readExtensionsFor: pkg from: directory |
|
111 |
||
112 |
directory directoryContentsAsFilenamesDo:[:each| |
|
113 |
each suffix = self defaultFileSuffixForExtensions ifTrue:[ |
|
114 |
| clsname dir | |
|
115 |
||
116 |
clsname := each withoutSuffix baseName. |
|
117 |
dir := each / 'class'. |
|
118 |
dir exists ifTrue:[ |
|
119 |
self readMethodsForClassNamed: clsname meta: true from: dir into: pkg extensions. |
|
120 |
]. |
|
121 |
dir := each / 'instance'. |
|
122 |
dir exists ifTrue:[ |
|
123 |
self readMethodsForClassNamed: clsname meta: false from: dir into: pkg extensions. |
|
124 |
] |
|
125 |
||
126 |
] |
|
127 |
] |
|
128 |
||
129 |
"Created: / 18-09-2012 / 10:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
130 |
! |
|
131 |
||
132 |
readMethod:arg1 from:arg2 |
|
133 |
"raise an error: must be redefined in concrete subclass(es)" |
|
134 |
||
135 |
^ self subclassResponsibility |
|
136 |
! |
|
137 |
||
138 |
readMethodsFor: cls from: directory |
|
139 |
| dir | |
|
140 |
||
141 |
(dir := directory / 'class') exists ifTrue:[ |
|
142 |
self readMethodsForClassNamed: cls name meta: true from: dir into: cls methods |
|
143 |
]. |
|
144 |
(dir := directory / 'instance') exists ifTrue:[ |
|
145 |
self readMethodsForClassNamed: cls name meta: false from: dir into: cls methods |
|
146 |
] |
|
147 |
||
148 |
"Created: / 18-09-2012 / 09:56:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
149 |
! |
|
150 |
||
151 |
readMethodsForClassNamed: clsname meta: isClassMethod from: dir into: collection |
|
152 |
||
153 |
dir directoryContentsAsFilenamesDo:[:each| |
|
154 |
each suffix = 'st' ifTrue:[ |
|
155 |
| mthd | |
|
156 |
||
157 |
mthd := self readMethod: each baseName from: dir. |
|
158 |
mthd meta: isClassMethod. |
|
159 |
mthd klass: clsname. |
|
160 |
collection add: mthd. |
|
161 |
] |
|
162 |
] |
|
163 |
||
164 |
"Created: / 18-09-2012 / 10:07:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
165 |
! |
|
166 |
||
167 |
readPropertiesFor: model from: directory |
|
168 |
| props propFile | |
|
169 |
||
170 |
propFile := directory / self defaultFileNameForProperties. |
|
171 |
props := propFile exists |
|
172 |
ifTrue:[CypressJSONReader parse: propFile] |
|
173 |
ifFalse:[Dictionary new]. |
|
174 |
model properties: props. |
|
175 |
||
176 |
"Created: / 18-09-2012 / 09:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
177 |
! ! |
|
178 |
||
15
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
179 |
!CypressAbstractReader class methodsFor:'documentation'! |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
180 |
|
25
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
181 |
version_HG |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
182 |
|
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
183 |
^ '$Changeset: <not expanded> $' |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
184 |
! |
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
185 |
|
15
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
186 |
version_SVN |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
187 |
^ '$Id:: $' |
31a33727c629
- Getting rid of old Cypress implementation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
188 |
! ! |
25
0ab1d8f0f793
Implemented utility method #readPackageForm:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
21
diff
changeset
|
189 |