DRI/Transport/Defer.pm

filter: Statementstmt 34.0% 16 / 47 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod 33.3% 1 / 3 totaltotal 30.9% 22 / 71 CC 6 SCAR 30.0
CC
6
Cov
28%
new
42.0
ping
2.0
send
2.0
CRAP 20.1
« DRI/Protocol/Whois/Domain/SE.pm ↑ Summary DRI/Protocol/EPP/Extensions/AusRegistry/Variant.pm »
1 ## Domain Registry Interface, Deferred Transport
2 ##
3 ## Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Transport::Defer;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use base qw(Net::DRI::Transport);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =pod
26  
27 =head1 NAME
28  
29 Net::DRI::Transport::Defer - Deferred Transport for Net::DRI
30  
31 =head1 DESCRIPTION
32  
33 This module implements a deferred transport in Net::DRI. For now it just dumps all data
34 to a given filehandle, and reports back to Net::DRI that the message has been sent.
35  
36 This is useful for debugging, and also to validate all parameters of an operation without
37 actually sending anything to the registry ; in such way, it is kind of a "simulate" operation
38 where everything is done (parameters validation, message building, etc...) without touching
39 the registry.
40  
41 =head1 METHODS
42  
43 At creation (see Net::DRI C<new_profile>) you pass a reference to an hash, with the following available keys:
44  
45 =head2 protocol_connection
46  
47 Net::DRI class handling protocol connection details. (Ex: C<Net::DRI::Protocol::RRP::Connection> or C<Net::DRI::Protocol::EPP::Connection>)
48  
49 =head2 dump_fh (optional)
50  
51 a filehandle (ex: \*STDERR or an anonymous filehandle) on something already opened for write ;
52 if not defined, defaults to \*STDERR
53  
54 =head1 SUPPORT
55  
56 For now, support questions should be sent to:
57  
58 E<lt>netdri@dotandco.comE<gt>
59  
60 Please also see the SUPPORT file in the distribution.
61  
62 =head1 SEE ALSO
63  
64 http://www.dotandco.com/services/software/Net-DRI/
65  
66 =head1 AUTHOR
67  
68 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
69  
70 =head1 COPYRIGHT
71  
72 Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>.
73 All rights reserved.
74  
75 This program is free software; you can redistribute it and/or modify
76 it under the terms of the GNU General Public License as published by
77 the Free Software Foundation; either version 2 of the License, or
78 (at your option) any later version.
79  
80 See the LICENSE file that comes with this distribution for more details.
81  
82 =cut
83  
84 ####################################################################################################
85  
86 sub new
87 {
88 0 ▶ my ($class,$ctx,$rp)=@_;
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
89 0 my %opts=%$rp;
90  
91 0 my %t=();
92 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('protocol_connection') unless (exists($opts{protocol_connection}) && $opts{protocol_connection});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"protocol_connection"} and $opts{"protocol_connection"} 0 0 0
Condition0%0/3
exists $opts{"protocol_connection"} and $opts{"protocol_connection"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opts{"protocol_connection"} and $opts{"protocol_connection"}
exists $opts{"protocol_connection"} $opts{"protocol_connection"}
Truth table0%0/3
A and B
A= exists $opts{"protocol_connection"}B= $opts{"protocol_connection"}
ABresult
0X0
100
111
93 0 $t{pc}=$opts{protocol_connection};
94 0 Net::DRI::Util::load_module($t{pc},'transport/defer');
95 0 ▶ if ($t{pc}->can('transport_default'))
Branch: 1 branch
BranchTrueFalseTotal
if ($t{"pc"}->can("transport_default")) 0 0 0
96 {
97 0 %opts=($t{pc}->transport_default('defer'),%opts);
98 }
99  
100 0 my $self=$class->SUPER::new($ctx,\%opts);
101 0 $self->name('defer');
102 0 $self->version('0.1');
103 0 $self->has_state(0);
104 0 $self->is_sync(0);
105 0 $self->defer(0);
106 0 $self->current_state(0);
107 0 $self->time_open(time());
108 0 $self->time_used(time());
109  
110 0 $t{exchanges_done}=0;
111 0 ▶ $t{dump_fh}=(exists($opts{dump_fh}))? $opts{dump_fh} : \*STDERR;
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'dump_fh'} ? : 0 0 0
112  
113 0 my @need=qw/read_data write_message/;
114 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('protocol_connection class ('.$t{pc}.') must have: '.join(' ',@need)) if (grep { ! $t{pc}->can($_) } @need);
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $t{"pc"}->can($_);} @need 0 0 0
115  
116 0 $self->{transport}=\%t;
117 0 return $self;
118 }
119  
120 0 ▶sub ping { return 1; }
Subroutine ping: not called CC=1 SCAR=6.9
Pod undocumented
121  
122 sub send ## no critic (Subroutines::ProhibitBuiltinHomonyms)
123 {
124 0 ▶ my ($self,$ctx,$tosend)=@_;
Subroutine send: not called CC=1 SCAR=6.9
Pod undocumented
125 0 my $t=$self->transport_data();
126 0 my $pc=$t->{pc};
127  
128 0 print { $t->{dump_fh} } "\n",$pc->write_message($self,$tosend),"\n";
129 0 return 1;
130 }
131  
132 ####################################################################################################
133 1 1;
« DRI/Protocol/Whois/Domain/SE.pm ↑ Summary DRI/Protocol/EPP/Extensions/AusRegistry/Variant.pm »