lib/Metabase/Index.pm

filter: Statementstmt 100% 37 / 37 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 91.3% 53 / 58 CC 9 SCAR 16.1
CC
9
Cov
91%
clone_metadata
8.2
search
2.0
BEGIN
1.0
CRAP 5.0
« lib/Metabase/Gateway.pm ↑ Summary lib/Metabase/Query.pm »
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 || {}
l!l
360
MC/DC0%0/1
$fact->$method || {}
$fact->$method
Truth table50%1/2
A
A= $fact->$method
Aresult
11
00
32  
33 36 KEY: for my $key (keys %$data) {
34 166 ▶ next KEY unless defined $data->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{$key} 0 166 166
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
BranchTrueFalseTotal
unless $key =~ /\A[-_a-z0-9.]+\z/i 0 166 166
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
BranchTrueFalseTotal
if exists $metadata{"core.$key"} 12 12 24
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
BranchTrueFalseTotal
$result->is_done ? : 0 26 26
54 }
55  
56 4 1;
57  
58 __END__
« lib/Metabase/Gateway.pm ↑ Summary lib/Metabase/Query.pm »