DNSMadeEasy/ManagedDomain/Record.pm

filter: Statementstmt 33.8% 23 / 68 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 28.1% 9 / 32 Podpod 92.5% 25 / 27 totaltotal 40.4% 57 / 141 CC 8 SCAR 24.6
CC
8
Cov
29%
update
56.0
create_monitor
6.0
description
2.0
CRAP 11.7
↑ Summary DNSMadeEasy/Monitor.pm »
1 package WWW::DNSMadeEasy::ManagedDomain::Record;
2 8 our $VERSION = '0.100';
3 8 our $AUTHORITY = 'cpan:GETTY';
4 # ABSTRACT: A managed domain record in the DNSMadeEasy API
5  
6 8 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use String::CamelSnakeKebab qw/lower_camel_case/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use WWW::DNSMadeEasy::Monitor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 has domain => (is => 'ro', required => 1, handles => {path => 'records_path'});
11 8 has dme => (is => 'lazy', handles => ['request']);
12 8 has as_hashref => (is => 'rw', builder => 1, lazy => 1, clearer => 1);
13 8 has response => (is => 'rw');
14  
15 1 ▶sub _build_dme { shift->domain->dme }
Subroutine _build_dme: called CC=1 SCAR=0.0
16 1 ▶sub _build_as_hashref { shift->response->as_hashref }
Subroutine _build_as_hashref: called CC=1 SCAR=0.0
17  
18 0 ▶sub description { shift->as_hashref->{description} }
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
19 0 ▶sub dynamic_dns { shift->as_hashref->{dynamicDns} }
Subroutine dynamic_dns: not called CC=1 SCAR=6.9
Pod documented
20 0 ▶sub failed { shift->as_hashref->{failed} }
Subroutine failed: not called CC=1 SCAR=6.9
Pod documented
21 0 ▶sub failover { shift->as_hashref->{failover} }
Subroutine failover: not called CC=1 SCAR=6.9
Pod documented
22 0 ▶sub gtd_location { shift->as_hashref->{gtdLocation} }
Subroutine gtd_location: not called CC=1 SCAR=6.9
Pod documented
23 0 ▶sub hard_link { shift->as_hashref->{hardLink} }
Subroutine hard_link: not called CC=1 SCAR=6.9
Pod documented
24 4 ▶sub id { shift->as_hashref->{id} }
Subroutine id: called CC=1 SCAR=0.0
Pod documented
25 0 ▶sub keywords { shift->as_hashref->{keywords} }
Subroutine keywords: not called CC=1 SCAR=6.9
Pod documented
26 0 ▶sub monitor { shift->as_hashref->{monitor} }
Subroutine monitor: not called CC=1 SCAR=6.9
Pod documented
27 0 ▶sub mxLevel { shift->as_hashref->{mxLevel} }
Subroutine mxLevel: not called CC=1 SCAR=6.9
Pod documented
28 3 ▶sub name { shift->as_hashref->{name} }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
29 0 ▶sub password { shift->as_hashref->{password} }
Subroutine password: not called CC=1 SCAR=6.9
Pod documented
30 0 ▶sub port { shift->as_hashref->{port} }
Subroutine port: not called CC=1 SCAR=6.9
Pod documented
31 0 ▶sub priority { shift->as_hashref->{priority} }
Subroutine priority: not called CC=1 SCAR=6.9
Pod documented
32 0 ▶sub redirect_type { shift->as_hashref->{redirectType} }
Subroutine redirect_type: not called CC=1 SCAR=6.9
Pod documented
33 0 ▶sub source { shift->as_hashref->{source} }
Subroutine source: not called CC=1 SCAR=6.9
Pod documented
34 0 ▶sub source_id { shift->as_hashref->{source_id} }
Subroutine source_id: not called CC=1 SCAR=6.9
Pod documented
35 0 ▶sub title { shift->as_hashref->{title} }
Subroutine title: not called CC=1 SCAR=6.9
Pod documented
36 0 ▶sub ttl { shift->as_hashref->{ttl} }
Subroutine ttl: not called CC=1 SCAR=6.9
Pod documented
37 3 ▶sub type { shift->as_hashref->{type} }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
38 0 ▶sub value { shift->as_hashref->{value} }
Subroutine value: not called CC=1 SCAR=6.9
Pod documented
39 0 ▶sub weight { shift->as_hashref->{weight} }
Subroutine weight: not called CC=1 SCAR=6.9
Pod documented
40  
41 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
42 1 my ($self) = @_;
43 1 $self->request('DELETE', $self->path . $self->id);
44 }
45  
46 0 ▶sub update {
Subroutine update: not called CC=7 SCAR=40.3
Pod documented
47 0 my ($self, %data) = @_;
48  
49 0 my %req;
50 0 for my $old (keys %data) {
51 0 my $new = lower_camel_case($old);
52 0 $req{$new} = $data{$old};
53 }
54  
55 0 ▶ $req{id} //= $self->id;
Condition0%0/3
$req{"id"} //= $self->id
l!l&&r!l&&!r
000
MC/DC0%0/2
$req{"id"} //= $self->id
$req{"id"} $self->id
Truth table0%0/3
A //= B
A= $req{"id"}B= $self->id
ABresult
1X1
011
000
56 0 ▶ $req{name} //= $self->name;
Condition0%0/3
$req{"name"} //= $self->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$req{"name"} //= $self->name
$req{"name"} $self->name
Truth table0%0/3
A //= B
A= $req{"name"}B= $self->name
ABresult
1X1
011
000
57  
58 0 my $id = $self->id;
59 0 my $type = $self->type;
60 0 my $name = $self->name;
61 0 $self->clear_as_hashref;
62 0 $self->request(PUT => $self->path . $id, \%req);
63  
64 # GRR DME doesn't return the updasted record and there is no way to get a
65 # single record by id
66 0 ▶ $name = $req{name} if $req{name};
Branch: 1 branch
BranchTrueFalseTotal
if $req{"name"} 0 0 0
67 0 my @records = $self->domain->records(type => $type, name => $name);
68 0 for my $record (@records) {
69 0 ▶ next unless $record->id eq $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->id eq $id 0 0 0
70 0 $self->as_hashref($record->as_hashref);
71 }
72 }
73  
74 0 ▶sub monitor_path { 'monitor/' . shift->id }
Subroutine monitor_path: not called CC=1 SCAR=6.9
Pod undocumented
75  
76 0 ▶sub get_monitor {
Subroutine get_monitor: not called CC=1 SCAR=6.9
Pod documented
77 0 my ($self) = @_;
78 0 return WWW::DNSMadeEasy::Monitor->new(
79 response => $self->request(GET => $self->monitor_path),
80 dme => $self->dme,
81 record => $self,
82 );
83 }
84  
85 0 ▶sub create_monitor {
Subroutine create_monitor: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my ($self, %data) = @_;
87  
88 0 my %req;
89 0 for my $old (keys %data) {
90 0 my $new = lower_camel_case($old);
91 0 $req{$new} = $data{$old};
92 }
93  
94 0 my $monitor = WWW::DNSMadeEasy::Monitor->new(
95 response => $self->request(PUT => $self->monitor_path, \%req),
96 dme => $self->dme,
97 record => $self,
98 );
99 }
100  
101 8 1;
102  
103 __END__
↑ Summary DNSMadeEasy/Monitor.pm »