Skip to content

Commit

Permalink
ErrorReport can now show problems with metadata.
Browse files Browse the repository at this point in the history
Also catches errors with broken files (#124).
  • Loading branch information
Vincent Opitz committed Jun 23, 2019
1 parent 4ab5f46 commit dfecf60
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
as yet unclassified
buildFileErrorReportString

| aString |
(self errorReport at: #files) isEmpty
ifTrue: [^ ' I loaded all additional files correctly.']
ifFalse:
[aString := ''.
self filesErrorReport keysAndValuesDo:
[:key :value | aString := aString, Character cr , key , ' ', value , '.'.
^ aString]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
as yet unclassified
buildMorphErrorReportString

| aString wronglyLoadedMorphs |
wronglyLoadedMorphs := self slidesErrorReport select:
[:each | each > 0].
(wronglyLoadedMorphs) isEmpty
ifTrue: [^ ' I loaded all morphs correctly.']
ifFalse:
[aString := ''.
wronglyLoadedMorphs keysAndValuesDo:
[:key :value | aString := aString , Character cr , key , ' is missing ' , value , ' morph(s)'].
^ aString].

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
completeErrorReport

^ self buildMorphErrorReportString , Character cr , self buildFileErrorReportString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
filesErrorReport

^ self errorReport at: #files
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ loadLayoutsFrom: aDirectory
sortedDirectories do: [:each |
| slide |
slide := self loadLayoutFromDirectory: layoutsPath / each.
self errorReport at: each
self slidesErrorReport at: each
put: (self morphFilesIn: layoutsPath / each) size - slide submorphs size]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
slide loading
loadMetadataFrom: aDirectory for: aSlide

| instanceVarDict |
(aDirectory /'metadata.dict') exists ifTrue:
[[instanceVarDict := Dictionary readFrom: (aDirectory readOnlyFileNamed: 'metadata.dict').
self update: aSlide with: instanceVarDict]
on: Error
do: [self filesErrorReport at: aDirectory/ 'metadata' asString put: 'file corrupted']]

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
slide loading
loadSlideFromDirectory: aDirectory

| slide instanceVar|
| slide |
slide := self presentation createSlideBack.
self loadMorphsFromDirectory: aDirectory intoSlide: slide.
(aDirectory / 'metadata.dict') exists ifTrue:
[instanceVar := Object readFrom: (aDirectory readOnlyFileNamed: 'metadata.dict').
"instanceVar := FileStream oldFileNamed: (aDirectory / ) fullName do: [:in | Object readFrom: in]."
self update:slide with: instanceVar.].
self loadMetadataFrom: aDirectory for: slide.
^ slide
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ loadSlidesFrom: aDirectory
slidesPath exists ifTrue:
[sortedDirectories := self sortedSubdirectories: slidesPath.
sortedDirectories do: [:each |
| slide |
| slide |
slide := self loadSlideFromDirectory: slidesPath / each.
self errorReport at: each
put: (self morphFilesIn: slidesPath / each) size - slide submorphs size].
self slidesErrorReport at: each put: (self morphFilesIn: slidesPath / each) size - slide submorphs size].
self presentation minimumSlideCount timesRepeat: [self presentation deleteSlideAt: 1]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ initialize-release
reset

self
errorReport: Dictionary new;
presentation: PSPresentation new
errorReport: (Dictionary newFrom:
{#slides -> Dictionary new.
#files -> Dictionary new});
presentation: PSPresentation new.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
slidesErrorReport

^ self errorReport at: #slides
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
"slidesDirectoryName" : "LM 7/24/2018 14:46" },
"instance" : {
"abandonMorph:" : "MK 7/20/2018 14:56",
"buildFileErrorReportString" : "VO 6/23/2019 12:09",
"buildMorphErrorReportString" : "VO 6/23/2019 12:09",
"checkLayoutDirectoryName:" : "JB 5/7/2019 22:03",
"checkMorphsInDirectory:" : "msob 5/23/2019 17:06",
"checkSlideDirectoryName:" : "mb 6/12/2019 18:15",
"completeErrorReport" : "VO 6/23/2019 11:56",
"errorReport" : "MK 7/20/2018 14:20",
"errorReport:" : "MK 7/20/2018 14:20",
"filesErrorReport" : "VO 6/23/2019 12:08",
"initialize" : "LM 7/24/2018 15:30",
"isEmptyDirectory:" : "VO 6/13/2019 16:51",
"isValidContentDirectory:namesSatisfy:" : "JB 6/13/2019 11:15",
Expand All @@ -19,20 +23,22 @@
"layoutName:" : "JB 5/7/2019 22:19",
"layoutsDirectoryName" : "msob 4/30/2019 15:38",
"loadLayoutFromDirectory:" : "JB 5/7/2019 22:17",
"loadLayoutsFrom:" : "mb 6/12/2019 18:03",
"loadLayoutsFrom:" : "VO 6/23/2019 12:09",
"loadMetadataFrom:for:" : "VO 6/23/2019 12:10",
"loadMorphFromStream:" : "LM 7/24/2018 15:22",
"loadMorphFromStream:testIn:" : "mb 6/12/2019 17:37",
"loadMorphInDirectory:fromFile:" : "LM 7/24/2018 14:27",
"loadMorphsFromDirectory:intoSlide:" : "VO 5/29/2019 17:20",
"loadPresentationFromDirectory:" : "mb 6/12/2019 18:10",
"loadSlideFromDirectory:" : "VO 5/29/2019 16:47",
"loadSlidesFrom:" : "mb 6/12/2019 18:02",
"loadSlideFromDirectory:" : "VO 6/22/2019 16:13",
"loadSlidesFrom:" : "VO 6/23/2019 12:10",
"morph:survivesOneCycleIn:" : "LM 7/25/2018 12:21",
"morphFilesIn:" : "VO 5/29/2019 17:18",
"presentation" : "MK 7/20/2018 14:20",
"presentation:" : "MK 7/20/2018 14:20",
"reset" : "LM 7/24/2018 15:31",
"reset" : "VO 6/23/2019 12:07",
"slidesDirectoryName" : "LM 7/24/2018 14:54",
"slidesErrorReport" : "VO 6/23/2019 12:08",
"sortedMorphFilesIn:" : "VO 5/29/2019 17:20",
"sortedSubdirectories:" : "mb 6/12/2019 17:27",
"update:with:" : "msob 5/23/2019 17:35",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ loadPresentationFromDirectory: aDirectory
loader := PSPresentationLoader new.
(loader loadPresentationFromDirectory: aDirectory)
ifNotNil: [:presentation |
self updatePresentation: presentation withErrorReport: loader errorReport]
self updatePresentation: presentation withErrorReport: loader completeErrorReport]
ifNil: [UIManager default inform: self loadCorruptionMessage]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
slide miniatures
updatePresentation: aPSPresentation withErrorReport: aDictionary
updatePresentation: aPSPresentation withErrorReport: aString

self
presentation: aPSPresentation;
selectSlideNumber: 1;
updateSlideMiniaturesCompletely;
showErrorReport: aDictionary
updateSlideMiniaturesCompletely.
UIManager inform: aString
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"askForInputWithQuestion:withInitial:andDo:onError:" : "VO 6/12/2019 15:43",
"barFrameFrom:height:" : "LB 6/22/2018 18:28",
"bringToFrontButtonData" : "VO 5/23/2019 16:29",
"buildErrorReportString:" : "MK 6/8/2018 18:38",
"buildWith:" : "VO 5/29/2019 17:53",
"buttonBarTopData" : "VO 6/5/2019 16:45",
"buttonHeight" : "LB 6/22/2018 18:34",
Expand Down Expand Up @@ -85,7 +84,7 @@
"isInteractive:" : "LB 7/6/2018 17:19",
"loadCorruptionMessage" : "WoC 7/24/2018 15:44",
"loadPresentation" : "WoC 7/24/2018 15:56",
"loadPresentationFromDirectory:" : "mb 6/19/2019 16:38",
"loadPresentationFromDirectory:" : "VO 6/22/2019 17:46",
"loadQuestionMessage" : "WoC 7/24/2018 15:48",
"menuBarButtonData" : "jb 6/6/2019 17:25",
"menuBarColor" : "LM 7/13/2018 14:13",
Expand Down Expand Up @@ -138,7 +137,6 @@
"sendToBackButtonData" : "VO 5/23/2019 16:31",
"setFrames:" : "VO 6/5/2019 16:37",
"showButtons:" : "VO 5/29/2019 17:56",
"showErrorReport:" : "WoC 7/24/2018 16:33",
"showNoLayoutsDialog" : "JB 6/13/2019 11:27",
"slideAt:" : "LM 7/13/2018 18:12",
"slideButtonData" : "VO 5/23/2019 16:31",
Expand Down Expand Up @@ -167,7 +165,7 @@
"toolBuilder:" : "VO 5/22/2019 18:03",
"topRightButtonData" : "JB 6/12/2019 20:03",
"updateCurrentMiniature" : "LB 6/29/2018 17:21",
"updatePresentation:withErrorReport:" : "MK 7/20/2018 15:41",
"updatePresentation:withErrorReport:" : "VO 6/23/2019 12:14",
"updateSelection:" : "VO 5/29/2019 17:56",
"updateSlideMiniatures" : "LB 6/29/2018 17:08",
"updateSlideMiniaturesCompletely" : "LM 7/24/2018 16:41",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ testCanLoadCompletelyEmptyPresentation
| directory errorReport |
directory := self mockCompletelyEmptyPresentationDirectory.
self loader loadPresentationFromDirectory: directory.
errorReport := self loader errorReport.
errorReport := self loader slidesErrorReport.
self
assert: (errorReport values select: [:each | each ~= 0]) isEmpty
description: 'There should be 0 errors per slide for an empty presentation'
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ testCanLoadEmptyPresentation
| directory errorReport |
directory := self mockEmptyPresentationDirectory.
self loader loadPresentationFromDirectory: directory.
errorReport := self loader errorReport.
errorReport := self loader slidesErrorReport.
self
assert: (errorReport values select: [:each | each ~= 0]) isEmpty
description: 'There should be 0 errors per slide for an empty presentation'
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ testErrorReportExistsPerSlide
| directory errorReport entries |
directory := self mockEmptyPresentationDirectory.
self loader loadPresentationFromDirectory: directory.
errorReport := self loader errorReport.
errorReport := self loader slidesErrorReport.

entries := (directory / self loader slidesDirectoryName) directoryNames asSet.
entries addAll: (directory / self loader layoutsDirectoryName) directoryNames asSet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"mockEmptyPresentationDirectory" : "VO 5/29/2019 17:12",
"morphLoadingStreamFor:" : "MK 7/20/2018 15:48",
"setUp" : "MK 7/20/2018 15:46",
"testCanLoadCompletelyEmptyPresentation" : "VO 6/13/2019 17:06",
"testCanLoadEmptyPresentation" : "mb 6/12/2019 18:10",
"testCanLoadCompletelyEmptyPresentation" : "VO 6/23/2019 12:10",
"testCanLoadEmptyPresentation" : "VO 6/23/2019 12:10",
"testCanLoadEmptySlide" : "LM 7/25/2018 13:10",
"testCompletelyEmptyPresentationIsValid" : "JB 6/13/2019 11:12",
"testEmptyPresentationDirectoryIsValid" : "MK 7/20/2018 15:50",
"testErrorReportExistsPerSlide" : "mb 6/12/2019 18:10",
"testErrorReportExistsPerSlide" : "VO 6/23/2019 12:11",
"testInvalidLayoutDirectoryNames" : "JB 5/7/2019 21:48",
"testInvalidLoadReturnsNil" : "MK 7/20/2018 15:51",
"testInvalidSlideDirectoryNames" : "VO 6/13/2019 17:14",
Expand Down

0 comments on commit dfecf60

Please sign in to comment.