-
Notifications
You must be signed in to change notification settings - Fork 138
/
resolve_deprecated.nqp
executable file
·73 lines (53 loc) · 1.73 KB
/
resolve_deprecated.nqp
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
72
73
#! parrot-nqp
# Copyright (C) 2011, Parrot Foundation.
pir::load_bytecode("YAML/Tiny.pbc");
pir::load_bytecode("YAML/Dumper.pbc");
pir::load_bytecode("LWP/UserAgent.pbc");
pir::load_bytecode("nqp-setting.pbc");
pir::load_bytecode("dumper.pbc");
=begin NAME
resolve_deprecated.nqp - Resolve deprecated features
=end NAME
=begin SYNOPSIS
parrot-nqp tools/dev/resolve_deprecated.nqp
=end SYNOPSIS
=begin DESCRIPTION
Resolve all freshly deprecated features listed in api.yaml by quering trac for
status of ticket.
=end DESCRIPTION
=begin COMPLICATIONS
YAML::Dumper produce way too complex YAML. We should extend YAML::Tiny to
produce simplified version.
=end COMPLICATIONS
say("Parsing");
my @yaml := YAML::Tiny.new.read_string(slurp('api.yaml'))[0];
my $ua := pir::new(LWP::UserAgent);
say("Processing");
for @yaml -> %e {
# Skip items without ticket
my $ticket := %e<ticket>;
next unless $ticket;
# Skip already marked items
next if any(-> $_ { $_ eq 'completed' }, %e<tags>);
say("Checking $ticket");
# Request non-https version due limitation of LWP.
my $response := $ua.get(subst($ticket ~ '?format=tab', /^https/, 'http')).content;
#_dumper(['response', $response]);
# cheat. split doesn't split properly on multiple tabs. So just check \tclosed\t
my $/ := $response ~~ /\t ( "closed" ) \t/;
next unless $/[0] eq 'closed';
say("Ticket $ticket is closed and can be marked as 'completed'");
%e<tags>.push('completed');
}
say("Done");
spew("api.yaml", YAML::Tiny.new.write_string(@yaml));
sub any(&code, @list) {
return 1 if &code($_) for @list;
0;
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=perl6: