RabbitFoot/Cmd/Command/declare_exchange.pm

filter: Statementstmt 57.5% 19 / 33 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 37.5% 3 / 8 Podpod 100% 1 / 1 totaltotal 50.0% 23 / 46 CC 3 SCAR 11.9
CC
3
Cov
51%
_validate_exchange
6.0
_validate_type
6.0
abstract
2.0
CRAP 3.3
« RabbitFoot/Cmd/Command/declare_queue.pm ↑ Summary RabbitFoot/Channel.pm »
1 package Net::RabbitFoot::Cmd::Command::declare_exchange;
2  
3 1 ▶use List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 extends qw(MooseX::App::Cmd::Command);
7 1 with qw(Net::RabbitFoot::Cmd::Role::Config Net::RabbitFoot::Cmd::Role::Command);
8  
9 1 has exchange => (
10 isa => 'Str',
11 is => 'rw',
12 default => '',
13 metaclass => 'MooseX::Getopt::Meta::Attribute',
14 cmd_aliases => 'e',
15 documentation => 'exchange name',
16 );
17  
18 1 has type => (
19 isa => 'Str',
20 is => 'rw',
21 default => 'direct',
22 metaclass => 'MooseX::Getopt::Meta::Attribute',
23 cmd_aliases => 't',
24 documentation => 'exchange type [direct|topic|fanout|headers]',
25 );
26  
27 1 has passive => (
28 isa => 'Bool',
29 is => 'rw',
30 default => 0,
31 metaclass => 'MooseX::Getopt::Meta::Attribute',
32 # cmd_aliases => 'p',
33 documentation => 'do not create exchange',
34 );
35  
36 1 has durable => (
37 isa => 'Bool',
38 is => 'rw',
39 default => 0,
40 metaclass => 'MooseX::Getopt::Meta::Attribute',
41 cmd_aliases => 'd',
42 documentation => 'request a durable exchange',
43 );
44  
45 1 has auto_delete => (
46 isa => 'Bool',
47 is => 'rw',
48 default => 0,
49 metaclass => 'MooseX::Getopt::Meta::Attribute',
50 cmd_aliases => 'a',
51 documentation => 'auto delete exchange when unused',
52 );
53  
54 1 has internal => (
55 isa => 'Bool',
56 is => 'rw',
57 default => 0,
58 metaclass => 'MooseX::Getopt::Meta::Attribute',
59 cmd_aliases => 'i',
60 documentation => 'create internal exchange',
61 );
62  
63 1 __PACKAGE__->meta->make_immutable;
64 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 0 ▶sub abstract {
Subroutine abstract: not called CC=1 SCAR=6.9
Pod documented
67 0 return 'declare exchange, create if needed';
68 }
69  
70 0 ▶sub _validate_exchange {
Subroutine _validate_exchange: not called CC=2 SCAR=17.9
71 0 my ($self,) = @_;
72  
73 0 ▶ return if !$self->exchange;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exchange 0 0 0
74 0 $self->_check_shortstr('exchange');
75 0 return;
76 }
77  
78 0 ▶sub _validate_type {
Subroutine _validate_type: not called CC=2 SCAR=17.9
79 0 my ($self,) = @_;
80  
81 die 'type', "\n"
82 0 ▶ if none {$_ eq $self->type} qw(direct topic fanout headers);
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if &none(sub { $_ eq $self->type; } , "direct", "topic", "fanout", "headers") 0 0 0
83 0 return;
84 }
85  
86 0 ▶sub _run {
Subroutine _run: not called CC=1 SCAR=6.9
87 0 my ($self, $client, $opt, $args,) = @_;
88  
89 my $method_frame = $client->declare_exchange(
90 0 (map {$_ => $self->$_} qw(exchange type passive durable auto_delete internal))
91 )->method_frame;
92  
93 0 print 'Declared exchange', "\n";
94 0 return;
95 }
96  
97 1 1;
98  
« RabbitFoot/Cmd/Command/declare_queue.pm ↑ Summary RabbitFoot/Channel.pm »