Converting YAML metadata to JSON using external Nim programs.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-16 18:52:07 -05:00
parent 1d005f04a8
commit 94b3c59d7a

View File

@ -11,3 +11,37 @@ MiniDocs class >> appFolder [
tempFolder exists ifFalse: [ tempFolder ensureCreateDirectory ]. tempFolder exists ifFalse: [ tempFolder ensureCreateDirectory ].
^ tempFolder ^ 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'
]