line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DDG::Meta::Fathead; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DDG'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Functions for generating a L factory |
4
|
|
|
|
|
|
|
$DDG::Meta::Fathead::VERSION = '1016'; |
5
|
11
|
|
|
11
|
|
42
|
use strict; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
274
|
|
6
|
11
|
|
|
11
|
|
38
|
use warnings; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
229
|
|
7
|
11
|
|
|
11
|
|
38
|
use Package::Stash; |
|
11
|
|
|
|
|
309
|
|
|
11
|
|
|
|
|
2820
|
|
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
0
|
0
|
sub fathead_attributes {qw( |
10
|
|
|
|
|
|
|
mediawiki |
11
|
|
|
|
|
|
|
title_addon |
12
|
|
|
|
|
|
|
)} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %applied; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub apply_keywords { |
19
|
5
|
|
|
5
|
1
|
8
|
my ( $class , $target ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
5
|
50
|
|
|
|
14
|
return if exists $applied{$target}; |
22
|
5
|
|
|
|
|
8
|
$applied{$target} = undef; |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
|
|
17
|
my @parts = split( '::' , $target ); |
25
|
5
|
|
|
|
|
6
|
shift @parts; |
26
|
5
|
|
|
|
|
7
|
shift @parts; |
27
|
5
|
|
|
|
|
83
|
my $answer_type = lc(join(' ', @parts)); |
28
|
|
|
|
|
|
|
|
29
|
5
|
|
|
|
|
47
|
my $stash = Package::Stash->new($target); |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
16
|
my %zci_params = ( |
32
|
|
|
|
|
|
|
answer_type => $answer_type, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$stash->add_symbol('&fathead', sub { |
37
|
0
|
0
|
|
0
|
|
|
if (ref $_[0] eq 'HASH') { |
38
|
0
|
|
|
|
|
|
for (keys %{$_[0]}) { |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$zci_params{check_fathead_key($_)} = $_[0]->{$_}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} else { |
42
|
0
|
|
|
|
|
|
while (@_) { |
43
|
0
|
|
|
|
|
|
my $key = shift; |
44
|
0
|
|
|
|
|
|
my $value = shift; |
45
|
0
|
|
|
|
|
|
$zci_params{check_fathead_key($key)} = $value; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
5
|
|
|
|
|
67
|
}); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub check_fathead_key { |
53
|
0
|
|
|
0
|
1
|
|
my $key = shift; |
54
|
0
|
0
|
|
|
|
|
if (grep { $key eq $_ } fathead_attributes) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return $key; |
56
|
|
|
|
|
|
|
} else { |
57
|
0
|
|
|
|
|
|
croak $key." is not supported on DDG::Meta::Fathead"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |