DDG/Meta/ZeroClickInfo.pm

filter: Statementstmt 85.0% 34 / 40 Branchbran 20.0% 2 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 74.5% 44 / 59 CC 6 SCAR 19.8
CC
6
Cov
72%
__ANON__
20.0
apply_keywords
2.5
__ANON__
2.3
CRAP 7.3
« DDG/Block.pm ↑ Summary DDG/Meta/ZeroClickInfoSpice.pm »
1 package DDG::Meta::ZeroClickInfo;
2 11 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Functions for generating a L<DDG::ZeroClickInfo> factory
4 11 $DDG::Meta::ZeroClickInfo::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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use DDG::ZeroClickInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 my %supported_zci_attributes = map { $_ => 1 } (qw(
12 abstract
13 abstract_text
14 abstract_source
15 abstract_url
16 caller
17 image
18 heading
19 answer
20 answer_type
21 definition
22 definition_source
23 definition_url
24 type
25 is_cached
26 is_unsafe
27 ttl
28 ));
29  
30  
31  
32 11 my %applied;
33  
34 sub apply_keywords {
35 34 ▶ my ( $class, $target ) = @_;
Subroutine apply_keywords: called CC=2 SCAR=9.0
Pod documented
36  
37 34 ▶ return if exists $applied{$target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $applied{$target} 0 34 34
38 34 $applied{$target} = undef;
39  
40 34 my @parts = split('::',$target);
41 34 shift @parts;
42 34 shift @parts;
43 34 my $answer_type = lc(join(' ',@parts));
44  
45 34 my $stash = Package::Stash->new($target);
46  
47 34 my %zci_params = (
48 caller => $target,
49 answer_type => $answer_type,
50 );
51  
52  
53  
54 $stash->add_symbol( '&zci', sub {
55 0 ▶ my %kv = (ref $_[0] eq 'HASH') ? %{$_[0]} : @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
56 0 ▶ while (my ($key, $value) = each(%kv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %kv) 0 0 0
57 0 ▶ croak $key. " is not supported on DDG::ZeroClickInfo" unless (exists $supported_zci_attributes{$key});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $supported_zci_attributes{$key} 0 0 0
58 0 $zci_params{$key} = $value;
59 }
60 34 });
61  
62  
63 $stash->add_symbol('&zci_new', sub {
64 34 ▶ shift;
Subroutine __ANON__: called CC=2 SCAR=8.1
65 34 ▶ DDG::ZeroClickInfo->new( %zci_params, ref $_[0] eq 'HASH' ? %{$_[0]} : @_ );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 34 34
66 34 });
67  
68 }
69  
70 11 1;
71  
72 __END__
« DDG/Block.pm ↑ Summary DDG/Meta/ZeroClickInfoSpice.pm »