Extracting patterns from NanoID to be used with other external Nim programs.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-16 17:41:12 -05:00
parent c0f7ebe803
commit 1c632dd1d0
4 changed files with 19 additions and 10 deletions

View File

@ -205,7 +205,7 @@ Markdeep >> markdeepScriptTag [
{ #category : #accessing }
Markdeep >> markdownFile [
^ self config at: 'markdownFile'
^ Markdown new fromFile: (self config at: 'markdownFile')
]
{ #category : #accessing }

View File

@ -98,7 +98,7 @@ Markdown >> exportMetadataAsYaml [
Markdown >> extractYAMLMetadata [
| output yamlLines |
self detectYAMLMetadata ifFalse: [ ^ nil ].
yamlLines := self lines copyFrom: 2 to: (self yamlMetadataClosingLineNumber).
yamlLines := self lines copyFrom: 2 to: self yamlMetadataClosingLineNumber - 1.
output := '' writeStream.
yamlLines do: [ :line |
output

View File

@ -0,0 +1,13 @@
Class {
#name : #MiniDocs,
#superclass : #Object,
#category : #MiniDocs
}
{ #category : #accessing }
MiniDocs class >> appFolder [
| tempFolder |
tempFolder := FileLocator userData / 'Mutabit' / 'MiniDocs'.
tempFolder exists ifFalse: [ tempFolder ensureCreateDirectory ].
^ tempFolder
]

View File

@ -20,7 +20,7 @@ Class {
{ #category : #accessing }
NanoID class >> binaryFile [
^ FileLocator userData / 'Mutabit' / 'MiniDocs' / self scriptSourceCode basenameWithoutExtension
^ MiniDocs appFolder / self scriptSourceCode basenameWithoutExtension
]
{ #category : #accessing }
@ -30,7 +30,6 @@ NanoID class >> generate [
command: self binaryFile fullName;
redirectStdout;
redirectStdout;
"workingDirectory: self binaryFile parent;"
runAndWaitOnExitDo: [ :process :outString | ^ outString copyWithoutAll: (Character lf asString) ]
]
@ -38,17 +37,14 @@ NanoID class >> generate [
NanoID class >> install [
"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."
| binaryFileFolder |
binaryFileFolder := self binaryFile parent.
binaryFileFolder exists ifFalse: [ binaryFileFolder ensureCreateDirectory ].
self binaryFile exists ifTrue: [ ^ binaryFileFolder ].
self binaryFile exists ifTrue: [ ^ MiniDocs appFolder ].
Nimble install: 'nanoid'.
OSSUnixSubprocess new
command: 'nim';
arguments: {'c'. self scriptSourceCode fullName};
runAndWaitOnExitDo: [ :process :outString |
(self scriptSourceCode parent / (self scriptSourceCode) basenameWithoutExtension) moveTo: binaryFileFolder asFileReference.
^ binaryFileFolder ]
(self scriptSourceCode parent / (self scriptSourceCode) basenameWithoutExtension) moveTo: MiniDocs appFolder asFileReference.
^ MiniDocs appFolder ]
]
{ #category : #accessing }