MiniDocs/src/MiniDocs/MarkupFile.class.st

38 lines
895 B
Smalltalk
Raw Normal View History

"
I model common operations made with several markup files.
"
Class {
#name : #MarkupFile,
#superclass : #Object,
#instVars : [
'file'
],
#category : #MiniDocs
}
{ #category : #persistence }
MarkupFile class >> exportAsFileOn: aFileReferenceOrFileName containing: text [
| file |
file := aFileReferenceOrFileName asFileReference.
file ensureDelete.
file exists ifFalse: [ file ensureCreateFile ].
file writeStreamDo: [ :stream |
stream nextPutAll: text withUnixLineEndings].
self inform: 'Exported as: ', String cr, file fullName.
^ file
]
{ #category : #accessing }
MarkupFile class >> installTemplate: anUrl into: aFolder [
| fileName |
fileName := anUrl asUrl segments last.
(aFolder / fileName) exists
ifTrue: [ (aFolder / fileName) ensureDeleteFile ]
ifFalse: [ aFolder ensureCreateDirectory ].
ZnClient new
url: anUrl;
downloadTo: aFolder.
^ aFolder
]