forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-langs
executable file
·71 lines (52 loc) · 1.6 KB
/
latest-langs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env perl6
use Cro::HTTP::Client;
constant @langs = (
'C',
'http://download.savannah.gnu.org/releases/tinycc/?C=M&O=D',
/ 'tcc-' (<[\d.]>+) '.tar.bz2' /,
'Go',
'https://golang.org/project/',
/ 'var goVersion = "go' (<[\d.]>+) '"' /,
'Haskell',
'https://www.haskell.org/ghc/download.html',
/ 'download_ghc' .+? ">" (<[\d.]>+) /,
'Julia',
'https://julialang.org/downloads/',
/ 'stable release: v' (<[\d.]>+) /,
'Lua',
'https://www.lua.org',
/ 'versions.html' .+? '>Lua ' (<[\d.]>+) /,
'Nim',
'https://nim-lang.org',
/ 'Version ' (<[\d.]>+) /,
'Perl',
'https://www.perl.org',
/ '"version-highlight">' (<[\d.]>+) /,
'PHP',
'https://www.php.net/downloads.php',
/ 'Stable</span>' \s* 'PHP ' (<[\d.]>+) /,
'Python',
'https://www.python.org',
/ 'Latest: <' .+? '>Python ' (<[\d.]>+) /,
'Ruby',
'https://www.ruby-lang.org/en/downloads/',
/ 'stable version is ' (<[\d.]>+) '.' /,
'Rust',
'https://www.rust-lang.org',
/ 'Version ' (<[\d.]>+) /,
'Swift',
'https://swift.org/download/',
/ 'Swift ' (<[\d.]>+) /,
);
constant $len = @langs[0, 3 … *]».chars.max;
my %current = (get('https://code-golf.io/about') ~~ m:g/
'<tr><th' .+? '>' (.+?) '<' .*? (<[\d.]> ** 2..*)
/)».list.flat».Str.Hash;
for @langs -> $lang, $url, $re {
my $ver = get($url) ~~ $re ?? ~$0 !! '';
printf " %*s %s\n", $len, $lang, $ver if $ver ne %current{$lang};
}
sub get ($url) {
state $client = Cro::HTTP::Client.new(:!follow :http<1.1>);
await (await $client.get($url)).body;
}