Created
April 23, 2017 21:49
-
-
Save samcv/2c87aec0c687c3224531d4e994cd27c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
use JSON::Fast; | |
use v6.d.PREVIEW; | |
# Gets the distribution of tag usage and the usage of license tags | |
sub get-distribution { | |
my $lock = Lock.new; | |
my @list; | |
note "getting list"; | |
my $list = qx{curl -s 'https://raw.githubusercontent.com/perl6/ecosystem/master/META.list'}; | |
note "got list"; | |
await do for $list.lines -> $url { | |
start { | |
#say $url; | |
my $proc = run 'curl', '-s', $url, :out; | |
my Str $out = $proc.out.slurp; | |
my $result; | |
try { | |
$result = from-json($out); | |
}; | |
#say $result; | |
$lock.protect({ | |
@list.append($result.keys); | |
#say @list; | |
}) if $proc.exitcode == 0 and $result; | |
$*ERR.print: '.'; | |
} | |
} | |
$*ERR.print: "\n"; | |
my $bag = Bag(@list); | |
say ($bag<license> / $bag<name>) * 100 ~ '% of all modules have license fields'; | |
say "{$bag<name>} modules {$bag<license>} have license metadata"; | |
say $bag.sort(-*.value.Int); | |
} | |
get-distribution; | |
# Gets which modules have noncompliant fields in the META files | |
# uses ecosystem api thing which updates probably every 15 mins | |
sub get-noncompliant { | |
use JSON::Fast; my $json = from-json(qx{curl -s 'http://ecosystem-api.p6c.org/projects.json'}); | |
my $elems = $json.elems; | |
my @ok = <license depends emulates authors description perl name | |
test-depends resources support source-url auth version tags production | |
provides supersedes superseded-by excludes build-depends meta6 | |
>; | |
for ^$elems -> $elem { | |
unless all($json[$elem].keys) eq any(@ok) { | |
say $json[$elem]<name>; | |
say $json[$elem].keys; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment