| 1 | package WWW::eNom::Role::ParseDomain; | ||
| 2 | |||
| 3 | 66 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 66 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 66 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 66 | ▶ | use MooseX::Aliases; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 66 | ▶ | use WWW::eNom::Types qw( Str ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 66 | ▶ | use Mozilla::PublicSuffix; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 66 | requires 'name'; | |
| 14 | |||
| 15 | 66 | our $VERSION = 'v2.7.0'; # VERSION | |
| 16 | # ABSTRACT: Parse a domain into sld and public_suffix/tld | ||
| 17 | |||
| 18 | 66 | has 'sld' => ( | |
| 19 | is => 'ro', | ||
| 20 | isa => Str, | ||
| 21 | builder => '_build_sld', | ||
| 22 | lazy => 1, | ||
| 23 | init_arg => undef, | ||
| 24 | ); | ||
| 25 | |||
| 26 | 66 | 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 | 4 | ▶ | sub _build_sld { |
|
Subroutine
_build_sld: called CC=1 SCAR=0.0
| |||
| 36 | 4 | my $self = shift; | |
| 37 | |||
| 38 | 4 | return substr( $self->name, 0, length( $self->name ) - ( length( $self->public_suffix ) + 1 ) ); | |
| 39 | } | ||
| 40 | |||
| 41 | 6 | ▶ | sub _build_public_suffix { |
|
Subroutine
_build_public_suffix: called CC=1 SCAR=0.0
| |||
| 42 | 6 | my $self = shift; | |
| 43 | |||
| 44 | 6 | return Mozilla::PublicSuffix::public_suffix( $self->name ); | |
| 45 | } | ||
| 46 | |||
| 47 | 66 | 1; | |
| 48 | |||
| 49 | __END__ | ||