Skip to content

Commit

Permalink
Fixing two more tests. builder text:
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Jul 19, 2024
1 parent 6731fd6 commit acecb67
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 203 deletions.
15 changes: 8 additions & 7 deletions src/Pillar-ExporterMicrodown/BookAsDocBuilder.class.st
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
Class {
#name : #BookAsDocBuilder,
#superclass : #Object,
#name : 'BookAsDocBuilder',
#superclass : 'Object',
#instVars : [
'metadata'
],
#category : #'Pillar-ExporterMicrodown'
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #stuff }
{ #category : 'stuff' }
BookAsDocBuilder >> bookFiles [

^ PRInputFileFinder
fromFileIndex: self fileIndex; files
]

{ #category : #stuff }
{ #category : 'stuff' }
BookAsDocBuilder >> fileIndex [
"self new readingTitle"

Expand All @@ -24,7 +25,7 @@ BookAsDocBuilder >> fileIndex [
PRPillarParser parse: index contents
]

{ #category : #stuff }
{ #category : 'stuff' }
BookAsDocBuilder >> loadMetaData [
"self new readingTitle"

Expand All @@ -35,7 +36,7 @@ BookAsDocBuilder >> loadMetaData [

]

{ #category : #stuff }
{ #category : 'stuff' }
BookAsDocBuilder >> title [
^ metadata at: #title ifAbsent: [ 'Strange there is no title' ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ I am a command line handler to convert a pillar file (for now) in a microdown fi
`./pillar convertBook SUnit.pillar`
"
Class {
#name : #ClapPillarMicrodownBookConverterCommand,
#superclass : #ClapPillarCommand,
#category : #'Pillar-ExporterMicrodown'
#name : 'ClapPillarMicrodownBookConverterCommand',
#superclass : 'ClapPillarCommand',
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #accessing }
{ #category : 'accessing' }
ClapPillarMicrodownBookConverterCommand class >> commandName [
^'convertBook'
]

{ #category : #'command line' }
{ #category : 'command line' }
ClapPillarMicrodownBookConverterCommand class >> commandSpecification [
<commandline>
^ (ClapCommand id: self commandName asSymbol)
Expand All @@ -30,7 +31,7 @@ ClapPillarMicrodownBookConverterCommand class >> commandSpecification [
(self with: args) execute ]
]

{ #category : #execution }
{ #category : 'execution' }
ClapPillarMicrodownBookConverterCommand >> execute [
| file |
file := self requestedFile asString asFileReference.
Expand All @@ -39,7 +40,7 @@ ClapPillarMicrodownBookConverterCommand >> execute [
ifFalse: [ self outputStreamDo: [ :str | str nextPutAll: 'File ', file fullName, ' does not exist' ] ]
]

{ #category : #execution }
{ #category : 'execution' }
ClapPillarMicrodownBookConverterCommand >> requestedFile [
^ (arguments at: #requestedFile) value: self
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ I am a command line handler to convert a pillar file (for now) in a microdown fi
`./pillar convertChapter SUnit.pillar`
"
Class {
#name : #ClapPillarMicrodownChapterConverterCommand,
#superclass : #ClapPillarCommand,
#category : #'Pillar-ExporterMicrodown'
#name : 'ClapPillarMicrodownChapterConverterCommand',
#superclass : 'ClapPillarCommand',
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #accessing }
{ #category : 'accessing' }
ClapPillarMicrodownChapterConverterCommand class >> commandName [
^'convertChapter'
]

{ #category : #'command line' }
{ #category : 'command line' }
ClapPillarMicrodownChapterConverterCommand class >> commandSpecification [
<commandline>
^ (ClapCommand id: self commandName asSymbol)
Expand All @@ -30,7 +31,7 @@ ClapPillarMicrodownChapterConverterCommand class >> commandSpecification [
(self with: args) execute ]
]

{ #category : #execution }
{ #category : 'execution' }
ClapPillarMicrodownChapterConverterCommand >> execute [
| file |
file := self requestedFile asString asFileReference.
Expand All @@ -39,7 +40,7 @@ ClapPillarMicrodownChapterConverterCommand >> execute [
ifFalse: [ self outputStreamDo: [ :str | str nextPutAll: 'File ', file fullName, ' does not exist' ] ]
]

{ #category : #activation }
{ #category : 'activation' }
ClapPillarMicrodownChapterConverterCommand >> requestedFile [
^ (arguments at: #requestedFile) value: self
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ I am a command line handler to convert a pillar slide file in a microdown file i
`./pillar convertSlide SUnit.pillar`
"
Class {
#name : #ClapPillarMicrodownSlideConverterCommand,
#superclass : #ClapPillarCommand,
#category : #'Pillar-ExporterMicrodown'
#name : 'ClapPillarMicrodownSlideConverterCommand',
#superclass : 'ClapPillarCommand',
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #accessing }
{ #category : 'accessing' }
ClapPillarMicrodownSlideConverterCommand class >> commandName [
^'convertSlide'
]

{ #category : #'command line' }
{ #category : 'command line' }
ClapPillarMicrodownSlideConverterCommand class >> commandSpecification [
<commandline>
^ (ClapCommand id: self commandName asSymbol)
Expand All @@ -30,7 +31,7 @@ ClapPillarMicrodownSlideConverterCommand class >> commandSpecification [
(self with: args) execute ]
]

{ #category : #execution }
{ #category : 'execution' }
ClapPillarMicrodownSlideConverterCommand >> execute [
| file |
file := self requestedFile asString asFileReference.
Expand All @@ -39,7 +40,7 @@ ClapPillarMicrodownSlideConverterCommand >> execute [
ifFalse: [ self outputStreamDo: [ :str | str nextPutAll: 'File ', file fullName, ' does not exist' ] ]
]

{ #category : #activation }
{ #category : 'activation' }
ClapPillarMicrodownSlideConverterCommand >> requestedFile [
^ (arguments at: #requestedFile) value: self
]
19 changes: 10 additions & 9 deletions src/Pillar-ExporterMicrodown/PRConverterToMic.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ PRConverterToMic new goForBook: '/Users/ducasse/Workspace/FirstCircle/ActiveRese
```
"
Class {
#name : #PRConverterToMic,
#superclass : #Object,
#name : 'PRConverterToMic',
#superclass : 'Object',
#pools : [
'MicroSharedPool'
],
#category : #'Pillar-ExporterMicrodown'
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #conversion }
{ #category : 'conversion' }
PRConverterToMic >> convertBook: aPath [

| input paths |
Expand All @@ -23,14 +24,14 @@ PRConverterToMic >> convertBook: aPath [
paths do: [ :path | self convertChapter: path ]
]

{ #category : #conversion }
{ #category : 'conversion' }
PRConverterToMic >> convertChapter: aPath [
| input |
input := PRPillarParser parse: aPath readStream contents.
self writeMicrodownOn: aPath forInput: input
]

{ #category : #conversion }
{ #category : 'conversion' }
PRConverterToMic >> convertSlide: aPath [

| input firstParagraph dict metadata |
Expand All @@ -43,7 +44,7 @@ PRConverterToMic >> convertSlide: aPath [
self writeMicrodownOn: aPath forInput: input
]

{ #category : #collect }
{ #category : 'collect' }
PRConverterToMic >> getInputFilesPaths: aString [

| paths |
Expand All @@ -56,7 +57,7 @@ PRConverterToMic >> getInputFilesPaths: aString [
^ paths
]

{ #category : #config }
{ #category : 'config' }
PRConverterToMic >> handleConfigFile [
"We copy the config file to 'pillarconf.old'
then we migrate it."
Expand All @@ -80,7 +81,7 @@ PRConverterToMic >> handleConfigFile [
ifFalse: [ Stdio stdout nextPutAll: conf fullName , ' does not exist']
]

{ #category : #conversion }
{ #category : 'conversion' }
PRConverterToMic >> writeMicrodownOn: aPath forInput: input [

| fileReference |
Expand Down
17 changes: 9 additions & 8 deletions src/Pillar-ExporterMicrodown/PRInputFileFinder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@
I'm a visitor that returns all the `${inputFile:path=xxx}$` in a document.
"
Class {
#name : #PRInputFileFinder,
#superclass : #PRVisitor,
#name : 'PRInputFileFinder',
#superclass : 'PRVisitor',
#instVars : [
'metadata',
'files'
],
#category : #'Pillar-ExporterMicrodown'
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #creation }
{ #category : 'creation' }
PRInputFileFinder class >> fromFileIndex: aFileReference [

^ self new
fromFileIndex: aFileReference;
yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
PRInputFileFinder >> files [
^ files
]

{ #category : #API }
{ #category : 'API' }
PRInputFileFinder >> fromFileIndex: aFileReference [

self start: (PRPillarParser parse: aFileReference contents)

]

{ #category : #accessing }
{ #category : 'accessing' }
PRInputFileFinder >> initialize [

super initialize.
files := OrderedCollection new.
]

{ #category : #visiting }
{ #category : 'visiting' }
PRInputFileFinder >> visitInputFileAnnotation: anInputFileAnnotation [

files add: anInputFileAnnotation path
Expand Down
15 changes: 8 additions & 7 deletions src/Pillar-ExporterMicrodown/PRInputFileFinderTest.class.st
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
Class {
#name : #PRInputFileFinderTest,
#superclass : #TestCase,
#name : 'PRInputFileFinderTest',
#superclass : 'TestCase',
#instVars : [
'memory',
'filesystem',
'index'
],
#category : #'Pillar-ExporterMicrodown'
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #accessing }
{ #category : 'accessing' }
PRInputFileFinderTest class >> indexPillar [

^ '%reviewed SD: 4th of march
Expand Down Expand Up @@ -58,7 +59,7 @@ ${inputFile:path=Chapters/Reflection/Reflection.pillar}$
'
]

{ #category : #running }
{ #category : 'running' }
PRInputFileFinderTest >> setUp [
super setUp.
filesystem := FileSystem memory.
Expand All @@ -67,7 +68,7 @@ PRInputFileFinderTest >> setUp [

]

{ #category : #running }
{ #category : 'running' }
PRInputFileFinderTest >> testFinderFindInputFiles [

| files |
Expand All @@ -78,7 +79,7 @@ PRInputFileFinderTest >> testFinderFindInputFiles [

]

{ #category : #running }
{ #category : 'running' }
PRInputFileFinderTest >> testFinderFindInputFilesFromFileIndex [


Expand Down
19 changes: 10 additions & 9 deletions src/Pillar-ExporterMicrodown/PRMicrodownInputDocumentTest.class.st
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
Class {
#name : #PRMicrodownInputDocumentTest,
#superclass : #PRInputDocumentTest,
#category : #'Pillar-ExporterMicrodown'
#name : 'PRMicrodownInputDocumentTest',
#superclass : 'PRInputDocumentTest',
#category : 'Pillar-ExporterMicrodown',
#package : 'Pillar-ExporterMicrodown'
}

{ #category : #tests }
{ #category : 'tests' }
PRMicrodownInputDocumentTest >> testParsedDocument [

| doc |
doc := ((PRInputDocument inputClassForFile: memoryFileSystem / 'input1.md') new file: memoryFileSystem / 'input1.md') parsedDocument.
self assert: doc class equals: MicRootBlock
]

{ #category : #tests }
{ #category : 'tests' }
PRMicrodownInputDocumentTest >> testParsedDocument2 [

| doc |
doc := (PRInputDocument forFile: memoryFileSystem / 'input1.md') parsedDocument.
self assert: doc class equals: MicRootBlock
]

{ #category : #tests }
{ #category : 'tests' }
PRMicrodownInputDocumentTest >> testParserClass [

| input |
input := (PRInputDocument inputClassForFile: memoryFileSystem / 'input1.md') new.
self assert: input parserClass equals: MicrodownParser
]

{ #category : #tests }
{ #category : 'tests' }
PRMicrodownInputDocumentTest >> testParserClass2 [

| input |
input := PRInputDocument forFile: memoryFileSystem / 'input1.md'.
self assert: input parserClass equals: MicrodownParser
]

{ #category : #tests }
{ #category : 'tests' }
PRMicrodownInputDocumentTest >> testRegistration [

| inputClass |
inputClass := PRInputDocument inputClassForFile: memoryFileSystem / 'input1.md'.
self assert: inputClass equals: MicMicrodownInputDocument
]

{ #category : #tests }
{ #category : 'tests' }
PRMicrodownInputDocumentTest >> testRegistration2 [

| inputClass |
Expand Down
Loading

0 comments on commit acecb67

Please sign in to comment.