GrafoscopioUtils/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st

53 lines
1.5 KiB
Smalltalk
Raw Normal View History

"
I contain simple general functionality used by Grafoscopio, Dataviz
or other related projects.
"
Class {
#name : #GrafoscopioUtils,
#superclass : #Object,
#category : #'Grafoscopio-Utils'
}
{ #category : #'graphical interface' }
GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [
| fileName |
fileName := downloadUrl segments last.
(location / fileName) ensureDelete.
[: bar |
bar title: aString.
[ZnClient new
enforceHttpSuccess: true;
url: downloadUrl;
downloadTo: location;
signalProgress: true
]
on: HTTPProgress
do: [ :progress |
progress isEmpty ifFalse: [ bar current: progress percentage ].
progress resume ].
] asJob run.
]
{ #category : #private }
GrafoscopioUtils class >> sanitize: url [
"I remove white spaces in url's and prepend 'http://' to urls when it is ommited, so
operations that rely on sane and well formed urls don't throw error messages."
| sanitized modUrl |
modUrl := url.
[modUrl endsWith: ' ']
whileTrue: [ modUrl := modUrl copyFrom: 1 to: (modUrl size - 1) ].
(url beginsWith: 'http://')
ifFalse: [ sanitized := ('http://', modUrl) asUrl ]
ifTrue: [ sanitized := modUrl asUrl ].
^ sanitized
]
{ #category : #updating }
GrafoscopioUtils class >> update [
"Updates GrafoscopioUtils with new versions of itself take from the source code repository."
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
2017-08-11 13:39:08 +00:00
package: 'Grafoscopio-Utils';
load.
]