Attean/IRI.pm

filter: Statementstmt 100% 42 / 42 Branchbran 87.5% 7 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 92.3% 60 / 65 CC 6 SCAR 8.6
CC
6
Cov
94%
equals
4.2
__ANON__
3.0
BEGIN
1.0
CRAP 2.4
« AtteanX/Store/SimpleTripleStore.pm ↑ Summary Test/Attean/MutableQuadStore.pm »
1 51 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 51 ▶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.041
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 51 package Attean::IRI 0.041 {
32 51 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 51 ▶ use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 51 ▶ use IRI 0.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 51 ▶ use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 51 extends 'IRI';
38
39 51 has 'ntriples_string' => (is => 'ro', isa => Str, lazy => 1, builder => '_ntriples_string');
40 51 has 'string' => (is => 'ro', lazy => 1, builder => '_as_string', reader => 'as_string');
41  
42 =item C<< equals ( $iri ) >>
43  
44 Returns true if C<< $iri >> is equal to the invocant, false otherwise.
45  
46 =cut
47  
48 833 ▶ sub equals {
Subroutine equals: called CC=4 SCAR=14.5
Pod documented
49 # This overrides the Attean::API::TermOrVariable::equals implementation
50 # to allow lazy IRIs to remain unparsed for the case where neither has
51 # a base IRI.
52 833 my ($a, $b) = @_;
53 833 ▶ if ($b->isa('Attean::IRI')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->isa("Attean::IRI")) 825 8 833
54 825 ▶ unless ($a->has_base or $b->has_base) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($a->has_base or $b->has_base) 825 0 825
Condition33%1/3
$a->has_base or $b->has_base
l!l&&r!l&&!r
00825
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
ABresult
1X1
011
000
55 825 return ($a->value eq $b->value);
56 }
57 }
58 8 return ($a->as_string eq $b->as_string);
59 }
60
61 51 with 'Attean::API::IRI';
62 51 with 'Attean::API::BlankOrIRI';
63  
64 1824 ▶ around BUILDARGS => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
65 1824 my $orig = shift;
66 1824 my $class = shift;
67 1824 my $args;
68 1824 ▶ if (scalar(@_) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1) { } 1312 512 1824
69 1312 $args = $class->$orig(value => shift);
70 } else {
71 512 $args = $class->$orig(@_);
72 }
73
74 1824 ▶ if (exists $args->{base}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"base"}) 16 1808 1824
75 # fully qualify IRIs
76 16 my $iri = IRI->new( %$args );
77 16 $args = { value => $iri->as_string };
78 }
79 1824 return $args;
80 51 };
81  
82 =item C<< as_string >>
83  
84 Returns the IRI value.
85  
86 =cut
87  
88 466 ▶ sub _as_string {
Subroutine _as_string: called CC=1 SCAR=0.0
89 466 my $self = shift;
90 466 return $self->abs;
91 }
92 }
93  
94 51 1;
95  
96 __END__
« AtteanX/Store/SimpleTripleStore.pm ↑ Summary Test/Attean/MutableQuadStore.pm »