/usr/share/perl5/RDF/DOAP/Utils.pm is in librdf-doap-perl 0.100-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | package RDF::DOAP::Utils;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.100';
use strict;
use warnings;
use RDF::DOAP::Types -types;
use match::simple 'match';
use List::Util 'uniq';
use MooseX::AttributeTags (
WithURI => [
uri => [ is => 'ro', isa => Identifier, coerce => 1, required => 1 ],
multi => [ is => 'ro', isa => Bool, default => 0 ],
],
Gathering => [
gather_as => [ is => 'ro', isa => ArrayRef[Str], default => sub { [] } ],
],
);
use Exporter::Tiny ();
our @ISA = qw( Exporter::Tiny );
our @EXPORT_OK = qw( WithURI Gathering );
our %EXPORT_TAGS = (
traits => [qw( WithURI Gathering )]
);
our %seen;
sub _gather_objects
{
my ($self, $relation) = @_;
return if $seen{$self}++;
if (ArrayRef->check($self))
{
return uniq(
grep defined, map _gather_objects($_, $relation), grep defined, @$self
);
}
if (Object->check($self))
{
return unless $self->isa('Moose::Object');
my @local =
grep defined,
map ArrayRef->check($_) ? @$_ : $_,
map $_->get_value($self),
grep $_->does(Gathering) && match($relation, $_->gather_as),
$self->meta->get_all_attributes;
my @recursive =
grep defined,
map _gather_objects($_, $relation),
grep defined,
map $_->get_value($self),
grep !($_->does(Gathering) && match($relation, $_->gather_as)),
$self->meta->get_all_attributes;
return uniq(@local, @recursive);
}
}
sub gather_objects
{
local %seen;
grep ref, _gather_objects(@_);
}
1;
|