blib/lib/WWW/eNom/Role/ParseDomain.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 35 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/WWW/eNom/PrivateNameServer.pm ↑ Summary
1 package WWW::eNom::Role::ParseDomain;
2  
3 64 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 64 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 64 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 64 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 64 ▶use WWW::eNom::Types qw( Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 64 ▶use Mozilla::PublicSuffix;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 64 requires 'name';
14  
15 64 our $VERSION = 'v2.0.0'; # VERSION
16 # ABSTRACT: Parse a domain into sld and public_suffix/tld
17  
18 64 has 'sld' => (
19 is => 'ro',
20 isa => Str,
21 builder => '_build_sld',
22 lazy => 1,
23 init_arg => undef,
24 );
25  
26 64 has 'public_suffix' => (
27 is => 'ro',
28 isa => Str,
29 alias => 'tld',
30 builder => '_build_public_suffix',
31 lazy => 1,
32 init_arg => undef,
33 );
34  
35 sub _build_sld {
36 4 ▶ my $self = shift;
Subroutine _build_sld: called CC=1 SCAR=0.0
37  
38 4 return substr( $self->name, 0, length( $self->name ) - ( length( $self->public_suffix ) + 1 ) );
39 }
40  
41 sub _build_public_suffix {
42 6 ▶ my $self = shift;
Subroutine _build_public_suffix: called CC=1 SCAR=0.0
43  
44 6 return Mozilla::PublicSuffix::public_suffix( $self->name );
45 }
46  
47 64 1;
48  
49 __END__
50  
51 =pod
52  
53 =head1 NAME
54  
55 WWW::eNom::Role::ParseDomain - Parse a domain into sld and public_suffix/tld
56  
57 =head1 REQUIRES
58  
59 =over 4
60  
61 =item name
62  
63 =back
64  
65 =head1 DESCRIPTION
66  
67 This role is consumed by objects that have a domain name and adds to the consuming object the ability to split that domain into sld and public_suffix/tld. This is critically important because most of L<eNom|https://www.enom.com>'s API expects the SLD and TLD to be sent as different parameters.
68  
69 =head1 ATTRIBUTES
70  
71 =head2 sld
72  
73 The SLD of the domain. For google.co.uk this value would be google.
74  
75 B<NOTE> this is lazy built with an init_arg of undef.
76  
77 =head2 public_suffix
78  
79 The public_suffix of the domain (what some folks incorrectly call the TLD). For domains like google.co.uk the public_suffix is .co.uk. The public suffix is what is available for someone to actually register. For additional information between the distinction between Top Level Domain and Public Suffix please see L<https://publicsuffix.org/learn/>
80  
81 An alias of 'tld' is also provided if you really wish to refer to this as the TLD.
82  
83 B<NOTE> this is lazy built with an init_arg of undef.
84  
85 =cut
« blib/lib/WWW/eNom/PrivateNameServer.pm ↑ Summary