blib/lib/Net/DNS/Create/Tiny.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 93.7% 15 / 16 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 7 totaltotal 83.5% 66 / 79 SCAR 24.0
CC
11
Cov
95%
domain
10.1
import
2.0
master_list
2.0
CRAP 11.0
« blib/lib/Net/DNS/Create/Bind.pm ↑ Summary Build »
1 # Copyright (c) 2009-2014 David Caldwell, All Rights Reserved.
2  
3 package Net::DNS::Create::Tiny;
4 1 ▶use feature ':5.10';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Net::DNS::Create qw(internal full_host email interval);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Slurp qw(write_file);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our %config;
12 sub import {
13 1 ▶ my $package = shift;
Subroutine import: called CC=2 SCAR=6.9
14 1 my %c = @_;
15 1 $config{$_} = $c{$_} for keys %c;
16 }
17  
18 sub tiny_escape($) {
19 8 ▶ my ($f) = @_;
Subroutine tiny_escape: called CC=1 SCAR=0.0
Pod undocumented
20 8 $f =~ s/(:|\\|[^ -~])/sprintf "\\%03o", ord($1)/eg;
21 8 $f
22 }
23  
24 sub domainname_encode($;$) {
25 3 ▶ my ($node, $domain) = @_;
Subroutine domainname_encode: called CC=1 SCAR=0.0
Pod undocumented
26 3 $node = full_host($node, $domain);
27 3 join('', map { chr(length $_).$_ } split /\./, $node, -1);
28 }
29  
30 sub C(@) { # "Colon"
31 27 ▶ join(':', @_)
Subroutine C: called CC=1 SCAR=0.0
Pod undocumented
32 }
33  
34 1 my @domain;
35 sub domain($$) {
36 1 ▶ my ($package, $domain, $entries) = @_;
Subroutine domain: called CC=10 SCAR=23.1
Pod undocumented
37  
38 1 my @conf = map { ;
39 27 my $rr = lc $_->type;
40 27 my $fqdn = $_->name . '.';
41  
42 27 ▶ $rr eq 'a' ? '='.C($fqdn,$_->address,$_->ttl) :
Branch: 8 branches
BranchTrueFalseTotal
$rr eq 'a' ? : 11 16 27
$rr eq 'cname' ? : 3 13 16
$rr eq 'rp' ? : 1 12 13
$rr eq 'mx' ? : 2 10 12
$rr eq 'ns' ? : 2 8 10
$rr eq 'txt' ? : 6 2 8
$rr eq 'soa' ? : 1 1 2
$rr eq 'srv' ? : 1 0 1
Condition50%1/2
$_->serial || ''
l!l
10
MC/DC0%0/1
$_->serial || ''
$_->serial
Truth table50%1/2
A
A= $_->serial
Aresult
11
00
43 $rr eq 'cname' ? 'C'.C($fqdn,$_->cname.'.',$_->ttl) :
44 $rr eq 'rp' ? ':'.C($fqdn,17,tiny_escape(domainname_encode(email($_->mbox)).domainname_encode($_->txtdname)),$_->ttl) :
45 $rr eq 'mx' ? '@'.C($fqdn,'',$_->exchange.'.',$_->preference,'',$_->ttl) :
46 $rr eq 'ns' ? '&'.C($fqdn,'',$_->nsdname.'.',$_->ttl) :
47 $rr eq 'txt' ? "'".C($fqdn,tiny_escape(join('',$_->char_str_list)),$_->ttl) :
48 $rr eq 'soa' ? 'Z'.C($fqdn,
49 $_->mname.'.',
50 email($_->rname),
51 $_->serial || '',
52 $_->refresh, $_->retry, $_->expire, $_->minimum, $_->ttl) :
53 $rr eq 'srv' ? ':'.C($fqdn,33,tiny_escape(pack("nnn", $_->priority, $_->weight, $_->port)
54 .domainname_encode($_->target)),$_->ttl) :
55 die "Don't know how to handle \"$rr\" RRs yet.";
56  
57 } @$entries;
58  
59 push @domain, "# $domain\n" .
60 "#\n" .
61 1 join('', map { "$_\n" } @conf) .
62 "\n";
63 }
64  
65 sub master {
66 1 ▶ my ($package, $filename) = @_;
Subroutine master: called CC=1 SCAR=0.0
Pod undocumented
67 1 write_file($filename, @domain);
68 }
69  
70 ▶sub domain_list($@) {
Subroutine domain_list: not called CC=1 SCAR=0.0
Pod undocumented
71 # There are no separate zone files in a tiny setup.
72 }
73  
74 sub master_list($$) {
75 0 ▶ print "$_[0]\n"
Subroutine master_list: not called CC=1 SCAR=6.9
Pod undocumented
76 }
77  
78 1 1;
79 __END__
« blib/lib/Net/DNS/Create/Bind.pm ↑ Summary Build »