Refactoring for documentation support.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-10-08 12:45:57 +00:00
parent 8ed0f0a4eb
commit 81bba96dae
5 changed files with 91 additions and 111 deletions

View File

@ -1,48 +0,0 @@
"
I model a documentation object for Grafoscopio.
Documents are stored in a fossil repository and have
relative paths to it.
"
Class {
#name : #Documentation,
#superclass : #Object,
#instVars : [
'repository',
'documents'
],
#category : #'Grafoscopio-Model'
}
{ #category : #queries }
Documentation class >> grafoscopioDocumentation [
"I model the important documents that belong to the Grafoscopio documentation.
When more documents become more mature and usable, I will include them."
| gfcDocumentation |
gfcDocumentation := self new.
gfcDocumentation repository: (FossilRepo new url: 'http://mutabit.com/repos.fossil/grafoscopio').
gfcDocumentation documents: (Dictionary new
at: 'Spanish Tutorial' put: 'Docs/Es/Tutoriales/tutorial.ston'; yourself).
^ gfcDocumentation
]
{ #category : #accessing }
Documentation >> documents [
^ documents
]
{ #category : #accessing }
Documentation >> documents: anObject [
documents := anObject
]
{ #category : #accessing }
Documentation >> repository [
^ repository
]
{ #category : #accessing }
Documentation >> repository: anObject [
repository := anObject
]

View File

@ -13,14 +13,14 @@ Class {
}
{ #category : #querying }
FossilRepo >> checkinsFor: aFullFileName [
FossilRepo >> checkinsFor: relativeFilePath [
"I get all histotical checkins information for a full file name, wich includes relative path
in the repository (i.e: 'Doc/Es/Tutoriales/tutorial.ston' or 'index.html's)"
(self jsonDataFor: aFullFileName) at: 'payload' ifAbsent: [
(self jsonDataFor: relativeFilePath) = self ifTrue: [
self inform:
'WARNING! Key not found, verify the file name you are looking in this repository'.
^ self ].
^ (((self jsonDataFor: aFullFileName) at: 'payload') at: 'checkins')
^ (((self jsonDataFor: relativeFilePath) at: 'payload') at: 'checkins')
]
{ #category : #querying }

View File

@ -0,0 +1,79 @@
"
I model a documentation object for Grafoscopio.
Documents are stored in a fossil repository and have
relative paths to it.
"
Class {
#name : #GrafoscopioDocumentation,
#superclass : #Object,
#instVars : [
'repository',
'documents',
'localPlace'
],
#category : #'Grafoscopio-Model'
}
{ #category : #queries }
GrafoscopioDocumentation class >> current [
"I model the important documents that belong to the Grafoscopio documentation.
When more documents become more mature and usable, I will include them."
| gfcDocumentation |
gfcDocumentation := self new.
gfcDocumentation repository: (FossilRepo new url: 'http://mutabit.com/repos.fossil/grafoscopio').
gfcDocumentation documents add: 'Docs/Es/Tutoriales/tutorial.ston'.
gfcDocumentation localPlace.
^ gfcDocumentation
]
{ #category : #updating }
GrafoscopioDocumentation class >> isUpdated [
"I compare the cryptografic signatures of the local copy of aDocumentType and the remote one to see if the're the same,
in which case I return true or false in any other cases."
^ ((self current documents collect: [ :doc | (self isUpdatedFor: doc) ]) includes: false) not
]
{ #category : #updating }
GrafoscopioDocumentation class >> isUpdatedFor: relativeFilePath [
"I compare if the local and remote copies of a relativeFilePath are updated for the current documentation and return
true if they are and false in any other case"
| localFile |
localFile := self current localPlace / relativeFilePath.
localFile exists
ifFalse: [ ^ false ]
ifTrue: [ ^ ExternalApp compareHashFor: localFile with: (self current repository lastHashNumberFor: relativeFilePath) ]
]
{ #category : #accessing }
GrafoscopioDocumentation >> documents [
^ documents ifNil: [ documents := OrderedCollection new ]
]
{ #category : #accessing }
GrafoscopioDocumentation >> documents: anObject [
documents := anObject
]
{ #category : #accessing }
GrafoscopioDocumentation >> localPlace [
^ localPlace ifNil: [
localPlace := FileLocator documents asFileReference / 'Grafoscopio'.
self localPlace exists ifFalse: [ self localPlace ensureCreateDirectory ] ].
]
{ #category : #accessing }
GrafoscopioDocumentation >> localPlace: anObject [
localPlace := anObject
]
{ #category : #accessing }
GrafoscopioDocumentation >> repository [
^ repository
]
{ #category : #accessing }
GrafoscopioDocumentation >> repository: anObject [
repository := anObject
]

View File

@ -85,38 +85,6 @@ GrafoscopioGUI class >> docDataTutorial [
]
{ #category : #updating }
GrafoscopioGUI class >> docDownloadFor: aDocumentType [
"I download the interactive documentation in STON format, according to the document
type which can be: 'tutorial' or 'manual'.
If a the documentation is already present in the system I made a temporal backup and
download a new copy"
| docInfo rootFolder localDoc temporalBackup remoteDoc |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
rootFolder := (FileLocator documents asFileReference / 'Grafoscopio').
rootFolder exists ifFalse: [
rootFolder ensureCreateDirectory.
OSProcess command: ('exec mkdir -p ', rootFolder fullName, '/', (docInfo at: 'relativePath'))
].
localDoc := rootFolder fullName, '/', (docInfo at: 'relativePath'), (docInfo at: 'filename').
temporalBackup := rootFolder fullName, '/', (docInfo at: 'relativePath'), aDocumentType, '.temp.ston'.
remoteDoc :=
(self docDataTutorial at: 'remoteRepo'), 'doc/tip/',
(self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
localDoc asFileReference exists
ifTrue: [
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
localDoc asFileReference renameTo: aDocumentType, '.temp.ston'
].
self
downloadingFrom: remoteDoc
withMessage: 'Actualizando el ', aDocumentType,'...'
into: (rootFolder fullName, '/', (docInfo at: 'relativePath')).
]
{ #category : #accessing }
GrafoscopioGUI class >> dockingBar [
^ dockingBar
@ -335,13 +303,13 @@ GrafoscopioGUI class >> initialize [
{ #category : #updating }
GrafoscopioGUI class >> isDocUpdatedFor: aDocumentType [
"I compare the cryptografic signatures of the local copy of aDocumentType and the remote one to see if the're the same,
in which case I return True or False in any other cases.
aDocumentType is a string that can be 'tutorial' or 'manual' according to the type of document we're querying for.
Now documentation is mainly on Spanish. When support for multiple languages be enabled this method needs revision"
"I compare the cryptografic signatures of the local copy of aDocumentType and the remote one to see if the're
the same, in which case I return True or False in any other cases.
aDocumentType is a string that can be 'tutorial' or 'manual' according to the type of document
we're querying for.
Now documentation is mainly on Spanish. When support for multiple languages be enabled this method needs
revision"
| folderLastContents lastRemoteTutorial localTutorial docInfo |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
localTutorial := FileLocator documents / 'Grafoscopio', (docInfo at: 'relativePath'), (docInfo at: 'filename').
@ -356,7 +324,6 @@ GrafoscopioGUI class >> isDocUpdatedFor: aDocumentType [
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
detect: [:entry | (entry at: 'name') = (docInfo at: 'filename') ].
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex]
]
{ #category : #'graphical interface' }
@ -578,24 +545,6 @@ GrafoscopioGUI class >> updateDatavizUI [
ifFalse: [self inform: 'Actualización del paquete dataviz no realizada']]
]
{ #category : #updating }
GrafoscopioGUI class >> updateDocumentation [
"Updates documentation (manual, tutorials) from official repository"
| docs |
docs := #('tutorial' 'manual').
docs do: [ :eachDoc |
(self isDocUpdatedFor: eachDoc)
ifFalse: [ self docDownloadFor: eachDoc]
ifTrue: [
self inform:
'NADA QUE ACTUALIZAR!', String cr,
'El ', eachDoc,' ya se encuentra en su versión más reciente.'
]
]
]
{ #category : #updating }
GrafoscopioGUI class >> updateDocumentationUI [
"Updates documentation (manual, tutorials) from official repository"
@ -605,7 +554,7 @@ GrafoscopioGUI class >> updateDocumentationUI [
update := (UIManager default
confirm: '¿Desea actualizar la documentación?'
label: 'Actualizar documentación').
update ifTrue: [self updateDocumentation]
update ifTrue: [GrafoscopioDocumentation update]
]
{ #category : #updating }
@ -732,8 +681,8 @@ GrafoscopioGUI class >> updateSystem [
ifTrue: [
self
updateGrafoscopio;
updateDocumentation;
updateDataviz.
GrafoscopioDocumentation update.
ExternalApp installSQLite32Bits.
self inform: 'Actualización de todo el sistema terminada.']
]

View File

@ -9,7 +9,7 @@ Class {
{ #category : #'code-critics' }
ManifestGrafoscopio class >> ruleRBClassNameInSelectorRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#'Documentation class' #grafoscopioDocumentation #true)) #'2016-10-07T19:39:23.013722-05:00') )
^ #(#(#(#RGMethodDefinition #(#'Documentation class' #current #true)) #'2016-10-07T19:39:23.013722-05:00') )
]
{ #category : #'code-critics' }