| 1 | 50 | ▶ | use v5.14; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | Attean::IRI - RDF Internationalized Resource Identifiers (IRIs) | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | This document describes Attean::IRI version 0.040 | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | use v5.14; | ||||||||||||||||||||||||||||
| 15 | use Attean; | ||||||||||||||||||||||||||||
| 16 | my $term = Attean::IRI->new('http://example.org/'); | ||||||||||||||||||||||||||||
| 17 | $term->ntriples_string; # <http://example.org/> | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | The Attean::IRI class represents RDF IRIs. | ||||||||||||||||||||||||||||
| 22 | It conforms to the L<Attean::API::IRI|Attean::API::Term> role | ||||||||||||||||||||||||||||
| 23 | and extends the L<IRI> class. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 METHODS | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =over 4 | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 50 | package Attean::IRI 0.040 { | |||||||||||||||||||||||||||
| 32 | 50 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 50 | ▶ | use Types::Standard qw(Str); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 50 | ▶ | use IRI 0.005; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 50 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 50 | extends 'IRI'; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 50 | has 'ntriples_string' => (is => 'ro', isa => Str, lazy => 1, builder => '_ntriples_string'); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =item C<< equals ( $iri ) >> | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | Returns true if C<< $iri >> is equal to the invocant, false otherwise. | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 747 | ▶ | sub equals { | ||||||||||||||||||||||||||
|
Subroutine
equals: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | # This overrides the Attean::API::TermOrVariable::equals implementation | ||||||||||||||||||||||||||||
| 49 | # to allow lazy IRIs to remain unparsed for the case where neither has | ||||||||||||||||||||||||||||
| 50 | # a base IRI. | ||||||||||||||||||||||||||||
| 51 | 747 | my ($a, $b) = @_; | |||||||||||||||||||||||||||
| 52 | 747 | ▶ | if ($b->isa('Attean::IRI')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 739 | ▶ | unless ($a->has_base or $b->has_base) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$a->has_base or $b->has_base
MC/DC0%0/2
$a->has_base or $b->has_base
$a->has_base
$b->has_base
Truth table33%1/3
A or B
A= $a->has_baseB= $b->has_base
| |||||||||||||||||||||||||||||
| 54 | 739 | return ($a->value eq $b->value); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 8 | return ($a->as_string eq $b->as_string); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 50 | with 'Attean::API::IRI'; | |||||||||||||||||||||||||||
| 61 | 50 | with 'Attean::API::BlankOrIRI'; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1839 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 64 | 1839 | my $orig = shift; | |||||||||||||||||||||||||||
| 65 | 1839 | my $class = shift; | |||||||||||||||||||||||||||
| 66 | 1839 | my $args; | |||||||||||||||||||||||||||
| 67 | 1839 | ▶ | if (scalar(@_) == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 1423 | $args = $class->$orig(value => shift); | |||||||||||||||||||||||||||
| 69 | } else { | ||||||||||||||||||||||||||||
| 70 | 416 | $args = $class->$orig(@_); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1839 | ▶ | if (exists $args->{base}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | # fully qualify IRIs | ||||||||||||||||||||||||||||
| 75 | 16 | my $iri = IRI->new( %$args ); | |||||||||||||||||||||||||||
| 76 | 16 | $args = { value => $iri->as_string }; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 1839 | return $args; | |||||||||||||||||||||||||||
| 79 | 50 | }; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =item C<< as_string >> | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Returns the IRI value. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1714 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 1714 | my $self = shift; | |||||||||||||||||||||||||||
| 89 | 1714 | return $self->abs; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 50 | 1; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||||||||||