Skip to content

Commit

Permalink
Is Tatin package now
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Mar 17, 2021
1 parent bcfa5c0 commit 5a30110
Show file tree
Hide file tree
Showing 41 changed files with 6,026 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.acre/
aplcore
Dist/
change_history/
.gitignore
54 changes: 32 additions & 22 deletions APLSource/GitHubAPIv3.aplc
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
It is part of the [APLTree library](https://github.com/aplteam/apltree/wiki)
Kai Jaeger ⋄ APL Team Ltd

:Include APLTreeUtils

⎕IO1 ⎕ML1

rVersion
:Access Public Shared
r'GitHub' '0.6.0.18' '2020-03-23'
r'GitHub' '0.7.0+22' '2020-03-17'

History
:Access Public Shared
* 0.7.0
* Is a Tatin package now and therefore requires 18.0 Unicode or better
* Does not :Include APLTreeUtils anymore (but does depend on APLTreeUtils2 being a sibling)
* 0.6.0
* File extension is now .aplc rather than .dyalog
* 0.5.0
Expand Down Expand Up @@ -79,6 +80,7 @@
:Implements Constructor
_ownerowner
_regEx'setup_<repoName>_<version>[.\]*.[0-9]{0,6}\.exe' After version there _might_ be a built number
A(⊃⊃⎕CLASS ⎕THIS).##.APLTreeUtils2

(rc msg ns)GetLatestReleaseInfo repoName;gitPath
Expand Down Expand Up @@ -213,7 +215,7 @@
:EndIf

(rc msg endpoints)GetAllEndpoints;gitPath;msg;rc
(rc msg endpoints)GetAllEndpoints;gitPath;msg;rc;A
:Access Public Shared
This method returns all REST endpoints offered by the API.\\
It returns a namespace. Use the built-in `List` function for an overview.
Expand All @@ -224,6 +226,7 @@
: Is empty in case `rc ←→ 0` but might offer addtional information otherwise.
`ns`
: Namespace with the data received from GitHub.
A##.APLTreeUtils2
gitPath'https://api.github.com/'
endpoints⎕NS''
(rc msg endpoints)GetJson gitPath
Expand Down Expand Up @@ -269,9 +272,14 @@
+ 1.20.333 transforms into 120333
+ 12.12.123.12345 transforms into 1212123.12345\\
number
This function might be called from a Shared method. when we need to address APLTreeUtils2 explicitly,
or from a n Instance method, when `A` is a ref pointing to APLTreeUtils2.
:If 0<##.⎕NC'APLTreeUtils2'
A##.APLTreeUtils2
:EndIf
:If 0<text{+/\0=⎕D}text
text,,/(02-text+.='.')'.0'
:AndIf 0=+/{(1<)'0'=1}¨'.'Split text
:AndIf 0=+/{(1<)'0'=1}¨'.'A.Split text
(bool vec)'.'⎕VFI text
:AndIf 3 4bool
vec{34}vec
Expand Down Expand Up @@ -307,7 +315,7 @@
:If 0=⎕NC'regEx'
regEx_regEx
:EndIf
typeUppercase type
type1 ⎕C type
'Invalid right argument ("type")'⎕SIGNAL 11/~(type)'EXE' 'ZIP' 'TAR'
:If 0=⎕NC'tag'
(rc more info)GetLatestReleaseInfo repoName
Expand All @@ -331,7 +339,7 @@
regEx'/',_owner,'/',repoName,'/releases/download/v',tag,'/',regEx
:If 1=buffregEx ⎕S 2 0 1('Greedy' 0)('IC' 1)html
(itemNo offset length)buff
url'https://github.com/',1(1+length)(offset-1)(itemNo+1)(⎕UCS 10)Split html
url'https://github.com/',1(1+length)(offset-1)(itemNo+1)(⎕UCS 10)A.Split html
:EndIf
:EndIf
:EndIf
Expand All @@ -342,8 +350,13 @@
Note that drafted release and pre-release are both ignored.
:Access Public Instance
(rc more ns)GetLatestReleaseInfo repoName
:If /'Error'more
'Error accessin GitHub via the REST API'⎕SIGNAL 11
:If 0rc
:OrIf /'Error'more
:If 0=more
'Error accessing GitHub via the REST API'⎕SIGNAL 11
:Else
more ⎕SIGNAL 11
:EndIf
:Else
tagns.tag_name
:EndIf
Expand Down Expand Up @@ -418,10 +431,10 @@
GetNoOfPages{
Takes HTTP headers and returns the number of pages. If there are not any a zero is returned.
headers
bool'Link:'{¨()¨}headers
bool'link:'{¨()¨}⎕C headers
0=+/bool:0
link(bool1)headers
buff' 'Split link
buff' 'A.Split link
last(¯1+buff)buff
buff{{('?page-')[2][1]}'(&|\?)page=[0-9]{1,}'⎕S 0 1}last
⊃⊃(//)⎕VFI buff
Expand All @@ -430,16 +443,16 @@
GetLinkToNextPage{
Takes HTTP headers and returns the link pointing to the next page, if any
headers
bool'Link:'{¨()¨}headers
bool'link:'{¨()¨}⎕C headers
0=+/bool:0
link(bool1)headers
buff' 'Split link
buff' 'A.Split link
1¯21buff
}

SplitHeaders{
headers1(⎕UCS 10 13)
(⎕UCS 13 10)Split headers
A.Split headers
}

txtGetText obj;ts
Expand All @@ -451,19 +464,16 @@
Takes `gitURL`which must specify a valid GitHub API URL and returns the data from GitHub.\\
`⍵`: Project URL, for example 'api.github.com/repos/aplteam/testrepo/releases/latest'
`⍺`: Optional parameter space, typically create by calling `CreateHttpParms`.
`rc`
: Either 0 for okay or an error code.\\
`msg`
: Is empty in case `rc←→0` but might offer addtional information otherwise.
`ns`
: Namespace with the data received from GitHub.
| `rc` | Either 0 for okay or an error code.
| `msg` | Is empty in case `rc←→0` but might offer addtional information otherwise.
| `ns` | Namespace with the data received from GitHub.
parms{0<⎕NC : CreateHttpParms}'parms'
:If 0=⎕NC'_owner'
owner'APL GitHub API'
:Else
owner_owner
:EndIf
gitURL'https://'{,/()}Lowercase gitURL
gitURL'https://'{,/()}⎕C gitURL
rc0
msg''
ns⎕NS''
Expand Down Expand Up @@ -517,7 +527,7 @@
:If 0=type Import?
r7159y
:ElseIf 1=type Export!
∘∘∘ Not implemented yet (because not required)
∘∘∘ Not implemented yet (because never required)
7160
:Else
∘∘∘ Huuh?!
Expand Down
10 changes: 10 additions & 0 deletions APLSource/Initialize.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{r}Initialize;⎕TRAP;parent
⎕TRAP0 'S'
r
{}⎕SE.UCMD'cd ',AcreConfig.ProjectFolder
⎕WSIDAcreConfig.ProjectFolder,'project.dws'
parent⎕THIS
{}⎕SE.Tatin.LoadDependencies'./packages/'parent
parent,'.TestCases'
{}⎕SE.Tatin.LoadDependencies'./packages_dev/'parent
Done
20 changes: 18 additions & 2 deletions APLSource/TestCases/Prepare.aplf
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
Prepare
T⎕NEW ##.Tester2 ⎕THIS
Prepare;testPath;testFilename;ask;answer
⎕IO1 ⎕ML1
T⎕NEW Tester2 ⎕THIS
testPath(1 ⎕NPARTS''),'TestResults'
testFilenametestPath,'/CodeCoverage'
:If ⎕NEXISTS testPath
:If ⎕NEXISTS testFilename,'.dcf'
ask{,'; 1=append, 2=replace' a ~(a)1 2: a}
answerask'Coverage file already exists'
:If 2answer
1 ⎕NDELETE testFilename,'.dcf'
:EndIf
:EndIf
:EndIf
3 ⎕MKDIR testPath
T.codeCoverage⎕NEW CodeCoverage(,'#.',{,'.',}2⎕THIS.##)
T.codeCoverage.filenametestFilename
Done
8 changes: 8 additions & 0 deletions APLSource/TestCases/RunTests.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
RunTests;htmlFilename
Prepare
T.Run 1
htmlFilenameCodeCoverage.ProcessDataAndCreateReport T.codeCoverage.filename
:If 1 ∆YesOrNo'View CodeCoverage report?'
APLTreeUtils2.GoToWebPage'file://',htmlFilename
:EndIf
Done
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_GetRelease_003.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
RT._Failed

url∆MyGitHubAPI.GetRelease'APLTreeUtils' 'EXE' Becauss this test project has no EXE!
url∆MyGitHubAPI.GetRelease'APLTreeUtils2' 'EXE' Becauss this test project has no EXE!
T.PassesIf 0=url
url∆MyGitHubAPI.GetRelease'TestRepo' 'EXE' This one has an EXE!
T.PassesIf'https://'{()}url
Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_Misc_001.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(rc more data)∆MyGitHubAPI.GetAllRepos
T.PassesIf 0=rc
T.PassesIf 0=more
T.PassesIf 30<data Important: GitHub pages requests to a max of 30 items per page,
T.PassesIf 30<data Important: GitHub returns by default a maximum of 30 items per page; there are more repositories, and all should be delivered

RT._OK
Done
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_Misc_030.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

(rc more data)∆MyGitHubAPI.GetAllTopics'TestRepo'
T.PassesIf 0=rc
T.PassesIf 0=more
T.PassesIf 0=more You will possibly get a 403 if the test cases are executed too often (GitHub does allow only so many requests without authentication)
T.PassesIf 0<data

:If 0
Expand Down
21 changes: 10 additions & 11 deletions APLSource/TestCases/Test_ZZZ_998.aplf
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
RTest_ZZZ_998(stopFlag batchFlag);⎕IO;⎕ML;⎕TRAP;report;buff;xml;source
RTest_ZZZ_998(stopFlag batchFlag);⎕IO;⎕ML;⎕TRAP;report;buff;rf
Checks on two text vectors: "⍝TODO⍝" and "⍝CHECK⍝"; never fails, just reports.
⎕IO0 ⎕ML3
⎕IO1 ⎕ML1
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
RT._OK
report''
rf##.GitHubAPIv3

xml⎕XML'flat'##.APLTreeUtils.ReadUtf8File'publish.config'
source2xml[xml[;1]'container';]
buffT.FindSpecialString'⍝CHECK⍝'
buff(buff[;0]¨⎕XSI[0])buff remove caller
:If ~0buff
buffrf T.FindSpecialString'⍝CHECK⍝'
buff(buff[;1]¨⎕XSI[1])buff remove caller
:If 0buff
report,(' ⍝CHECK⍝ found:'),(' '),¨buff
:EndIf
buffT.FindSpecialString'⍝TODO⍝'
buff(buff[;0]¨⎕XSI[0])buff remove caller
:If ~0buff
buffrf T.FindSpecialString'⍝TODO⍝'
buff(buff[;1]¨⎕XSI[1])buff remove caller
:If 0buff
report,(' ⍝TODO⍝ found:'),(' '),¨buff
:EndIf
:If 1=,report
:If 1=report
report,' Nothing found!'
:Else
'Checking for ⍝TODO⍝ and ⍝CHECK⍝ '{,'--- ',,' ','-'}80⎕PW-1
Expand Down
33 changes: 0 additions & 33 deletions APLSource/TestCases/Test_ZZZ_999.aplf

This file was deleted.

51 changes: 51 additions & 0 deletions APLSource/TestCases/∆YesOrNo.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
yesOrNo{default}∆YesOrNo question;isOkay;answer;add;dtb;answer2
Ask a simple question and allows just "Yes" or "No" as answers.
You may specify a default via the optional left argument which when specified
rules what happens when the user just presses <enter>.
`default` must be either 1 (yes) or 0 (no).
Note that this function does not work as expected when traced!
isOkay0
default{0<⎕NC : ''}'default'
isOkay0
:If 0default
'Left argument must be a scalar'⎕SIGNAL 11/1default
:AndIf ~default0 1
'The left argument. if specified, must be a Boolean or empty'⎕SIGNAL 11
:EndIf
:If 0=default
add' (y/n) '
:Else
:If default
add' (Y/n) '
:Else
add' (y/N) '
:EndIf
:EndIf
:If 1<question
((question)question)((question)question),add
questionquestion
:Else
questionquestion,add
:EndIf
:Repeat
question
answer
:If answerquestion Did... (since version 18.0 trailing blanks are not removed anynmore)
:OrIf (answer)=¯1+question ..the ...
:OrIf 0=answer ...user just...
dtb{-+/\' '=}
answer2dtb answer
:OrIf answer2((-answer2)(⎕UCS 10){~: ' ',dtb {1+}}question) ...press <enter>?
:If 0default
yesOrNodefault
isOkay1
:EndIf
:Else
answer¯1{-+/\' '=}answer
:If answer'YyNn'
isOkay1
yesOrNoanswer'Yy'
:EndIf
:EndIf
:Until isOkay
Done
Binary file removed Dist/GitHubAPIv3-0.6.0.18.zip
Binary file not shown.
Binary file modified Make/Make.DWS
Binary file not shown.
2 changes: 0 additions & 2 deletions Make/Make.bat

This file was deleted.

Binary file added TestResults/CodeCoverage.dcf
Binary file not shown.
Loading

0 comments on commit 5a30110

Please sign in to comment.