Skip to content

Commit

Permalink
Cleaning cleaning cleaning a bit more.
Browse files Browse the repository at this point in the history
- remove file
- initialize a default fileReference
- remove syntaxState
- renamed instance variable
- remove unless tests
Should do a pass on test and clean more.
  • Loading branch information
Ducasse committed Dec 1, 2024
1 parent c4f1a75 commit dcb670d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 49 deletions.
7 changes: 0 additions & 7 deletions src/MicroEd-Spec-Tests/MDEditorFilePresenterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ MDEditorFilePresenterTest >> testGotMicrodownParser [
self assert: presenter microdownParser class equals: MicrodownParser
]

{ #category : 'running' }
MDEditorFilePresenterTest >> testMDFileOverwriteFileReferenceWhenAnotherSameFile [

"We want to test how to overwrite the content of a file when there is another file with the same name. "
self skip.
]

{ #category : 'tests-interaction' }
MDEditorFilePresenterTest >> testOpenIsWorkingSmokeTest [

Expand Down
31 changes: 9 additions & 22 deletions src/MicroEd-Spec/MDEditorPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Class {
#superclass : 'SpApplicationWithToolbar',
#instVars : [
'textInput',
'textOutput',
'composer',
'syntaxState',
'mdFile'
'mdFile',
'renderedText'
],
#category : 'MicroEd-Spec',
#package : 'MicroEd-Spec'
Expand Down Expand Up @@ -49,7 +49,7 @@ MDEditorPresenter >> cleanInput [
{ #category : 'actions' }
MDEditorPresenter >> cleanOutput [

textOutput text: ''
renderedText text: ''
]

{ #category : 'layout' }
Expand All @@ -58,8 +58,8 @@ MDEditorPresenter >> defaultLayout [
^ SpBoxLayout newTopToBottom
add: #menu expand: false;
add: (SpPanedLayout newLeftToRight
add: #textInput;
add: #textOutput;
add: textInput;
add: renderedText;
yourself);
yourself
]
Expand Down Expand Up @@ -185,7 +185,7 @@ MDEditorPresenter >> initializePresentersWithText: anInputText [
[ self application defer: [ self renderAction ] ] schedule.
anEvent wasHandled: false ]."

textOutput := self newText
renderedText := self newText
beNotEditable;
yourself

Expand Down Expand Up @@ -228,7 +228,6 @@ MDEditorPresenter >> openFile [
openModal.
selectedFile
ifNotNil: [

self mdFile: (MDFile newFromFileReference: selectedFile asFileReference).
textInput text: selectedFile contents.
self cleanOutput.
Expand All @@ -246,7 +245,7 @@ MDEditorPresenter >> renderDocument [
document := syntaxState parse: textInput text.
text := composer visit: document.

textOutput text: text.
renderedText text: text.

]

Expand All @@ -263,7 +262,7 @@ MDEditorPresenter >> saveFile [
MDEditorPresenter >> setExampleAsInput [
"GET EXAMPLE button is pressed: fill input text with an example"

textInput text: syntaxState exampleText.
textInput text: self exampleText.
self cleanOutput
]

Expand All @@ -276,18 +275,6 @@ MDEditorPresenter >> startNewFile [
self window ifNotNil: [ self updateTitle ]
]

{ #category : 'accessing' }
MDEditorPresenter >> syntaxState [

^ syntaxState
]

{ #category : 'accessing' }
MDEditorPresenter >> syntaxState: aSyntaxState [

syntaxState := aSyntaxState
]

{ #category : 'accessing' }
MDEditorPresenter >> textInputText [

Expand All @@ -303,7 +290,7 @@ MDEditorPresenter >> textInputText: aString [
{ #category : 'accessing' }
MDEditorPresenter >> textOutputText [

^ textOutput text
^ renderedText text
]

{ #category : 'api' }
Expand Down
4 changes: 2 additions & 2 deletions src/MicroEd-Tests/MDFileTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ MDFileTest >> testMDFileHasFileReferenceWithFormatISO [

| file date |
file := MDFile newFromFileReference: fileReferenceWithName.
date := DateAndTime now asDate yyyymmdd.
date := Date today yyyymmdd.
self assert: (file basename includesSubstring: date).
self deny: (fileReferenceWithName exists )
self deny: fileReferenceWithName exists
]

{ #category : 'tests' }
Expand Down
9 changes: 0 additions & 9 deletions src/MicroEd-Tests/MDMicroDownSyntaxTest.class.st

This file was deleted.

13 changes: 4 additions & 9 deletions src/MicroEd/MDFile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ MDFile >> contents [
{ #category : 'accessing' }
MDFile >> contents: aContent [

fileReference contents: aContent
fileReference writeStreamDo: [ :stream |
stream nextPutAll: aContent ]
]

{ #category : 'testing' }
Expand All @@ -90,16 +91,10 @@ MDFile >> extension: anExtension [
fileReference extension: anExtension
]

{ #category : 'accessing' }
MDFile >> file [

^ fileReference
]

{ #category : 'accessing' }
MDFile >> fileReference [

^ fileReference
^ fileReference ifNil: [ fileReference := 'unnamed.md' asFileReference ]
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -134,7 +129,7 @@ MDFile >> initializeWithFileReference: aFileReference [
{ #category : 'accessing' }
MDFile >> save: aString [

fileReference asFileReference writeStreamDo: [ :str |
fileReference writeStreamDo: [ :str |
str nextPutAll: aString ].


Expand Down

0 comments on commit dcb670d

Please sign in to comment.