|
1 | | -# GitHubAPI |
| 1 | +# GitHubAPIv3 |
2 | 2 |
|
| 3 | +## Dependencies |
| 4 | + |
| 5 | +Like most classes of the APLTree library GitHubAPIv3 depends on APLTreeUtils to be around. That namespace script is `:INCLUDE`d. |
| 6 | + |
| 7 | +## Experimental |
| 8 | + |
| 9 | +As long as the version number of GitHubAPIv3 starts with a 0 it is experimental. However, you can be sure that the code is stable and test cases exist and pass though the design might still change. |
| 10 | + |
| 11 | +## Overview |
3 | 12 |
|
4 | 13 | This class offers methods useful to communicate with GitHub's API version 3 from Dyalog APL. |
5 | 14 |
|
6 | | -Note that version 3 is the last version of that API that uses REST. See `GitHubGraphQL` for using a later version of the API. |
| 15 | +Note that version 3 is the last version of that API that uses REST. See `GitHubAPIGraphQL` for using a later version of the API. |
| 16 | + |
| 17 | +So far this class comes with a selection of methods useful to collect information about repositories and releases. In particular these methods allow you to check whether a better version of a program is available, and to download it if you wish so. |
| 18 | + |
| 19 | +Those methods require GitHubAPIv3 to be instanciated. That might seem like overkill because right now there is only one constructor requiring the owner's name, but with the implementation of OAuth that will change. |
| 20 | + |
| 21 | +In addition there is one shared method: `CastTagname2Number`; it takes a tag name and returns a number from it by making certain assumptions. This is useful for version comparison. |
| 22 | + |
| 23 | +See `]adoc GitHubAPIv3` for details from within Dyalog. |
| 24 | + |
| 25 | +## Usage example |
| 26 | + |
| 27 | +The following code shows how to use the GitHubAPIv3 class: |
| 28 | + |
| 29 | +``` |
| 30 | +OnCheckForUpdates←{ |
| 31 | + G←#.GitHubAPIv3 |
| 32 | + myGitAPI←⎕NEW G(,⊂'aplteam') |
| 33 | + (rc more ns)←myGitAPI.GetLatestRelease'Meddy' |
| 34 | + 0≠rc:0⊣TellErrorWhileCheckingForBetterVersion more |
| 35 | + gitVersion←G.CastTagname2Number ns.tag_name |
| 36 | + gitVersion≤⌊G.CastTagname2Number 1⊃Version:0⊣TellIsUp2Date ⍬ |
| 37 | + msg←⊂'There is a better version available on GitHub: ',1↓ns.tag_name |
| 38 | + msg,←'' 'Would you like to download the new version?' |
| 39 | + 0=#.Dialogs.YesOrNo msg:0 |
| 40 | + 0⊣#.APLTreeUtils.GoToWebPage ns.zipball_url |
| 41 | + } |
| 42 | +``` |
| 43 | + |
| 44 | +## Versioning |
| 45 | + |
| 46 | +`CastTagname2Number` assumes something like `v1.2.3` or `v1.2.3.4`. |
| 47 | + |
| 48 | +Some examples: |
7 | 49 |
|
8 | | -This class does not implement all the API calls available, it rather offers one basic method (`GetJson`, used by all other methods) and a number of methods serving special needs. |
| 50 | +``` |
| 51 | + 102003 ←→ G.CastTagname2Number 'v1.2.3' |
| 52 | +1202003 ←→ G.CastTagname2Number 'v12.2.3' |
| 53 | + 102003.00004 ←→ G.CastTagname2Number 'v1.2.3.4' |
| 54 | +1202003.00004 ←→ G.CastTagname2Number 'v12.2.3.4' |
| 55 | +``` |
9 | 56 |
|
10 | | -In addition the is one method (`CastTagname2Number`) that takes a tag name and returns a number from it by making certain assumptions. |
| 57 | +Maxima are `99.99.999.99999`. |
0 commit comments