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