Skip to content

Commit

Permalink
GetPrinciple renamed to GetPrincipal * ⎕DFs added/improved
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Apr 28, 2024
1 parent b476099 commit 4d5d7b9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
36 changes: 20 additions & 16 deletions APLSource/GitHubAPIv3.aplc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@

rVersion
:Access Public Shared
r'GitHubAPIv3' '1.2.0' '2024-03-19'
r'GitHubAPIv3' '1.2.0' '2024-04-28'

History
:Access Public Shared
* 1.2.0
* Dependencies updated
* Instances of GitHubAPIv3 now have a useful display format: for a user "foo" it shows GitHubAPIv3[foo]
* The name of the function `GetPrinciple` was changed to `GetPrincipal`
* When Assert signals an error not only the message but also the HTTP code is returned as in "Not found (404)"
* Package dependencies updated
* Bug fixes
* The DF of an issue was wrong ("Issues" rather than "Issue"). While on it the issue number was added.
* 1.1.0
Dependencies updated: HttpCommand and APLTreeUtil2
* 1.0.1
Expand Down Expand Up @@ -52,6 +57,7 @@
_regEx'setup_<repoName>_<version>[.\]*.[0-9]{0,6}\.exe' After version there _might_ be a built number
A(⊃⊃⎕CLASS ⎕THIS).##.APLTreeUtils2
H(⊃⊃⎕CLASS ⎕THIS).##.HttpCommand
⎕DF'GitHubAPIv3[',owner,']'

nsGetLatestReleaseInfo repoName;gitPath
Expand Down Expand Up @@ -131,16 +137,16 @@
:Access Public Instance
Returns all issues for a given repository but no pull requests by default.\\
In GitHub, every pull request is an issue, but not all issues are pull requests.
You can enforce Pull Requests by passing a 1 as left argument.
You can enforce the addition of Pull Requests by passing a 1 as left argument.
addPullRequests{0<⎕NC : 0}'addPullRequests'
gitPath'https://api.github.com/repos/',(_owner),'/',repoName,'/issues'
nsGetJson gitPath
:If ~addPullRequests
ns(0=¨ns.⎕NC'pull_request')/ns
:EndIf
ns.{⎕DF'[Issues of repo ',,']'}repoName
ns.⎕DF(repoName,' issue '),¨(¨ns.number)
ns.⎕FX⎕CR'∆List'
ns.⎕FX'r←∆Details instance' 'r←∆List' ' :If 0<≢instance' 'r(instance.GetPrinciple)←''assignees'' ''login''' 'r(instance.GetPrinciple)←''labels'' ''name''' ':EndIf'
ns.⎕FX'r←∆Details instance' 'r←∆List' ' :If 0<≢instance' 'r(instance.GetPrincipal)←''assignees'' ''login''' 'r(instance.GetPrincipal)←''labels'' ''name''' ':EndIf'
ns.⎕FX'r←∆QuickView instance;keyWords' 'r←∆Details instance' 'keyWords←''title'' ''number'' ''state'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]'

Expand All @@ -155,7 +161,7 @@
nsGetJson gitPath
ns.{⎕DF }'[Issue ',(number),' of repo ',repoName,']'
ns.⎕FX ⎕CR'∆List'
ns.⎕FX'r←∆Details instance' 'r←∆List' 'r(instance.GetPrinciple)←''assignees'' ''login''' 'r(instance.GetPrinciple)←''labels'' ''name'''
ns.⎕FX'r←∆Details instance' 'r←∆List' 'r(instance.GetPrincipal)←''assignees'' ''login''' 'r(instance.GetPrincipal)←''labels'' ''name'''
ns.⎕FX'r←∆QuickView instance;keyWords' 'r←∆Details instance' 'keyWords←''title'' ''number'' ''state'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]'

Expand Down Expand Up @@ -312,7 +318,7 @@
:EndIf
h.URLEncodeBlank gitURL
rh.Run
r.HttpMessage Assert r.HttpStatus=200
(r.HttpMessage,' (',(r.HttpStatus),')')Assert r.HttpStatus=200
data⎕JSON r.Data
noOfPagesGetNoOfPages r.Headers
:If 0<noOfPages
Expand All @@ -321,32 +327,30 @@
link2r.Headers[ind;]
h.URL{¯11¯1+';'}link
r2h.Run
r.HttpMessage Assert r.HttpStatus200 Assert 200=r.HttpStatus
(r.HttpMessage,' (',(r.HttpStatus),')')Assert r.HttpStatus=200
data,⎕JSON r2.Data
:If 2<noOfPages
Fetch all remaining pages
links({¯21¯1+';'}link){,}¨2noOfPages
:For link :In links
h.URLlink
r2h.Run
r.HttpMessage Assert r.HttpStatus=200
(r.HttpMessage,' (',(r.HttpStatus),')')Assert r.HttpStatus=200
data,⎕JSON r2.Data
:EndFor
:EndIf
:EndIf

datadata GetPrinciple(propName principleName);row;jsonObj;buff
* `propName` is the name of a variable in a data space that is one or more JSON object(s)
* `principleName` is the principle name of all the properties of that JSON object\\
datadata GetPrincipal(propName principalName);row;jsonObj;buff
* `propName` is the name of a variable in `data` holding one or more JSON object(s).\\
* `principalName` is the principal name of that JSON object or JSON objects.\\
Typical examples are "label" or "name"\\
The generic names are then replaced but the "real" ones.
Is concatenated with a comma and a blank, so ('bug' 'question') become:
'bug, question'
The generic names are then replaced but the real data.
:Access Public instance
rowdata[;1]propName
:If 0jsonObj2data[row;]
buffjsonObj¨principleName
buffjsonObj¨principalName
data[row;2]{,', ',}/buff
:EndIf
Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_GetRelease_008.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
T.FailsIf 1
:Else
dmx⎕DMX
T.PassesIf'Not Found'dmx.EM
T.PassesIf'Not Found (404)'dmx.EM
:EndTrap

RT._OK
Expand Down
Binary file modified TestResults/CodeCoverage.cr
Binary file not shown.
Binary file modified TestResults/CodeCoverage.profile
Binary file not shown.
2 changes: 1 addition & 1 deletion apl-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
source: "APLSource/GitHubAPIv3.aplc",
tags: "github-utilities",
userCommandScript: "",
version: "1.1.0+35",
version: "1.2.0+37",
}

0 comments on commit 4d5d7b9

Please sign in to comment.