File Coverage

blib/lib/RDF/DOAP/Utils.pm
Criterion Covered Total %
statement 21 33 63.6
branch 0 10 0.0
condition 0 6 0.0
subroutine 7 9 77.7
pod 0 1 0.0
total 28 59 47.4


line stmt bran cond sub pod time code
1              
2             our $AUTHORITY = 'cpan:TOBYINK';
3             our $VERSION = '0.105';
4              
5             use strict;
6 2     2   13 use warnings;
  2         5  
  2         55  
7 2     2   8  
  2         3  
  2         56  
8             use RDF::DOAP::Types -types;
9 2     2   11 use match::simple 'match';
  2         13  
  2         12  
10 2     2   10489 use List::Util 'uniq';
  2         3533  
  2         14  
11 2     2   349  
  2         4  
  2         172  
12             use MooseX::AttributeTags (
13             WithURI => [
14             uri => [ is => 'ro', isa => Identifier, coerce => 1, required => 1 ],
15             multi => [ is => 'ro', isa => Bool, default => 0 ],
16             ],
17             Gathering => [
18             gather_as => [ is => 'ro', isa => ArrayRef[Str], default => sub { [] } ],
19 2         7 ],
  0         0  
20             );
21 2     2   691  
  2         1652  
22             use Exporter::Tiny ();
23 2     2   223923 our @ISA = qw( Exporter::Tiny );
  2         4  
  2         870  
24             our @EXPORT_OK = qw( WithURI Gathering );
25             our %EXPORT_TAGS = (
26             traits => [qw( WithURI Gathering )]
27             );
28              
29             our %seen;
30              
31             {
32             my ($self, $relation) = @_;
33             return if $seen{$self}++;
34 0     0    
35 0 0         if (ArrayRef->check($self))
36             {
37 0 0         return uniq(
38             grep defined, map _gather_objects($_, $relation), grep defined, @$self
39 0           );
40             }
41            
42             if (Object->check($self))
43             {
44 0 0         return unless $self->isa('Moose::Object');
45            
46 0 0         my @local =
47             grep defined,
48 0 0 0       map ArrayRef->check($_) ? @$_ : $_,
49             map $_->get_value($self),
50             grep $_->does(Gathering) && match($relation, $_->gather_as),
51             $self->meta->get_all_attributes;
52            
53             my @recursive =
54             grep defined,
55 0   0       map _gather_objects($_, $relation),
56             grep defined,
57             map $_->get_value($self),
58             grep !($_->does(Gathering) && match($relation, $_->gather_as)),
59             $self->meta->get_all_attributes;
60            
61             return uniq(@local, @recursive);
62             }
63 0           }
64              
65             {
66             local %seen;
67             grep ref, _gather_objects(@_);
68             }
69 0     0 0    
70 0           1;