MatrixTool/Command/client/sync.pm

filter: Statementstmt 65.7% 23 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 1 totaltotal 53.5% 30 / 56 CC 4 SCAR 14.4
CC
4
Cov
55%
__ANON__
12.0
__ANON__
6.0
run
2.0
CRAP 4.2
« MatrixTool/Command/directory.pm ↑ Summary MatrixTool/Command/resolve.pm »
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2016 -- leonerd@leonerd.org.uk
5  
6 package App::MatrixTool::Command::client::sync;
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use base qw( App::MatrixTool::Command::client );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '0.08';
13  
14 1 ▶use Future::Utils qw( repeat );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use constant DESCRIPTION => "Follow the /sync event stream";
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use constant ARGUMENTS => ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant OPTIONS => (
Subroutine BEGIN: called CC=1 SCAR=0.0
19 'i|initial' => "Print the initial sync result too",
20 1 );
21  
22 =head1 NAME
23  
24 matrixtool client sync - Follow the C</sync> event stream
25  
26 =head1 SYNOPSIS
27  
28 $ matrixtool client -u @me:example.com sync
29  
30 =head1 DESCRIPTION
31  
32 This command follows the event stream from the homeserver by making repeated
33 calls to the C</sync> API, printing the returned values.
34  
35 =head1 OPTIONS
36  
37 =over 4
38  
39 =item C<--initial>, C<-i>
40  
41 Include the initial C</sync> result in the output, as well as ongoing updates.
42  
43 =back
44  
45 =cut
46  
47 sub run
48 0 ▶{
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
49 0 my $self = shift;
50 0 my ( $opts ) = @_;
51  
52 0 my $token;
53  
54 0 ▶ repeat {
Subroutine __ANON__: not called CC=2 SCAR=17.9
55 $self->do_json( GET => "/_matrix/client/r0/sync",
56 params => {
57 timeout => 30*1000,
58 ( defined $token ) ? ( since => $token ) : (),
59 }
60 0 ▶ )->then( sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
61 0 my ( $body ) = @_;
62  
63 0 ▶ if( defined $token or $opts->{initial} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token or $opts->{"initial"}) 0 0 0
Condition0%0/3
defined $token or $opts->{"initial"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $token or $opts->{"initial"}
defined $token $opts->{"initial"}
Truth table0%0/3
A or B
A= defined $tokenB= $opts->{"initial"}
ABresult
1X1
011
000
64 0 print "---\n";
65 0 print $self->JSON_pretty->encode( $body );
66 }
67  
68 0 $token = $body->{next_batch};
69 0 Future->done;
70 0 ▶ });
Branch: 1 branch
BranchTrueFalseTotal
defined $token ? : 0 0 0
71 0 ▶ } while => sub { !$_[0]->failure };
Subroutine __ANON__: not called CC=1 SCAR=6.9
72 }
73  
74 =head1 AUTHOR
75  
76 Paul Evans <leonerd@leonerd.org.uk>
77  
78 =cut
79  
80 1 0x55AA;
« MatrixTool/Command/directory.pm ↑ Summary MatrixTool/Command/resolve.pm »