Subscriber/Config.pm

filter: Statementstmt 100% 31 / 31 Branchbran 92.8% 13 / 14 Conditioncond 100% 7 / 7 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 5 / 5 totaltotal 98.5% 68 / 69 CC 11 SCAR 19.6
CC
11
Cov
98%
new
11.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.1
« Subscriber.pm ↑ Summary Subscriber/Client.pm »
1 package Plack::App::PubSubHubbub::Subscriber::Config;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Plack::App::PubSubHubbub::Subscriber::Config
10  
11 =head1 SYNOPSIS
12  
13 Plack::App::PubSubHubbub::Subscriber::Config->new(
14 callback => 'http://example.org/callback',
15 verify => 'sync',
16 lease_seconds => 86400,
17 token_in_path => 1,
18 );
19  
20 =head1 DESCRIPTION
21  
22 =head2 $class->new( %args )
23  
24 =over 4
25  
26 =item * C<callback> is required, must be 'http', must not contain fragment.
27  
28 =item * C<verify> can be 'sync' or 'async', and defaults to 'sync'.
29  
30 =item * C<lease_seconds> defaults to undef.
31  
32 =item * C<token_in_path> defaults to 1. This puts the token in the callback URL path, and does not use the hub.verify_token argument of the query string. The main benefit is that the token also known when a ping is received.
33  
34 =cut
35  
36 9 ▶sub new {
Subroutine new: called CC=11 SCAR=24.0
Pod documented
37 9 my $class = shift;
38 9 my %args = @_;
39 9 my $self = bless {}, $class;
40  
41 9 ▶ my $verify = $args{verify} || 'sync';
Condition100%2/2
$args{'verify'} || 'sync'
l!l
36
MC/DC100%1/1
$args{'verify'} || 'sync'
$args{'verify'}
Truth table100%2/2
A
A= $args{'verify'}
Aresult
11
00
42 9 ▶ die "verify must be 'sync' or 'async'"
Branch: 1 branch
BranchTrueFalseTotal
unless $verify eq "sync" or $verify eq "async" 1 8 9
Condition100%3/3
$verify eq "sync" or $verify eq "async"
l!l&&r!l&&!r
711
MC/DC100%2/2
$verify eq "sync" or $verify eq "async"
$verify eq "sync" $verify eq "async"
Truth table100%3/3
A or B
A= $verify eq "sync"B= $verify eq "async"
ABresult
1X1
011
000
43 unless $verify eq 'sync' || $verify eq 'async';
44 8 $self->{verify} = $verify;
45  
46 my $cb = $args{callback}
47 8 ▶ or die "'callback' required";
Branch: 1 branch
BranchTrueFalseTotal
my $cb = $args{"callback"} or die "'callback' required" 7 1 8
48 7 ▶ my $uri = URI->new($cb)
Branch: 1 branch
BranchTrueFalseTotal
my $uri = "URI"->new($cb) or die "invalid callback" 7 0 7
49 or die "invalid callback";
50 7 ▶ die "support only http"
Branch: 1 branch
BranchTrueFalseTotal
unless $uri->scheme eq "http" 1 6 7
51 unless $uri->scheme eq 'http';
52 6 ▶ die "fragment is not accepted in the callback"
Branch: 1 branch
BranchTrueFalseTotal
if $uri->fragment 1 5 6
53 if $uri->fragment;
54 5 $self->{callback} = $cb;
55  
56 5 my $lease = $args{lease_seconds};
57 5 ▶ if (defined $lease) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lease) 2 3 5
58 2 ▶ die "invalid number of seconds"
Branch: 1 branch
BranchTrueFalseTotal
unless $lease >= 0 1 1 2
59 unless $lease >= 0;
60 }
61 4 $self->{lease_seconds} = $lease;
62  
63 4 ▶ $self->{token_in_path} = $args{token_in_path} // 1;
Condition100%2/2
$args{"token_in_path"} // 1
l!l
13
MC/DC100%1/1
$args{"token_in_path"} // 1
$args{"token_in_path"}
Truth table100%2/2
A
A= $args{"token_in_path"}
Aresult
11
00
64  
65 4 return $self;
66 }
67  
68 9 ▶sub callback { $_[0]->{callback} }
Subroutine callback: called CC=1 SCAR=0.0
Pod documented
69  
70 5 ▶sub verify { $_[0]->{verify} }
Subroutine verify: called CC=1 SCAR=0.0
Pod documented
71  
72 5 ▶sub lease_seconds { $_[0]->{lease_seconds} }
Subroutine lease_seconds: called CC=1 SCAR=0.0
Pod documented
73  
74 6 ▶sub token_in_path { $_[0]->{token_in_path} }
Subroutine token_in_path: called CC=1 SCAR=0.0
Pod documented
75  
76 4 1;
« Subscriber.pm ↑ Summary Subscriber/Client.pm »