From 9844b266d6da2a6b9ecceacd0faf918d1b53db26 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 2 May 2024 11:00:36 -0500 Subject: [PATCH] Starting GitHubAsset listings for later downloading. --- src/ExoRepo/GitHubAsset.class.st | 56 ++++++++++++++++++++++++++++++ src/ExoRepo/GitHubWrapper.class.st | 7 ++++ 2 files changed, 63 insertions(+) create mode 100644 src/ExoRepo/GitHubAsset.class.st diff --git a/src/ExoRepo/GitHubAsset.class.st b/src/ExoRepo/GitHubAsset.class.st new file mode 100644 index 0000000..35c74a9 --- /dev/null +++ b/src/ExoRepo/GitHubAsset.class.st @@ -0,0 +1,56 @@ +Class { + #name : #GitHubAsset, + #superclass : #Object, + #instVars : [ + 'name', + 'created', + 'updated', + 'size', + 'downloadLink' + ], + #category : #'ExoRepo-External' +} + +{ #category : #accessing } +GitHubAsset class >> fromDictionary: aGitHubAssetDictionary [ + | response | + response := self new + name: (aGitHubAssetDictionary at: 'name'); + size: (aGitHubAssetDictionary at: 'size'); + created: (aGitHubAssetDictionary at: 'created_at'); + updated: (aGitHubAssetDictionary at: 'updated_at'); + downloadLink: (aGitHubAssetDictionary at: 'browser_download_url'). + ^ response +] + +{ #category : #accessing } +GitHubAsset >> created: anObject [ + created := anObject +] + +{ #category : #accessing } +GitHubAsset >> downloadLink: anUrl [ + downloadLink := anUrl +] + +{ #category : #accessing } +GitHubAsset >> name: anObject [ + name := anObject +] + +{ #category : #accessing } +GitHubAsset >> printOn: aStream [ + super initialize. + aStream + nextPutAll: '(', name, ')' +] + +{ #category : #accessing } +GitHubAsset >> size: anObject [ + size := anObject +] + +{ #category : #accessing } +GitHubAsset >> updated: anObject [ + updated := anObject +] diff --git a/src/ExoRepo/GitHubWrapper.class.st b/src/ExoRepo/GitHubWrapper.class.st index 2e6c314..a611eaa 100644 --- a/src/ExoRepo/GitHubWrapper.class.st +++ b/src/ExoRepo/GitHubWrapper.class.st @@ -12,6 +12,13 @@ GitHubWrapper class >> apiEndPoint [ ^ 'https://api.github.com/' asUrl ] +{ #category : #accessing } +GitHubWrapper >> assets [ + ^ (self lastReleaseData at: 'assets') collect: [:each | + GitHubAsset fromDictionary: each + ] +] + { #category : #accessing } GitHubWrapper >> lastReleaseData [ | releasesLink |