DDG/ZeroClickInfo/Fathead.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 34 CC 2 SCAR 15.4
CC
2
Cov
0%
new_via_output
6.0
BEGIN
2.0
CRAP 4.7
1 package DDG::ZeroClickInfo::Fathead;
2 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: DuckDuckGo server side used ZeroClickInfo Fathead result class
4 $DDG::ZeroClickInfo::Fathead::VERSION = '1017';
5 use Moo;
6 with 'DDG::IsControllable';
7  
8  
9  
10 sub new_via_output {
11 my @line = split( /\t/, $_[0] );
12  
13 my @fields = (
14 'title',
15 'type',
16 'redirect',
17 'otheruses',
18 'categories',
19 'references',
20 'see_also',
21 'further_reading',
22 'external_links',
23 'disambiguation',
24 'image',
25 'abstract',
26 'source_url');
27  
28 # Uses the list of fields to construct a hash with the field
29 # names as keys and the corresponding elements in the line as
30 # the values
31 my %params = map { $_ => shift @line || ''} @fields;
32  
33 # Delete undefined parameters so the attributes aren't set and
34 # we can use the predicates later.
35 foreach (keys %params) {
36 delete $params{$_} if $params{$_} eq '';
37 }
38  
39 return __PACKAGE__->new( %params );
40 }
41  
42  
43 has title => (
44 is => 'ro',
45 predicate => 'has_title',
46 );
47  
48  
49  
50 has type => (
51 is => 'ro',
52 predicate => 'has_type',
53 );
54  
55  
56  
57 has redirect => (
58 is => 'ro',
59 predicate => 'has_redirect',
60 );
61  
62  
63  
64 has other_uses => (
65 is => 'ro',
66 predicate => 'has_other_uses',
67 );
68  
69  
70  
71 has categories => (
72 is => 'ro',
73 predicate => 'has_categories',
74 );
75  
76  
77  
78 has references => (
79 is => 'ro',
80 predicate => 'has_references',
81 );
82  
83  
84  
85 has see_also => (
86 is => 'ro',
87 predicate => 'has_see_also',
88 );
89  
90  
91  
92 has further_reading => (
93 is => 'ro',
94 predicate => 'has_further_reading',
95 );
96  
97  
98  
99 has external_links => (
100 is => 'ro',
101 predicate => 'has_external_links',
102 );
103  
104  
105  
106 has disambiguation => (
107 is => 'ro',
108 predicate => 'has_disambiguation',
109 );
110  
111  
112  
113 has image => (
114 is => 'ro',
115 predicate => 'has_image',
116 );
117  
118  
119  
120 has abstract => (
121 is => 'ro',
122 predicate => 'has_abstract',
123 );
124  
125  
126  
127 has source_url => (
128 is => 'ro',
129 predicate => 'has_source_url',
130 );
131  
132 1;
133  
134 __END__