GrafoscopioDocumentation: moving methods to

instance side, where makes more sense.
This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-07-04 14:24:31 +00:00
parent a4af9071a5
commit a75174451a

View File

@ -9,7 +9,8 @@ Class {
#instVars : [ #instVars : [
'repository', 'repository',
'documents', 'documents',
'localPlace' 'localPlace',
'name'
], ],
#category : #'Grafoscopio-Utils' #category : #'Grafoscopio-Utils'
} }
@ -45,21 +46,6 @@ GrafoscopioDocumentation class >> dataviz [
^ gfcDocumentation ^ gfcDocumentation
] ]
{ #category : #updating }
GrafoscopioDocumentation class >> download: fileNameWithRelativePath [
| fileName relativePathFolders newPath parentFolder |
fileName := (fileNameWithRelativePath splitOn: $/) last.
relativePathFolders := (fileNameWithRelativePath splitOn: $/) allButLast.
newPath := self current localPlace path.
relativePathFolders do: [ :folder | newPath := newPath / folder ].
parentFolder := newPath asFileReference.
parentFolder exists ifFalse: [ parentFolder ensureCreateDirectory ].
GrafoscopioDockingBar
downloadingFrom: self current repository remote asString, '/doc/tip/', fileNameWithRelativePath
withMessage: 'Downloading ', fileName
into: parentFolder
]
{ #category : #updating } { #category : #updating }
GrafoscopioDocumentation class >> initialize [ GrafoscopioDocumentation class >> initialize [
self self
@ -67,17 +53,6 @@ GrafoscopioDocumentation class >> initialize [
update: 'dataviz' update: 'dataviz'
] ]
{ #category : #updating }
GrafoscopioDocumentation class >> isFileUpdatedFor: 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 } { #category : #updating }
GrafoscopioDocumentation class >> listOutdatedDocsIn: aDocumentsListName [ GrafoscopioDocumentation class >> listOutdatedDocsIn: aDocumentsListName [
"I return the list of all documentent where the local copy and the remote copy doesn't match" "I return the list of all documentent where the local copy and the remote copy doesn't match"
@ -192,16 +167,75 @@ GrafoscopioDocumentation >> documents: anObject [
documents := anObject documents := anObject
] ]
{ #category : #accessing } { #category : #updating }
GrafoscopioDocumentation >> localPlace [ GrafoscopioDocumentation >> download: fileNameWithRelativePath [
^ localPlace ifNil: [ | fileName relativePathFolders newPath parentFolder |
localPlace := FileLocator workingDirectory asFileReference / 'Grafoscopio'. fileName := (fileNameWithRelativePath splitOn: $/) last.
self localPlace exists ifFalse: [ self localPlace ensureCreateDirectory ] ]. relativePathFolders := (fileNameWithRelativePath splitOn: $/) allButLast.
newPath := self localPlace path.
relativePathFolders do: [ :folder | newPath := newPath / folder ].
parentFolder := newPath asFileReference.
parentFolder exists ifFalse: [ parentFolder ensureCreateDirectory ].
GrafoscopioUtils
downloadingFrom: self repository remote asString, '/doc/tip/', fileNameWithRelativePath
withMessage: 'Downloading ', fileName
into: parentFolder
]
{ #category : #updating }
GrafoscopioDocumentation >> isFileUpdatedFor: 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 localPlace / relativeFilePath.
localFile exists
ifFalse: [ ^ false ]
ifTrue: [
^ ExternalApp
compareHashFor: localFile
with: (self repository lastHashNumberFor: relativeFilePath) ]
]
{ #category : #updating }
GrafoscopioDocumentation >> listOutdatedDocs [
"I return the list of all documentent where the local copy and the remote copy doesn't match"
^ self documents reject: [ :doc | (self isFileUpdatedFor: doc) ]
] ]
{ #category : #accessing } { #category : #accessing }
GrafoscopioDocumentation >> localPlace: anObject [ GrafoscopioDocumentation >> localPlace [
localPlace := anObject ^ localPlace ifNil: [
localPlace := FileLocator workingDirectory asFileReference / 'Grafoscopio' ].
]
{ #category : #accessing }
GrafoscopioDocumentation >> localPlace: aFileDirectory [
localPlace := aFileDirectory.
self localPlace exists ifFalse: [ self localPlace ensureCreateDirectory ].
]
{ #category : #accessing }
GrafoscopioDocumentation >> name [
^ name
]
{ #category : #accessing }
GrafoscopioDocumentation >> name: anObject [
name := anObject
]
{ #category : #accessing }
GrafoscopioDocumentation >> openNotebookAt: index [
"I open a notebook included with the documentation, located at a given index (anInteger)"
| notebookTemp |
(index between: 1 and: self documents size)
ifFalse: [ ^ self ]
ifTrue: [
notebookTemp := (self localPlace fullName, '/', (self documents at: index)) asFileReference.
notebookTemp exists
ifTrue: [GrafoscopioNotebook new openFromFile: notebookTemp]
ifFalse: [ self updateUI ]]
] ]
{ #category : #accessing } { #category : #accessing }
@ -213,3 +247,24 @@ GrafoscopioDocumentation >> repository [
GrafoscopioDocumentation >> repository: anObject [ GrafoscopioDocumentation >> repository: anObject [
repository := anObject repository := anObject
] ]
{ #category : #updating }
GrafoscopioDocumentation >> update [
(self listOutdatedDocs)
ifEmpty: [
self inform: 'All documents in the ', self name,' collection are already updated'.
^ self ]
ifNotEmpty: [:outdatedDocs |
outdatedDocs do: [ :eachDoc | self download: eachDoc].
self inform: 'Updating of ', self name,' documentation finished.' ]
]
{ #category : #updating }
GrafoscopioDocumentation >> updateUI [
"Updates documentation (manual, tutorials) from the official repository for a given documentation."
| update |
update := (UIManager default
confirm: 'Do you wish to update the ', self name,' documentation?'
label: 'Update ', self name, ' documentation').
update ifTrue: [ self update ]
]