DDG/Meta/Fathead.pm

filter: Statementstmt 62.1% 23 / 37 Branchbran 12.5% 1 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 66.6% 2 / 3 totaltotal 54.5% 30 / 55 CC 6 SCAR 21.4
CC
6
Cov
53%
__ANON__
20.0
check_fathead_key
6.0
apply_keywords
2.6
CRAP 8.5
« DDG/Meta/Data.pm ↑ Summary DDG/Meta/RequestHandler.pm »
1 package DDG::Meta::Fathead;
2 11 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Functions for generating a L<DDG::ZeroClickInfo::Fathead> factory
4 11 $DDG::Meta::Fathead::VERSION = '1017';
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub fathead_attributes {qw(
Subroutine fathead_attributes: not called CC=1 SCAR=6.9
Pod undocumented
10 mediawiki
11 title_addon
12 )}
13  
14  
15  
16 11 my %applied;
17  
18 sub apply_keywords {
19 5 ▶ my ( $class , $target ) = @_;
Subroutine apply_keywords: called CC=2 SCAR=9.7
Pod documented
20  
21 5 ▶ return if exists $applied{$target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $applied{$target} 0 5 5
22 5 $applied{$target} = undef;
23  
24 5 my @parts = split( '::' , $target );
25 5 shift @parts;
26 5 shift @parts;
27 5 my $answer_type = lc(join(' ', @parts));
28  
29 5 my $stash = Package::Stash->new($target);
30  
31 5 my %zci_params = (
32 answer_type => $answer_type,
33 );
34  
35  
36 $stash->add_symbol('&fathead', sub {
37 0 ▶ if (ref $_[0] eq 'HASH') {
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
38 0 for (keys %{$_[0]}) {
39 0 $zci_params{check_fathead_key($_)} = $_[0]->{$_};
40 }
41 } else {
42 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
43 0 my $key = shift;
44 0 my $value = shift;
45 0 $zci_params{check_fathead_key($key)} = $value;
46 }
47 }
48 5 });
49 }
50  
51  
52 sub check_fathead_key {
53 0 ▶ my $key = shift;
Subroutine check_fathead_key: not called CC=2 SCAR=17.9
Pod documented
54 0 ▶ if (grep { $key eq $_ } fathead_attributes) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$key eq $_;} fathead_attributes()) { } 0 0 0
55 0 return $key;
56 } else {
57 0 croak $key." is not supported on DDG::Meta::Fathead";
58 }
59 }
60  
61 11 1;
62  
63 __END__
« DDG/Meta/Data.pm ↑ Summary DDG/Meta/RequestHandler.pm »