From 94b3c59d7a231d09d9f293f437ac082a41db0169 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 16 Oct 2022 18:52:07 -0500 Subject: [PATCH] Converting YAML metadata to JSON using external Nim programs. --- src/MiniDocs/MiniDocs.class.st | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/MiniDocs/MiniDocs.class.st b/src/MiniDocs/MiniDocs.class.st index 95ec538..52c2134 100644 --- a/src/MiniDocs/MiniDocs.class.st +++ b/src/MiniDocs/MiniDocs.class.st @@ -11,3 +11,37 @@ MiniDocs class >> appFolder [ tempFolder exists ifFalse: [ tempFolder ensureCreateDirectory ]. ^ tempFolder ] + +{ #category : #accessing } +MiniDocs class >> installYamlToJson [ + "For the moment, only Gnu/Linux and Mac are supported. + IMPORTANT: Nimble, Nim's package manager should be installed, as this process doesn't verify its proper installation." + self yamlToJsonBinary exists ifTrue: [ ^ MiniDocs appFolder ]. + Nimble install: 'commandeer'. + OSSUnixSubprocess new + command: 'nim'; + arguments: {'c'. self yamlToJsonSourceCode fullName}; + runAndWaitOnExitDo: [ :process :outString | + (self yamlToJsonSourceCode basenameWithoutExtension) moveTo: MiniDocs appFolder asFileReference. + ^ MiniDocs appFolder ] +] + +{ #category : #accessing } +MiniDocs class >> yamlToJson: yamlString [ + + self yamlToJsonBinary exists ifFalse: [ self installYamlToJson ]. + + OSSUnixSubprocess new + command: self yamlToJsonBinary fullName; + runAndWaitOnExitDo: [ :process :outString | ^ outString ] +] + +{ #category : #accessing } +MiniDocs class >> yamlToJsonBinary [ + ^ self appFolder / 'yamlToJson' +] + +{ #category : #accessing } +MiniDocs class >> yamlToJsonSourceCode [ + ^ FileLocator image parent / 'pharo-local/iceberg/Offray/MiniDocs/src/yamlToJso.nim' +]