-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/Molecule-Geographical-Position-Example/MolGeoDownloadedRessource.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Class { | ||
#name : #MolGeoDownloadedRessource, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'downloadDirectory' | ||
], | ||
#category : #'Molecule-Geographical-Position-Example' | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
MolGeoDownloadedRessource class >> ensureAllDownloaded [ | ||
|
||
<script: 'self ensureAllDownloaded'> | ||
self allSubclassesDo: [ :each | | ||
each new | ||
downloadDirectory: self ressourcesDirectory; | ||
ensureDownloaded ] | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
MolGeoDownloadedRessource class >> ressourcesDirectory [ | ||
| reference | | ||
reference := FileLocator imageDirectory asFileReference / 'ressources'. | ||
(reference exists and: [ reference isDirectory ]) ifTrue: [ ^ reference ]. | ||
(reference exists and: [ reference isDirectory not ]) ifTrue: [ Error signal: 'ressources directory is not a directory.' ]. | ||
DiskStore current createDirectory: reference asPath. | ||
^ reference | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> baseUrl [ | ||
|
||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> download [ | ||
|
||
('Downloading {1}...' format: { self fileName }) traceCr. | ||
|
||
[ | ||
ZnClient new | ||
url: self baseUrl , self fileName; | ||
numberOfRetries: 5; | ||
timeout: 100; | ||
logToTranscript; | ||
downloadTo: self downloadDirectory ensureCreateDirectory; | ||
yourself. | ||
|
||
' | ||
Download finished - ' trace ] timeToRun traceCr | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> downloadDirectory [ | ||
|
||
^ downloadDirectory | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> downloadDirectory: aFileReference [ | ||
|
||
downloadDirectory := aFileReference | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> ensureDownloaded [ | ||
|
||
self isDownloaded ifFalse: [ self download ] | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> fileName [ | ||
|
||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> fileReference [ | ||
|
||
^ self downloadDirectory / self fileName | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoDownloadedRessource >> isDownloaded [ | ||
|
||
^ self fileReference exists | ||
] |
17 changes: 17 additions & 0 deletions
17
src/Molecule-Geographical-Position-Example/MolGeoMapDownloaded.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Class { | ||
#name : #MolGeoMapDownloaded, | ||
#superclass : #MolGeoDownloadedRessource, | ||
#category : #'Molecule-Geographical-Position-Example' | ||
} | ||
|
||
{ #category : #testing } | ||
MolGeoMapDownloaded >> baseUrl [ | ||
|
||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : #testing } | ||
MolGeoMapDownloaded >> fileName [ | ||
|
||
^ self subclassResponsibility | ||
] |