MtPolicyd/Client/App.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 1 totaltotal 45.4% 20 / 44 CC 4 SCAR 23.6
CC
4
Cov
45%
run
20.0
_dump
2.0
BEGIN
1.0
CRAP 10.6
« MtPolicyd/Plugin/DBL.pm ↑ Summary MtPolicyd/Plugin/Condition.pm »
1 package Mail::MtPolicyd::Client::App;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.11'; # VERSION
6 # ABSTRACT: application interface class for Mail::MtPolicyd::Client
7  
8  
9 1 extends 'Mail::MtPolicyd::Client';
10 1 with 'MooseX::Getopt';
11  
12 1 ▶use Mail::MtPolicyd::Client::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 has '+host' => (
16 traits => ['Getopt'],
17 cmd_aliases => "h",
18 documentation => "host:port of a policyd",
19 );
20  
21 1 has '+socket_path' => (
22 traits => ['Getopt'],
23 cmd_aliases => "s",
24 documentation => "path to a socket of a policyd",
25 );
26  
27  
28 1 has '+keepalive' => (
29 traits => ['Getopt'],
30 cmd_aliases => "k",
31 documentation => "use connection keepalive?",
32 );
33  
34 1 has 'verbose' => (
35 is => 'rw',
36 isa => 'Bool',
37 default => 0,
38 traits => ['Getopt'],
39 cmd_aliases => "v",
40 documentation => "be verbose, print input/output to STDERR",
41 );
42  
43 sub run {
44 0 ▶ my $self = shift;
Subroutine run: not called CC=4 SCAR=30.0
Pod undocumented
45 0 my $stdin = IO::Handle->new;
46 0 $stdin->fdopen(fileno(STDIN),"r");
47  
48 0 ▶ while( my $request = Mail::MtPolicyd::Client::Request->new_from_fh( $stdin ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $request = "Mail::MtPolicyd::Client::Request"->new_from_fh($stdin)) 0 0 0
49 0 ▶ if( $self->verbose ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose) 0 0 0
50 0 $self->_dump('>> ', $request->as_string);
51 }
52 0 my $response = $self->request( $request );
53 0 ▶ if( $self->verbose ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose) 0 0 0
54 0 $self->_dump('<< ', $response->as_string);
55 }
56 0 print $response->action."\n";
57 }
58 0 return;
59 }
60  
61 sub _dump {
62 0 ▶ my ( $self, $prefix, $message ) = @_;
Subroutine _dump: not called CC=1 SCAR=6.9
63 0 $message =~ s/^/$prefix/mg;
64 0 print STDERR $message;
65 0 return;
66 }
67  
68  
69 1 1;
70  
71  
72 __END__
73 =pod
74  
75 =head1 NAME
76  
77 Mail::MtPolicyd::Client::App - application interface class for Mail::MtPolicyd::Client
78  
79 =head1 VERSION
80  
81 version 1.11
82  
83 =head1 SYNOPSIS
84  
85 use Mail::MtPolicyd::Client::App;
86  
87 my $app = Mail::MtPolicyd::Client::App->new_with_options();
88 $app->run;
89  
90 =head1 DESCRIPTION
91  
92 This class provides a application interface for Mail::MtPolicyd::Client.
93  
94 =head1 SEE ALSO
95  
96 L<policyd-client>, L<Mail::MtPolicyd::Client>
97  
98 =head1 AUTHOR
99  
100 Markus Benning <ich@markusbenning.de>
101  
102 =head1 COPYRIGHT AND LICENSE
103  
104 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
105  
106 This is free software, licensed under:
107  
108 The GNU General Public License, Version 2, June 1991
109  
110 =cut
111  
« MtPolicyd/Plugin/DBL.pm ↑ Summary MtPolicyd/Plugin/Condition.pm »