Fritz/Action.pm

filter: Statementstmt 100% 46 / 46 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 50.0% 1 / 2 totaltotal 98.4% 63 / 64 CC 7 SCAR 7.6
CC
7
Cov
100%
_build_args_in
3.0
_build_args_out
3.0
BUILDARGS
2.0
CRAP 2.1
« Fritz/Device.pm ↑ Summary Fritz/Data.pm »
1 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 # Copyright (C) 2015 Christian Garbs <mitch@cgarbs.de>
4 # Licensed under GNU GPL v2 or later.
5  
6 package Net::Fritz::Action;
7 # ABSTRACT: represents a TR064 action
8 6 $Net::Fritz::Action::VERSION = 'v0.0.2';
9  
10 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 with 'Net::Fritz::IsNoError';
13  
14  
15 6 has xmltree => ( is => 'ro' );
16  
17
18 6 has name => ( is => 'lazy', init_arg => undef );
19  
20 sub _build_name {
21 4 ▶ my $self = shift;
Subroutine _build_name: called CC=1 SCAR=0.0
22 4 return $self->xmltree->{name}->[0];
23 }
24  
25  
26 6 has args_in => ( is => 'lazy', init_arg => undef );
27  
28 sub _build_args_in {
29 14 ▶ my $self = shift;
Subroutine _build_args_in: called CC=3 SCAR=11.0
30 14 my @args;
31  
32 # TODO convert to grep
33 14 foreach my $arg (@{$self->xmltree->{argumentList}->[0]->{argument}}) {
34 31 ▶ if ($arg->{direction}->[0] eq 'in') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"direction"}[0] eq "in") 17 14 31
35 17 push @args, $arg->{name}->[0];
36 }
37 }
38  
39 14 return \@args;
40 }
41  
42  
43 6 has args_out => ( is => 'lazy', init_arg => undef );
44  
45 sub _build_args_out {
46 8 ▶ my $self = shift;
Subroutine _build_args_out: called CC=3 SCAR=11.0
47 8 my @args;
48  
49 # TODO convert to grep
50 8 foreach my $arg (@{$self->xmltree->{argumentList}->[0]->{argument}}) {
51 19 ▶ if ($arg->{direction}->[0] eq 'out') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"direction"}[0] eq "out") 8 11 19
52 8 push @args, $arg->{name}->[0];
53 }
54 }
55  
56 8 return \@args;
57 }
58  
59  
60 sub BUILDARGS {
61 22 ▶ my ( $class, @args ) = @_;
Subroutine BUILDARGS: called CC=2 SCAR=6.9
Pod undocumented
62  
63 22 ▶ unshift @args, "xmltree" if @args % 2 == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 == 1 1 21 22
64  
65 22 return { @args };
66 };
67  
68  
69 sub dump {
70 3 ▶ my $self = shift;
Subroutine dump: called CC=2 SCAR=6.9
Pod documented
71  
72 3 my $indent = shift;
73 3 ▶ $indent = '' unless defined $indent;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $indent 1 2 3
74  
75 3 my $text = "${indent}Net::Fritz::Action:\n";
76 3 $indent .= ' ';
77 3 $text .= "${indent}name = " . $self->name . "\n";
78 3 $text .= "${indent}args_in = " . join(', ', @{$self->args_in}) . "\n";
79 3 $text .= "${indent}args_out = " . join(', ', @{$self->args_out}) . "\n";
80  
81 3 return $text;
82 }
83  
84  
85 6 1;
86  
87 __END__
« Fritz/Device.pm ↑ Summary Fritz/Data.pm »