73
|
1 |
"{ Package: 'stx:goodies/builder/reports' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Builder }"
|
|
4 |
|
|
5 |
Object subclass:#ReportFormat
|
|
6 |
instanceVariableNames:'report stream'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Builder-Reports-Formats'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!ReportFormat class methodsFor:'instance creation'!
|
|
14 |
|
|
15 |
named:aString
|
|
16 |
"Return new format with given name. Name may be
|
|
17 |
either class or symbolic name"
|
|
18 |
|
|
19 |
self allSubclassesDo:
|
|
20 |
[:cls |
|
|
21 |
(cls isAbstract not and:[cls name = aString or:[ cls symbolicNames includes:aString ]])
|
|
22 |
ifTrue:[ ^ cls new ] ].
|
|
23 |
|
|
24 |
self error:'No format named ' , aString.
|
|
25 |
|
|
26 |
"
|
|
27 |
ReportFormat named: 'tap'
|
|
28 |
ReportFormat named: 'JUnitFormat'
|
|
29 |
ReportFormat named: 'NONEX'
|
|
30 |
"
|
|
31 |
|
|
32 |
"Created: / 04-08-2011 / 11:47:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
33 |
!
|
|
34 |
|
|
35 |
new
|
|
36 |
"return an initialized instance"
|
|
37 |
|
|
38 |
^ self basicNew initialize.
|
|
39 |
! !
|
|
40 |
|
|
41 |
!ReportFormat class methodsFor:'accessing'!
|
|
42 |
|
|
43 |
symbolicNames
|
|
44 |
"Returns a collection of symbolic names for this format"
|
|
45 |
|
|
46 |
^ self subclassResponsibility
|
|
47 |
|
|
48 |
"Modified (comment): / 04-08-2011 / 11:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
49 |
! !
|
|
50 |
|
|
51 |
!ReportFormat class methodsFor:'testing'!
|
|
52 |
|
|
53 |
isAbstract
|
|
54 |
|
|
55 |
^self == HDReportFormat
|
|
56 |
|
|
57 |
"Created: / 04-08-2011 / 11:44:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
58 |
! !
|
|
59 |
|
|
60 |
!ReportFormat methodsFor:'accessing - defaults'!
|
|
61 |
|
|
62 |
defaultFileSuffix
|
|
63 |
|
|
64 |
^self subclassResponsibility
|
|
65 |
|
|
66 |
"Created: / 04-08-2011 / 12:47:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
67 |
! !
|
|
68 |
|
|
69 |
!ReportFormat methodsFor:'initialization'!
|
|
70 |
|
|
71 |
initialize
|
|
72 |
"Invoked when a new instance is created."
|
|
73 |
|
|
74 |
"/ please change as required (and remove this comment)
|
|
75 |
"/ stream := nil.
|
|
76 |
"/ suite := nil.
|
|
77 |
|
|
78 |
"/ super initialize. -- commented since inherited method does nothing
|
|
79 |
!
|
|
80 |
|
|
81 |
report: aReport stream: aStream
|
|
82 |
|
|
83 |
report := aReport.
|
|
84 |
(aStream isKindOf: EncodedStream) ifTrue:[
|
|
85 |
stream := aStream.
|
|
86 |
] ifFalse:[
|
|
87 |
stream := EncodedStream stream: aStream encoder: CharacterEncoder encoderForUTF8
|
|
88 |
]
|
|
89 |
|
|
90 |
"Created: / 03-08-2011 / 18:54:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!ReportFormat methodsFor:'stream - utilities'!
|
|
94 |
|
|
95 |
stream
|
|
96 |
|
|
97 |
^ stream
|
|
98 |
|
|
99 |
!
|
|
100 |
|
|
101 |
streamClose
|
|
102 |
|
|
103 |
"Temporarily closes the stream"
|
|
104 |
|
|
105 |
"stream is EncodedStream..."
|
|
106 |
stream stream close.
|
|
107 |
|
|
108 |
"Created: / 12-08-2011 / 09:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
109 |
!
|
|
110 |
|
|
111 |
streamFlush
|
|
112 |
|
|
113 |
"Temporarily closes the stream"
|
|
114 |
|
|
115 |
"stream is EncodedStream..."
|
|
116 |
stream stream flush.
|
|
117 |
|
|
118 |
"Created: / 12-08-2011 / 09:35:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
119 |
!
|
|
120 |
|
|
121 |
streamOpenForAppend
|
|
122 |
|
|
123 |
"Open previously closes stream"
|
|
124 |
|
|
125 |
| s |
|
|
126 |
"stream is EncodedStream..."
|
|
127 |
s := stream stream.
|
|
128 |
s isExternalStream ifTrue:[
|
|
129 |
s isOpen ifTrue:[s close].
|
|
130 |
s openForWriting.
|
|
131 |
s setToEnd.
|
|
132 |
].
|
|
133 |
|
|
134 |
"Created: / 12-08-2011 / 09:31:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
135 |
! !
|
|
136 |
|
|
137 |
!ReportFormat methodsFor:'writing'!
|
|
138 |
|
|
139 |
writeFooter
|
|
140 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
141 |
|
|
142 |
^ self subclassResponsibility
|
|
143 |
!
|
|
144 |
|
|
145 |
writeHeader
|
|
146 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
147 |
|
|
148 |
^ self subclassResponsibility
|
|
149 |
! !
|
|
150 |
|
|
151 |
!ReportFormat methodsFor:'writing - utilities'!
|
|
152 |
|
|
153 |
encode: aString
|
|
154 |
|
|
155 |
^Report encode: aString
|
|
156 |
|
|
157 |
"Created: / 03-08-2011 / 14:37:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
158 |
! !
|
|
159 |
|
|
160 |
!ReportFormat class methodsFor:'documentation'!
|
|
161 |
|
|
162 |
version
|
|
163 |
^ '$Header$'
|
|
164 |
!
|
|
165 |
|
|
166 |
version_CVS
|
|
167 |
^ '$Header$'
|
|
168 |
!
|
|
169 |
|
|
170 |
version_SVN
|
|
171 |
^ '§Id: Builder__ReportFormat.st 262 2011-10-07 10:09:53Z vranyj1 §'
|
|
172 |
! !
|