PandocWork added to improve reproducible publishing.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2019-04-22 19:54:07 +00:00
parent 0647a860f7
commit 85a4cbec24
2 changed files with 81 additions and 25 deletions

View File

@ -58,6 +58,13 @@ GrafoscopioUtils class >> ensureCreateDirectory: fileNameWithRelativePath into:
] ]
{ #category : #persistence }
GrafoscopioUtils class >> exportAsSton: anObject on: aFileReference [
"comment stating purpose of message"
]
{ #category : #'graphical interface' } { #category : #'graphical interface' }
GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [ GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [
| client | | client |

View File

@ -20,26 +20,17 @@ Class {
'contents', 'contents',
'metadataFiles', 'metadataFiles',
'rootFolder', 'rootFolder',
'manifest' 'manifests'
], ],
#category : #'Grafoscopio-Utils' #category : #'Grafoscopio-Utils'
} }
{ #category : #utilities } { #category : #utlity }
PandocWork >> buildManifest [ PandocWork >> buildManifestForLanguage: anISOCode [
"I create a manifest, that lists all the files which are needed to create a self
derivate file (PDF, EPUB, etc) with their checksums and folder locations. metadataManifestForLanguage: anISOCode;
contentsManifestForLanguage: anISOCode.
I can be used to associated derivated files with their sources." ^ self manifests
| checksums |
checksums := OrderedDictionary new.
self contents keysDo: [ :folder |
(self contents at: folder) do: [ :fileName | | keyName contentFile |
keyName := fileName, self defaultFileExtension.
contentFile := self rootFolder / self language / folder / keyName.
checksums at: keyName put: (GrafoscopioUtils checksumFor: contentFile)].
self manifest at: folder put: checksums ].
] ]
{ #category : #accessing } { #category : #accessing }
@ -56,6 +47,35 @@ PandocWork >> contents: anOrderedDictionary [
contents := anOrderedDictionary contents := anOrderedDictionary
] ]
{ #category : #utilities }
PandocWork >> contentsManifest [
| checksums |
checksums := OrderedDictionary new.
self contents keysDo: [ :folder |
(self contents at: folder) do: [ :fileName | | keyName contentFile |
keyName := fileName, self defaultFileExtension.
contentFile := self rootFolder / self language / folder / keyName.
checksums at: keyName put: (GrafoscopioUtils checksumFor: contentFile)].
self manifest at: folder put: checksums ].
^ self manifest
]
{ #category : #utilities }
PandocWork >> contentsManifestForLanguage: anISOCode [
| checksums |
checksums := OrderedDictionary new.
self contents keysDo: [ :folder |
(self contents at: folder) do: [ :fileName | | keyName contentFile |
keyName := fileName, self defaultFileExtension.
contentFile := self rootFolder / anISOCode / folder / keyName.
checksums at: keyName put: (GrafoscopioUtils checksumFor: contentFile)].
(self manifestForLanguage: anISOCode)
add: {folder -> checksums} asOrderedDictionary ].
^ self manifests at: anISOCode
]
{ #category : #utilities } { #category : #utilities }
PandocWork >> defaultFileExtension [ PandocWork >> defaultFileExtension [
^ '.md' ^ '.md'
@ -77,18 +97,23 @@ PandocWork >> language: aISOLangString [
language := aISOLangString language := aISOLangString
] ]
{ #category : #accessing } { #category : #utlity }
PandocWork >> manifest [ PandocWork >> manifestForLanguage: anISOCode [
"I create a manifest, that lists all the files which are needed to create a self manifests at: anISOCode ifAbsent: [
derivate file (PDF, EPUB, etc) with their checksums and folder locations. self manifests
at: anISOCode put: OrderedCollection new;
I can be used to associated derivated files with their sources." yourself].
^ manifest ifNil: [ ^ manifest := OrderedDictionary new ] ^ self manifests at: anISOCode
] ]
{ #category : #accessing } { #category : #accessing }
PandocWork >> manifest: anOrderedDictionary [ PandocWork >> manifests [
manifest := anOrderedDictionary ^ manifests ifNil: [ ^ manifests := OrderedDictionary new ]
]
{ #category : #accessing }
PandocWork >> manifests: anOrderedDictionary [
manifests := anOrderedDictionary
] ]
{ #category : #accessing } { #category : #accessing }
@ -106,6 +131,30 @@ PandocWork >> metadataFiles: aCollection [
metadataFiles := aCollection metadataFiles := aCollection
] ]
{ #category : #utilities }
PandocWork >> metadataManifest [
| languageFolder |
languageFolder := self language.
"Could the similar parts of this and contentsManifest be refactored?"
self metadataFiles do: [ :fileName | | contentFile |
contentFile := self rootFolder / languageFolder / fileName.
self manifest at: languageFolder put: {fileName -> (GrafoscopioUtils checksumFor: contentFile)} asOrderedDictionary ].
^ self manifest
]
{ #category : #utilities }
PandocWork >> metadataManifestForLanguage: anISOCode [
"anISOCode is the ISO 639-1 two letters language code"
"Could the similar parts of this and contentsManifest be refactored?"
self metadataFiles do: [ :fileName | | contentFile |
contentFile := self rootFolder / anISOCode / fileName.
(self manifestForLanguage: anISOCode)
add: {fileName -> (GrafoscopioUtils checksumFor: contentFile)} asOrderedDictionary].
^ self manifests at: anISOCode
]
{ #category : #accessing } { #category : #accessing }
PandocWork >> rootFolder [ PandocWork >> rootFolder [
^ rootFolder ^ rootFolder