项目作者: hernanmd

项目描述 :
Add helper methods to download resources in Baseline or Metacello Configurations (Pharo Smalltalk)
高级语言: Smalltalk
项目地址: git://github.com/hernanmd/MetacelloFileDownload.git
创建时间: 2017-12-27T05:05:54Z
项目社区:https://github.com/hernanmd/MetacelloFileDownload

开源协议:MIT License

下载


Table of Contents

Description

Add helper methods to download resources in Baseline or Metacello Configurations in Pharo Smalltalk. The files that you specify will be downloaded and uncompressed without need to write any code.

Installation

Note: You do not need to install it in your Pharo image unless you want to make modifications to this package. See the Usage section below.

  1. EpMonitor disableDuring: [
  2. Metacello new
  3. baseline: 'MetacelloFileDownload';
  4. repository: 'github://hernanmd/MetacelloFileDownload';
  5. load ]

Usage

  • You can upload your files anywhere you want.
  • All your files must be already uploaded in .zip or .tar.gz
  • .zip or .tar.gz files will be downloaded and uncompressed in the FileSystem workingDirectory (check if you have write permissions first).
  • You can add several (mirror) URL’s for the same resource file (see examples below).

Add the following line in the #baseline method of your Configuration/BaselineOf class:

  1. "... configuration code ... "
  2. spec preLoadDoIt: #preLoad.
  3. "... configuration code ... "

To enable bootstrapping add the following two methods to your Configuration/Baseline (instance side)

  1. ensureMetacelloFileDownload
  2. EpMonitor disableDuring: [
  3. Metacello new
  4. baseline: 'MetacelloFileDownload';
  5. onWarningLog;
  6. repository: 'github://hernanmd/MetacelloFileDownload';
  7. load ]

Add the #preLoad method (instance side) in your BaselineOf/ConfigurationOf class:

  1. preLoad
  2. self ensureMetacelloFileDownload.
  3. super preLoad.

Resources

Finally, in your ConfigurationOf/BaselineOf class (instance side), add a method with selector #platformFilesUrl answering a Collection of download URL’s.

If you have one resource file for all OS

Assuming you have uploaded your resource files named “file1.zip” and file1.tar.gz to a “res” directory in your repository:

  1. platformFilesUrl
  2. ^ Array with: 'https://github.com/yourGHUser/yourProject/raw/master/res/file1.zip' ]

If you have one URL for your resource file for multiple OS

Assuming you have uploaded your resource files named “file1.zip” and file1.tar.gz to a “res” directory:
(don’t forget the last / before the last URL fragment)

  1. platformFilesUrl
  2. ^ Array with: (String streamContents: [ : stream |
  3. stream
  4. nextPutAll: 'https://github.com/yourGHUser/yourProject/raw/master/res/';
  5. nextPutAll: (
  6. Smalltalk os isWin32
  7. ifTrue: [ 'file1.zip' ]
  8. ifFalse: [ 'file1.tar.gz' ]) ])

If you have mirror URLs for your resource file

The same as above, specify the raw URL to your resource files

  1. platformFilesUrl
  2. ^ Smalltalk os isWin32
  3. ifTrue: [ #(
  4. 'https://github.com/..../file1.zip'
  5. 'http://www.dropbox.com/file1.zip' ) ]
  6. ifFalse: [ #(
  7. 'https://github.com/..../file1.tar.gz'
  8. 'http://www.dropbox.com/file1.tar.gz') ].

That’s all. Try your Configuration or Baseline script!

License

This software is licensed under the MIT License.

Copyright Hernán Morales, 2018-2022.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.