| 1 | 4 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | package Metabase::Index; | ||||||||||||
| 6 | # ABSTRACT: Interface for Metabase indexing | ||||||||||||
| 7 | 4 | our $VERSION = '1.003'; # VERSION | |||||||||||
| 8 | |||||||||||||
| 9 | 4 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 4 | with 'Metabase::Query'; | |||||||||||
| 12 | |||||||||||||
| 13 | 4 | requires 'add'; | |||||||||||
| 14 | 4 | requires 'query'; | |||||||||||
| 15 | 4 | requires 'count'; | |||||||||||
| 16 | 4 | requires 'delete'; | |||||||||||
| 17 | 4 | requires 'initialize'; | |||||||||||
| 18 | |||||||||||||
| 19 | 10 | ▶ | sub exists { | ||||||||||
|
Subroutine
exists: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 20 | 10 | my ($self, $guid) = @_; | |||||||||||
| 21 | # if desired guid in upper case, fix it | ||||||||||||
| 22 | 10 | return scalar @{ $self->search(-where => [-eq =>'core.guid'=>lc $guid])}; | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 12 | ▶ | sub clone_metadata { | ||||||||||
|
Subroutine
clone_metadata: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||
| 26 | 12 | my ($self, $fact) = @_; | |||||||||||
| 27 | 12 | my %metadata; | |||||||||||
| 28 | |||||||||||||
| 29 | 12 | for my $type (qw(core content resource)) { | |||||||||||
| 30 | 36 | my $method = "$type\_metadata"; | |||||||||||
| 31 | 36 | ▶ | my $data = $fact->$method || {}; | ||||||||||
|
Condition50%1/2
$fact->$method || {}
MC/DC0%0/1
$fact->$method || {}
$fact->$method
Truth table50%1/2
A
A= $fact->$method
| |||||||||||||
| 32 | |||||||||||||
| 33 | 36 | KEY: for my $key (keys %$data) { | |||||||||||
| 34 | 166 | ▶ | next KEY unless defined $data->{$key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | # I'm just starting with a strict-ish set. We can tighten or loosen | ||||||||||||
| 36 | # parts of this later. -- rjbs, 2009-03-28 | ||||||||||||
| 37 | 166 | ▶ | die "invalid metadata key '$key'" unless $key =~ /\A[-_a-z0-9.]+\z/i; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | 166 | $metadata{ "$type.$key" } = $data->{$key}; | |||||||||||
| 39 | } | ||||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 12 | for my $key ( qw/resource creator/ ) { | |||||||||||
| 43 | $metadata{"core.$key"} = $metadata{"core.$key"}->resource | ||||||||||||
| 44 | 24 | ▶ | if exists $metadata{"core.$key"}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 12 | return \%metadata; | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 26 | ▶ | sub search { | ||||||||||
|
Subroutine
search: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||
| 51 | 26 | my ($self, %spec) = @_; | |||||||||||
| 52 | 26 | my $result = $self->query(%spec); | |||||||||||
| 53 | 26 | ▶ | return $result->is_done ? [] : [ $result->all ]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | 4 | 1; | |||||||||||
| 57 | |||||||||||||
| 58 | __END__ | ||||||||||||