-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #879 from pillar-markup/reportWriter
Report writer
- Loading branch information
Showing
11 changed files
with
252 additions
and
55 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/Microdown-BookTester-Tests/MicAnalysisReportWriterTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Class { | ||
#name : 'MicAnalysisReportWriterTest', | ||
#superclass : 'TestCase', | ||
#category : 'Microdown-BookTester-Tests', | ||
#package : 'Microdown-BookTester-Tests' | ||
} | ||
|
||
{ #category : 'tests' } | ||
MicAnalysisReportWriterTest >> testWithEmptyResults [ | ||
|
||
self assert: MicAnalysisReportWriter new report isEmpty | ||
] | ||
|
||
{ #category : 'tests' } | ||
MicAnalysisReportWriterTest >> testWithResults [ | ||
|
||
| reporter | | ||
reporter := MicAnalysisReportWriter new | ||
addResults: { MicBrokenSyncDefinition new }; | ||
addResults: { MicBrokenSyncOriginDefinition new }. | ||
self assert: reporter results size equals: 2. | ||
self deny: reporter report isEmpty | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
" | ||
I'm a little util classes that encapsulates writing reports about analyses. | ||
" | ||
Class { | ||
#name : 'MicAnalysisReportWriter', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'results' | ||
], | ||
#category : 'Microdown-BookTester', | ||
#package : 'Microdown-BookTester' | ||
} | ||
|
||
{ #category : 'adding' } | ||
MicAnalysisReportWriter >> addResults: aCollection [ | ||
|
||
results addAll: aCollection | ||
] | ||
|
||
{ #category : 'reporting' } | ||
MicAnalysisReportWriter >> buildReportOn: str [ | ||
|
||
| dict | | ||
dict := results groupedBy: [ :each | each class ]. | ||
dict keysAndValuesDo: [ :k :v | | ||
str cr; nextPutAll: '## ' ;nextPutAll: k headerString; cr; cr. | ||
self reportElementsOn: str. | ||
str cr; cr. | ||
] | ||
] | ||
|
||
{ #category : 'reporting' } | ||
MicAnalysisReportWriter >> buildReportSTONFormatOn: str [ | ||
|
||
| dict list | | ||
dict := results groupedBy: [ :each | each class ]. | ||
dict keysAndValuesDo: [ :k :v | |array| | ||
array := Array new: 2. | ||
list := OrderedCollection new. | ||
self reportElementsSTONFormatOn: list. | ||
list := list asArray. | ||
array | ||
at: 1 put: (Association new key: 'type' value: k errorType); | ||
at: 2 put: list. | ||
(String streamContents: [ :out | STON put: array onStream: str ]) | ||
] | ||
] | ||
|
||
{ #category : 'initialization' } | ||
MicAnalysisReportWriter >> initialize [ | ||
|
||
super initialize. | ||
results := OrderedCollection new | ||
] | ||
|
||
{ #category : 'reporting' } | ||
MicAnalysisReportWriter >> report [ | ||
|
||
^ String streamContents: [ :str | | ||
self buildReportOn: str | ||
] | ||
] | ||
|
||
{ #category : 'reporting' } | ||
MicAnalysisReportWriter >> reportElementsOn: aStream [ | ||
|
||
results | ||
do: [ :each | aStream tab; nextPutAll: each explanation ] | ||
separatedBy: [ aStream cr ] | ||
|
||
] | ||
|
||
{ #category : 'reporting' } | ||
MicAnalysisReportWriter >> reportElementsSTONFormatOn: aList [ | ||
|
||
results do: [ :each | aList add: each stonFormatExplanation ]. | ||
|
||
] | ||
|
||
{ #category : 'reporting' } | ||
MicAnalysisReportWriter >> reportSTONFormat [ | ||
|
||
^ String streamContents: [ :str | | ||
self buildReportSTONFormatOn: str | ||
] | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MicAnalysisReportWriter >> results [ | ||
|
||
^ results | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MicAnalysisReportWriter >> results: anObject [ | ||
|
||
results := anObject | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.