diff --git a/repository/Grafoscopio-Utils/MarkupFile.class.st b/repository/Grafoscopio-Utils/MarkupFile.class.st new file mode 100644 index 0000000..d64e786 --- /dev/null +++ b/repository/Grafoscopio-Utils/MarkupFile.class.st @@ -0,0 +1,16 @@ +Class { + #name : #MarkupFile, + #superclass : #Object, + #instVars : [ + 'file' + ], + #category : #'Grafoscopio-Utils' +} + +{ #category : #persistence } +MarkupFile class >> exportAsFileOn: aFileReference containing: contents [ + aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. + aFileReference writeStreamDo: [ :stream | + stream nextPutAll: contents ]. + self inform: 'Exported as: ', String cr, aFileReference fullName +] diff --git a/repository/Grafoscopio-Utils/OrgMode.class.st b/repository/Grafoscopio-Utils/OrgMode.class.st new file mode 100644 index 0000000..4e07529 --- /dev/null +++ b/repository/Grafoscopio-Utils/OrgMode.class.st @@ -0,0 +1,46 @@ +" +I provide some utilites to work with OrgMode files. + +https://orgmode.org/ +" +Class { + #name : #OrgMode, + #superclass : #Object, + #instVars : [ + 'contents', + 'file' + ], + #category : #'Grafoscopio-Utils' +} + +{ #category : #'instance creation' } +OrgMode class >> fromFile: aFileReference [ + ^ self new contents: aFileReference contents. +] + +{ #category : #accessing } +OrgMode >> contents [ + ^ contents +] + +{ #category : #accessing } +OrgMode >> contents: anObject [ + contents := anObject +] + +{ #category : #accessing } +OrgMode >> file [ + ^ file +] + +{ #category : #accessing } +OrgMode >> file: anObject [ + file := anObject +] + +{ #category : #utilities } +OrgMode >> selectHeadlines [ + + ^ self contents lines select: [ :line | + line isOrgModeHeader ] +] diff --git a/repository/Grafoscopio-Utils/String.extension.st b/repository/Grafoscopio-Utils/String.extension.st new file mode 100644 index 0000000..6c65f1e --- /dev/null +++ b/repository/Grafoscopio-Utils/String.extension.st @@ -0,0 +1,15 @@ +Extension { #name : #String } + +{ #category : #'*Grafoscopio-Utils' } +String >> asCapitalizedPhrase [ + "I convert phrases like 'THIS IS A PHASE' into 'This is a Phrase'." + + ^ Character space join: (self substrings collect: [:each | each asLowercase capitalized ]) +] + +{ #category : #'*Grafoscopio-Utils' } +String >> isOrgModeHeader [ + ^ self beginsWithAnyOf: #('* ' '** ' '*** ' '**** ' '***** ' '***** ') + + +]