From e5b6269547376ec55261c53c38f55723055ef7e2 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 2 May 2024 10:27:48 -0500 Subject: [PATCH] GitHubWrapper now contains common functionality for external programs provided via GitHub. --- src/ExoRepo/GitHubWrapper.class.st | 35 ++++++++++++++++++++++++++++++ src/ExoRepo/YQ.class.st | 10 +++------ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/ExoRepo/GitHubWrapper.class.st diff --git a/src/ExoRepo/GitHubWrapper.class.st b/src/ExoRepo/GitHubWrapper.class.st new file mode 100644 index 0000000..2e6c314 --- /dev/null +++ b/src/ExoRepo/GitHubWrapper.class.st @@ -0,0 +1,35 @@ +Class { + #name : #GitHubWrapper, + #superclass : #Object, + #instVars : [ + 'repository' + ], + #category : #'ExoRepo-External' +} + +{ #category : #accessing } +GitHubWrapper class >> apiEndPoint [ + ^ 'https://api.github.com/' asUrl +] + +{ #category : #accessing } +GitHubWrapper >> lastReleaseData [ + | releasesLink | + releasesLink := self class apiEndPoint addPathSegment: 'repos'. + self repository asUrl segments do: [:segment | + releasesLink addPathSegment: segment + ]. + releasesLink addPathSegment: 'releases'. + ^ (STONJSON + fromString: releasesLink retrieveContents) first +] + +{ #category : #accessing } +GitHubWrapper >> repository [ + ^ repository +] + +{ #category : #accessing } +GitHubWrapper >> repository: anUrl [ + repository := anUrl +] diff --git a/src/ExoRepo/YQ.class.st b/src/ExoRepo/YQ.class.st index 2424ca3..7290b3c 100644 --- a/src/ExoRepo/YQ.class.st +++ b/src/ExoRepo/YQ.class.st @@ -26,7 +26,9 @@ YQ class >> binaryFile [ { #category : #accessing } YQ class >> install [ - ^ self lastReleaseData + ^ GitHubWrapper new + repository: 'https://github.com/mikefarah/yq'; + lastReleaseData ] { #category : #accessing } @@ -45,9 +47,3 @@ YQ class >> jsonToYaml: aDictionary [ Smalltalk os isWindows ifTrue: [ ^ LibC resultOfCommand: 'yq -p=json ', jsonFile fullName ]. ] - -{ #category : #accessing } -YQ class >> lastReleaseData [ - ^ (STONJSON - fromString: 'https://api.github.com/repos/mikefarah/yq/releases' asUrl retrieveContents) first -]