Grafoscopio/src/Grafoscopio/GrafoscopioDocumentation.cl...

84 lines
2.4 KiB
Smalltalk

"
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 [
^ (self listOutdated size > 0) ifTrue: [ ^ false ] ifFalse: [ ^ true ]
]
{ #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 : #updating }
GrafoscopioDocumentation class >> listOutdated [
"I return the list of all documentent where the local copy and the remote copy doesn't match"
^ self current documents select: [ :doc | (self isUpdatedFor: doc) = false ]
]
{ #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
]