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