From bd897d8def38df49bf0af9a227022020cc85bb51 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sat, 2 May 2020 13:28:13 +0000 Subject: [PATCH] Improving Markdeep. --- .../Grafoscopio-Utils/MarkupFile.class.st | 16 +++++++ repository/Grafoscopio-Utils/OrgMode.class.st | 46 +++++++++++++++++++ .../Grafoscopio-Utils/String.extension.st | 15 ++++++ 3 files changed, 77 insertions(+) create mode 100644 repository/Grafoscopio-Utils/MarkupFile.class.st create mode 100644 repository/Grafoscopio-Utils/OrgMode.class.st create mode 100644 repository/Grafoscopio-Utils/String.extension.st 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: #('* ' '** ' '*** ' '**** ' '***** ' '***** ') + + +]