Skip to content

Instantly share code, notes, and snippets.

@peteruhnak
Created October 3, 2018 11:31
Show Gist options
  • Save peteruhnak/e4ba8d52bf4a89c4c9e015bb59b442fd to your computer and use it in GitHub Desktop.
Save peteruhnak/e4ba8d52bf4a89c4c9e015bb59b442fd to your computer and use it in GitHub Desktop.
Tonel Reading & Writing

Reading (Memory FS)

store := FileSystem memory root.
(store / 'Somewhere') ensureCreateDirectory.
(store / 'Somewhere' / 'Something.class.st')
    ensureDelete;
    writeStreamDo: [ :stream | stream << 'Class {
    #name : #Something,
    #superclass : #Object,
    #category : #Somewhere
}

{ #category : #initialization }
Something >> initialize [
    super initialize
]' ].


reader := TonelReader on: store fileName: 'Somewhere'.
reader snapshot install.

Reading from string

(MCSnapshot fromDefinitions: (TonelParser parseStream: 'Class {
    #name : #Something,
    #superclass : #Object,
    #category : #Somewhere
}

{ #category : #initialization }
Something >> initialize [
    super initialize
]' readStream)) install

Writing (Memory FS)

store := FileSystem memory root.
TonelWriter fileOut: 'SomeMorph' asPackage mcWorkingCopy on: store.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment