Skip to content

Commit 5a30110

Browse files
committed
Is Tatin package now
1 parent bcfa5c0 commit 5a30110

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6026
-75
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.acre/
22
aplcore
3+
Dist/
4+
change_history/
5+
.gitignore

APLSource/GitHubAPIv3.aplc

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
⍝ It is part of the [APLTree library](https://github.com/aplteam/apltree/wiki)
1313
⍝ Kai Jaeger ⋄ APL Team Ltd
1414

15-
:Include APLTreeUtils
16-
1715
⎕IO←1 ⋄ ⎕ML←1
1816

1917
∇ r←Version
2018
:Access Public Shared
21-
r←'GitHub' '0.6.0.18' '2020-03-23'
19+
r←'GitHub' '0.7.0+22' '2020-03-17'
2220
2321

2422
∇ History
2523
:Access Public Shared
24+
⍝ * 0.7.0
25+
⍝ * Is a Tatin package now and therefore requires 18.0 Unicode or better
26+
⍝ * Does not :Include APLTreeUtils anymore (but does depend on APLTreeUtils2 being a sibling)
2627
⍝ * 0.6.0
2728
⍝ * File extension is now .aplc rather than .dyalog
2829
⍝ * 0.5.0
@@ -79,6 +80,7 @@
7980
:Implements Constructor
8081
_owner←owner
8182
_regEx←'setup_<repoName>_<version>[.\]*.[0-9]{0,6}\.exe' ⍝ After version there _might_ be a built number
83+
A←(⊃⊃⎕CLASS ⎕THIS).##.APLTreeUtils2
8284
8385

8486
∇ (rc msg ns)←GetLatestReleaseInfo repoName;gitPath
@@ -213,7 +215,7 @@
213215
:EndIf
214216
215217

216-
∇ (rc msg endpoints)←GetAllEndpoints;gitPath;msg;rc
218+
∇ (rc msg endpoints)←GetAllEndpoints;gitPath;msg;rc;A
217219
:Access Public Shared
218220
⍝ This method returns all REST endpoints offered by the API.\\
219221
⍝ It returns a namespace. Use the built-in `List` function for an overview.
@@ -224,6 +226,7 @@
224226
⍝ : Is empty in case `rc ←→ 0` but might offer addtional information otherwise.
225227
⍝ `ns`
226228
⍝ : Namespace with the data received from GitHub.
229+
A←##.APLTreeUtils2
227230
gitPath←'https://api.github.com/'
228231
endpoints←⎕NS''
229232
(rc msg endpoints)←GetJson gitPath
@@ -269,9 +272,14 @@
269272
⍝ + 1.20.333 transforms into 120333
270273
⍝ + 12.12.123.12345 transforms into 1212123.12345\\
271274
number←⍬
275+
⍝ This function might be called from a Shared method. when we need to address APLTreeUtils2 explicitly,
276+
⍝ or from a n Instance method, when `A` is a ref pointing to APLTreeUtils2.
277+
:If 0<##.⎕NC'APLTreeUtils2'
278+
A←##.APLTreeUtils2
279+
:EndIf
272280
:If 0<≢text←{⍵↓⍨+/∧\0=⍵∊⎕D}text
273281
text,←⊃,/(0⌈2-text+.='.')⍴⊂'.0'
274-
:AndIf 0=+/{(1<⊃≢⍵)∧⊃'0'=1↑⍵}¨'.'Split text
282+
:AndIf 0=+/{(1<⊃≢⍵)∧⊃'0'=1↑⍵}¨'.'A.Split text
275283
(bool vec)←'.'⎕VFI text
276284
:AndIf 3 4∊⍨⍴bool
277285
vec←{⍵↑⍨3⌈4⌊⍴⍵}↑vec
@@ -307,7 +315,7 @@
307315
:If 0=⎕NC'regEx'
308316
regEx←_regEx
309317
:EndIf
310-
type←Uppercase type
318+
type←1 ⎕C type
311319
'Invalid right argument ("type")'⎕SIGNAL 11/⍨~(⊂type)∊'EXE' 'ZIP' 'TAR'
312320
:If 0=⎕NC'tag'
313321
(rc more info)←GetLatestReleaseInfo repoName
@@ -331,7 +339,7 @@
331339
regEx←'/',_owner,'/',repoName,'/releases/download/v',tag,'/',regEx
332340
:If 1=≢buff←regEx ⎕S 2 0 1⍠('Greedy' 0)('IC' 1)⊣html
333341
(itemNo offset length)←⊃buff
334-
url←'https://github.com/',1↓(1+length)↑(offset-1)↓(itemNo+1)⊃(⎕UCS 10)Split html
342+
url←'https://github.com/',1↓(1+length)↑(offset-1)↓(itemNo+1)⊃(⎕UCS 10)A.Split html
335343
:EndIf
336344
:EndIf
337345
:EndIf
@@ -342,8 +350,13 @@
342350
⍝ Note that drafted release and pre-release are both ignored.
343351
:Access Public Instance
344352
(rc more ns)←GetLatestReleaseInfo repoName
345-
:If ∨/'Error'⍷∊more
346-
'Error accessin GitHub via the REST API'⎕SIGNAL 11
353+
:If 0≠rc
354+
:OrIf ∨/'Error'⍷∊more
355+
:If 0=≢more
356+
'Error accessing GitHub via the REST API'⎕SIGNAL 11
357+
:Else
358+
more ⎕SIGNAL 11
359+
:EndIf
347360
:Else
348361
tag←ns.tag_name
349362
:EndIf
@@ -418,10 +431,10 @@
418431
GetNoOfPages←{
419432
⍝ Takes HTTP headers and returns the number of pages. If there are not any a zero is returned.
420433
headers←⍵
421-
bool←'Link:'{⍺∘≡¨(⍴⍺)↑¨⍵}headers
434+
bool←'link:'{⍺∘≡¨(⍴⍺)↑¨⍵}⎕C headers
422435
0=+/bool:0
423436
link←(bool⍳1)⊃headers
424-
buff←' 'Split link
437+
buff←' 'A.Split link
425438
last←(¯1+⍴buff)⊃buff
426439
buff←{⍵{(⍴'?page-')↓⍵[2]↑⍵[1]↓⍺}⊃'(&|\?)page=[0-9]{1,}'⎕S 0 1⊣⍵}last
427440
⊃⊃(//)⎕VFI buff
@@ -430,16 +443,16 @@
430443
GetLinkToNextPage←{
431444
⍝ Takes HTTP headers and returns the link pointing to the next page, if any
432445
headers←⍵
433-
bool←'Link:'{⍺∘≡¨(⍴⍺)↑¨⍵}headers
446+
bool←'link:'{⍺∘≡¨(⍴⍺)↑¨⍵}⎕C headers
434447
0=+/bool:0
435448
link←(bool⍳1)⊃headers
436-
buff←' 'Split link
449+
buff←' 'A.Split link
437450
1↓¯2↓⊃1↓buff
438451
}
439452

440453
SplitHeaders←{
441454
headers←⍵↑⍨1⍳⍨(⎕UCS 10 13)⍷⍵
442-
(⎕UCS 13 10)Split headers
455+
A.Split headers
443456
}
444457

445458
∇ txt←GetText obj;ts
@@ -451,19 +464,16 @@
451464
⍝ Takes `gitURL`which must specify a valid GitHub API URL and returns the data from GitHub.\\
452465
⍝ `⍵`: Project URL, for example 'api.github.com/repos/aplteam/testrepo/releases/latest'
453466
⍝ `⍺`: Optional parameter space, typically create by calling `CreateHttpParms`.
454-
⍝ `rc`
455-
⍝ : Either 0 for okay or an error code.\\
456-
⍝ `msg`
457-
⍝ : Is empty in case `rc←→0` but might offer addtional information otherwise.
458-
⍝ `ns`
459-
⍝ : Namespace with the data received from GitHub.
467+
⍝ | `rc` | Either 0 for okay or an error code.
468+
⍝ | `msg` | Is empty in case `rc←→0` but might offer addtional information otherwise.
469+
⍝ | `ns` | Namespace with the data received from GitHub.
460470
parms←{0<⎕NC ⍵:⍎⍵ ⋄ CreateHttpParms}'parms'
461471
:If 0=⎕NC'_owner'
462472
owner←'APL GitHub API'
463473
:Else
464474
owner←_owner
465475
:EndIf
466-
gitURL←'https://'{⍵,⍨⍺/⍨⍺≢(⍴⍺)↑⍵}Lowercase gitURL
476+
gitURL←'https://'{⍵,⍨⍺/⍨⍺≢(⍴⍺)↑⍵}⎕C gitURL
467477
rc←0
468478
msg←''
469479
ns←⎕NS''
@@ -517,7 +527,7 @@
517527
:If 0=type ⍝ Import?
518528
r←7159⌶y
519529
:ElseIf 1=type ⍝ Export!
520-
∘∘∘ ⍝ Not implemented yet (because not required)
530+
∘∘∘ ⍝ Not implemented yet (because never required)
521531
7160⌶
522532
:Else
523533
∘∘∘ ⍝ Huuh?!

APLSource/Initialize.aplf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{r}←Initialize;⎕TRAP;parent
2+
⎕TRAP←0 'S'
3+
r←⍬
4+
{}⎕SE.UCMD'cd ',AcreConfig.ProjectFolder
5+
⎕WSID←AcreConfig.ProjectFolder,'project.dws'
6+
parent←⍕⎕THIS
7+
{}⎕SE.Tatin.LoadDependencies'./packages/'parent
8+
parent,←'.TestCases'
9+
{}⎕SE.Tatin.LoadDependencies'./packages_dev/'parent
10+
⍝Done

APLSource/TestCases/Prepare.aplf

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
Prepare
2-
T←⎕NEW ##.Tester2 ⎕THIS
1+
Prepare;testPath;testFilename;ask;answer
2+
⎕IO←1 ⋄ ⎕ML←1
3+
T←⎕NEW Tester2 ⎕THIS
4+
testPath←(⊃1 ⎕NPARTS''),'TestResults'
5+
testFilename←testPath,'/CodeCoverage'
6+
:If ⎕NEXISTS testPath
7+
:If ⎕NEXISTS testFilename,'.dcf'
8+
ask←{⎕←⍵,'; 1=append, 2=replace' ⋄ a←⎕ ⋄ ~(⊂a)∊1 2:∇ ⍵ ⋄ ⊃a}
9+
answer←⊃ask'Coverage file already exists'
10+
:If 2≡answer
11+
1 ⎕NDELETE testFilename,'.dcf'
12+
:EndIf
13+
:EndIf
14+
:EndIf
15+
3 ⎕MKDIR testPath ⍝
16+
T.codeCoverage←⎕NEW CodeCoverage(,⊂'#.',{⍵,'.',⍵}2↓⍕⎕THIS.##)
17+
T.codeCoverage.filename←testFilename
18+
⍝Done

APLSource/TestCases/RunTests.aplf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RunTests;htmlFilename
2+
Prepare
3+
T.Run 1
4+
htmlFilename←CodeCoverage.ProcessDataAndCreateReport T.codeCoverage.filename
5+
:If 1 ∆YesOrNo'View CodeCoverage report?'
6+
APLTreeUtils2.GoToWebPage'file://',htmlFilename
7+
:EndIf
8+
⍝Done

APLSource/TestCases/Test_GetRelease_003.aplf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
44
R←T._Failed
55

6-
url←∆MyGitHubAPI.GetRelease'APLTreeUtils' 'EXE' ⍝ Becauss this test project has no EXE!
6+
url←∆MyGitHubAPI.GetRelease'APLTreeUtils2' 'EXE' ⍝ Becauss this test project has no EXE!
77
→T.PassesIf 0=≢url
88
url←∆MyGitHubAPI.GetRelease'TestRepo' 'EXE' ⍝ This one has an EXE!
99
→T.PassesIf'https://'{⍺≡(≢⍺)↑⍵}url

APLSource/TestCases/Test_Misc_001.aplf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(rc more data)←∆MyGitHubAPI.GetAllRepos
77
→T.PassesIf 0=rc
88
→T.PassesIf 0=≢more
9-
→T.PassesIf 30<≢data ⍝ Important: GitHub pages requests to a max of 30 items per page,
9+
→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
1010

1111
R←T._OK
1212
⍝Done

APLSource/TestCases/Test_Misc_030.aplf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
(rc more data)←∆MyGitHubAPI.GetAllTopics'TestRepo'
77
→T.PassesIf 0=rc
8-
→T.PassesIf 0=≢more
8+
→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)
99
→T.PassesIf 0<≢data
1010

1111
:If 0

APLSource/TestCases/Test_ZZZ_998.aplf

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
R←Test_ZZZ_998(stopFlag batchFlag);⎕IO;⎕ML;⎕TRAP;report;buff;xml;source
1+
R←Test_ZZZ_998(stopFlag batchFlag);⎕IO;⎕ML;⎕TRAP;report;buff;rf
22
⍝ Checks on two text vectors: "⍝TODO⍝" and "⍝CHECK⍝"; never fails, just reports.
3-
⎕IO←0 ⋄ ⎕ML←3
3+
⎕IO←1 ⋄ ⎕ML←1
44
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
55
R←T._OK
66
report←''
7+
rf←##.GitHubAPIv3
78

8-
xml←⎕XML'flat'##.APLTreeUtils.ReadUtf8File'publish.config'
9-
source←2⊃xml[xml[;1]⍳⊂'container';]
10-
buff←T.FindSpecialString'⍝CHECK⍝'
11-
buff←(buff[;0]≢¨⎕XSI[0])⌿buff ⍝ remove caller
12-
:If ~0∊⍴buff
9+
buff←rf T.FindSpecialString'⍝CHECK⍝'
10+
buff←(buff[;1]≢¨⎕XSI[1])⌿buff ⍝ remove caller
11+
:If 0≠≢buff
1312
report,←↓(⊂' ⍝CHECK⍝ found:'),(⊂' '),¨buff
1413
:EndIf
15-
buff←T.FindSpecialString'⍝TODO⍝'
16-
buff←(buff[;0]≢¨⎕XSI[0])⌿buff ⍝ remove caller
17-
:If ~0∊⍴buff
14+
buff←rf T.FindSpecialString'⍝TODO⍝'
15+
buff←(buff[;1]≢¨⎕XSI[1])⌿buff ⍝ remove caller
16+
:If 0≠≢buff
1817
report,←↓(⊂' ⍝TODO⍝ found:'),(⊂' '),¨buff
1918
:EndIf
20-
:If 1=⍴,report
19+
:If 1=report
2120
report,←⊂' Nothing found!'
2221
:Else
2322
⎕←'Checking for ⍝TODO⍝ and ⍝CHECK⍝ '{⍵↑,'--- ',⍺,' ',⍵⍴'-'}80⌊⎕PW-1

APLSource/TestCases/Test_ZZZ_999.aplf

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)