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 } { #category : #accessing }
Markdeep >> markdownFile [ Markdeep >> markdownFile [
^ self config at: 'markdownFile' ^ Markdown new fromFile: (self config at: 'markdownFile')
] ]
{ #category : #accessing } { #category : #accessing }

View File

@ -98,7 +98,7 @@ Markdown >> exportMetadataAsYaml [
Markdown >> extractYAMLMetadata [ Markdown >> extractYAMLMetadata [
| output yamlLines | | output yamlLines |
self detectYAMLMetadata ifFalse: [ ^ nil ]. self detectYAMLMetadata ifFalse: [ ^ nil ].
yamlLines := self lines copyFrom: 2 to: (self yamlMetadataClosingLineNumber). yamlLines := self lines copyFrom: 2 to: self yamlMetadataClosingLineNumber - 1.
output := '' writeStream. output := '' writeStream.
yamlLines do: [ :line | yamlLines do: [ :line |
output 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 } { #category : #accessing }
NanoID class >> binaryFile [ NanoID class >> binaryFile [
^ FileLocator userData / 'Mutabit' / 'MiniDocs' / self scriptSourceCode basenameWithoutExtension ^ MiniDocs appFolder / self scriptSourceCode basenameWithoutExtension
] ]
{ #category : #accessing } { #category : #accessing }
@ -30,7 +30,6 @@ NanoID class >> generate [
command: self binaryFile fullName; command: self binaryFile fullName;
redirectStdout; redirectStdout;
redirectStdout; redirectStdout;
"workingDirectory: self binaryFile parent;"
runAndWaitOnExitDo: [ :process :outString | ^ outString copyWithoutAll: (Character lf asString) ] runAndWaitOnExitDo: [ :process :outString | ^ outString copyWithoutAll: (Character lf asString) ]
] ]
@ -38,17 +37,14 @@ NanoID class >> generate [
NanoID class >> install [ NanoID class >> install [
"For the moment, only Gnu/Linux and Mac are supported. "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." IMPORTANT: Nimble, Nim's package manager should be installed, as this process doesn't verify its proper installation."
| binaryFileFolder | self binaryFile exists ifTrue: [ ^ MiniDocs appFolder ].
binaryFileFolder := self binaryFile parent.
binaryFileFolder exists ifFalse: [ binaryFileFolder ensureCreateDirectory ].
self binaryFile exists ifTrue: [ ^ binaryFileFolder ].
Nimble install: 'nanoid'. Nimble install: 'nanoid'.
OSSUnixSubprocess new OSSUnixSubprocess new
command: 'nim'; command: 'nim';
arguments: {'c'. self scriptSourceCode fullName}; arguments: {'c'. self scriptSourceCode fullName};
runAndWaitOnExitDo: [ :process :outString | runAndWaitOnExitDo: [ :process :outString |
(self scriptSourceCode parent / (self scriptSourceCode) basenameWithoutExtension) moveTo: binaryFileFolder asFileReference. (self scriptSourceCode parent / (self scriptSourceCode) basenameWithoutExtension) moveTo: MiniDocs appFolder asFileReference.
^ binaryFileFolder ] ^ MiniDocs appFolder ]
] ]
{ #category : #accessing } { #category : #accessing }