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