line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
13
|
use v5.14.0; |
|
1
|
|
|
|
|
4
|
|
2
|
|
|
|
|
|
|
package JMAP::Tester::SentenceBroker 0.103; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
with 'JMAP::Tester::Role::SentenceBroker'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
338
|
use Data::OptList (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
5
|
use JMAP::Tester::Abort; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
220
|
use JMAP::Tester::Response::Sentence; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
10
|
1
|
|
|
1
|
|
5
|
use JMAP::Tester::Response::Paragraph; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
546
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has response => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
weak_ref => 1, |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub client_ids_for_items { |
19
|
14
|
|
|
14
|
0
|
1698
|
map {; $_->[2] } @{ $_[1] } |
|
20
|
|
|
|
|
73
|
|
|
14
|
|
|
|
|
43
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub sentence_for_item { |
23
|
86
|
|
|
86
|
0
|
637
|
my ($self, $item) = @_; |
24
|
|
|
|
|
|
|
|
25
|
86
|
|
|
|
|
1627
|
return JMAP::Tester::Response::Sentence->new({ |
26
|
|
|
|
|
|
|
name => $item->[0], |
27
|
|
|
|
|
|
|
arguments => $item->[1], |
28
|
|
|
|
|
|
|
client_id => $item->[2], |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sentence_broker => $self, |
31
|
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub paragraph_for_items { |
35
|
14
|
|
|
14
|
0
|
159
|
my ($self, $items) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return JMAP::Tester::Response::Paragraph->new({ |
38
|
14
|
|
|
|
|
34
|
sentences => [ map {; $self->sentence_for_item($_) } @$items ], |
|
24
|
|
|
|
|
320
|
|
39
|
|
|
|
|
|
|
}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub abort { |
43
|
12
|
|
|
12
|
0
|
106
|
my ($self, $string, $diag_spec) = @_; |
44
|
|
|
|
|
|
|
|
45
|
12
|
|
100
|
11
|
|
109
|
$diag_spec //= [ 'Response sentences', sub { [ $_[0]->items ] } ]; |
|
11
|
|
|
|
|
34
|
|
46
|
|
|
|
|
|
|
|
47
|
12
|
|
|
|
|
23
|
my @diagnostics; |
48
|
|
|
|
|
|
|
|
49
|
12
|
50
|
|
|
|
38
|
if ($diag_spec) { |
50
|
12
|
|
|
|
|
71
|
my $todo = Data::OptList::mkopt($diag_spec); |
51
|
|
|
|
|
|
|
|
52
|
12
|
|
|
|
|
536
|
PAIR: for my $pair (@$todo) { |
53
|
13
|
|
|
|
|
38
|
my ($label, $value) = @$pair; |
54
|
|
|
|
|
|
|
|
55
|
13
|
100
|
|
|
|
32
|
if (not defined $value) { |
56
|
2
|
|
|
|
|
6
|
push @diagnostics, "$label\n"; |
57
|
2
|
|
|
|
|
6
|
next PAIR; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
11
|
50
|
|
|
|
38
|
if (ref $value) { |
61
|
11
|
50
|
|
|
|
28
|
if (ref $value eq 'CODE') { |
62
|
11
|
|
|
|
|
40
|
$value = $value->($self->response); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
11
|
|
|
|
|
48
|
$value = $self->response->dump_diagnostic($value); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
11
|
|
|
|
|
707
|
push @diagnostics, "$label: $value"; |
69
|
11
|
50
|
|
|
|
84
|
$diagnostics[-1] .= "\n" unless $value =~ /\n\z/; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
12
|
50
|
|
|
|
304
|
die JMAP::Tester::Abort->new({ |
74
|
|
|
|
|
|
|
message => $string, |
75
|
|
|
|
|
|
|
(@diagnostics ? (diagnostics => \@diagnostics) : ()), |
76
|
|
|
|
|
|
|
}); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub strip_json_types { |
80
|
10
|
|
|
10
|
0
|
41
|
state $typist = JSON::Typist->new; |
81
|
10
|
|
|
|
|
115
|
$typist->strip_types($_[1]); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
1
|
|
7
|
no Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |