File Coverage

blib/lib/DDC/PP/Constants.pm
Criterion Covered Total %
statement 8 11 72.7
branch n/a
condition n/a
subroutine 4 7 57.1
pod 0 4 0.0
total 12 22 54.5


line stmt bran cond sub pod time code
1             ##-*- Mode: CPerl -*-
2              
3             ##======================================================================
4             package DDC::PP;
5              
6             ##--------------------------------------------------------------
7             ## ddcConfig.h
8 3     3 0 1656 sub library_version { return "2.2.8"; }
9              
10              
11             ##--------------------------------------------------------------
12             ## ConcCommon.h: HitSortEnum
13             our @HitSortEnum = qw(
14             NoSort
15             LessByDate GreaterByDate
16             LessBySize GreaterBySize
17             LessByFreeBiblField GreaterByFreeBiblField
18             LessByRank GreaterByRank
19             LessByMiddleContext GreaterByMiddleContext
20             LessByLeftContext GreaterByLeftContext
21             LessByRightContext GreaterByRightContext
22             RandomSort
23             LessByCountKey GreaterByCountKey
24             LessByCountValue GreaterByCountValue
25             LessByPruneKey GreaterByPruneKey
26             );
27             our @HitSortEnumStrings = qw(
28             no_sort
29             asc_by_date desc_by_date
30             asc_by_size desc_by_size
31             asc desc
32             asc_by_rank desc_by_rank
33             asc_middle desc_middle
34             asc_left desc_left
35             asc_right desc_right
36             random
37             asc_by_key desc_by_key
38             asc_by_count desc_by_count
39             prune_asc prune_desc
40             );
41              
42             our %HitSortEnum = ((map {($HitSortEnum[$_] =>$_)} (0..$#HitSortEnum)),
43             (map {($HitSortEnumStrings[$_]=>$_)} (0..$#HitSortEnumStrings))
44             );
45 0     0 0 0 sub HitSortEnumName { return $HitSortEnum[$_[0]]; }
46 0     0 0 0 sub HitSortsCount { return scalar @HitSortEnum; }
47 0     0 0 0 sub HitSortEnumString { return $HitSortEnumStrings[$_[0]]; }
48              
49             foreach my $ename (@HitSortEnum) {
50 20     20   155 no strict 'refs';
  20         48  
  20         3113  
51 140     140   73361 *$ename = sub { return $HitSortEnum{$ename}; };
52             }
53              
54             ##======================================================================
55             ## Exports
56             our %EXPORT_TAGS =
57             (
58             'hitsort' => [qw(@HitSortEnum @HitSortEnumStrings %HitSortEnum HitSortEnumString), @HitSortEnum],
59             );
60             $EXPORT_TAGS{all} = [map {@$_} values %EXPORT_TAGS];
61             $EXPORT_TAGS{constants} = [map {@$_} @EXPORT_TAGS{qw(hitsort)}];
62             our @EXPORT_OK = @{$EXPORT_TAGS{all}};
63             our @EXPORT = qw();
64              
65             ##======================================================================
66             package DDC::PP::Constants;
67 20     20   133 use strict;
  20         44  
  20         1865  
68              
69             1; ##-- be happy
70              
71             =pod
72              
73             =head1 NAME
74              
75             DDC::PP::Constants - pure-perl DDC::XS clone: constants
76              
77             =head1 SYNOPSIS
78              
79             use DDC::PP;
80             # or
81             use DDC::PP qw(:constants);
82            
83             ##---------------------------------------------------------------------
84             ## Top-Level constants (not exported)
85            
86             $string = DDC::PP::library_version();
87            
88             ##---------------------------------------------------------------------
89             ## ConcCommon.h: HitSortEnum (export-tag ":hitsort")
90              
91             # enum values are also available as $DDC::PP::HitSortEnum{NoSort}, etc.
92             $i = DDC::PP::NoSort();
93             $i = DDC::PP::LessByDate();
94             $i = DDC::PP::GreaterByDate();
95             $i = DDC::PP::LessBySize();
96             $i = DDC::PP::GreaterBySize();
97             $i = DDC::PP::LessByFreeBiblField();
98             $i = DDC::PP::GreaterByFreeBiblField();
99             $i = DDC::PP::LessByRank();
100             $i = DDC::PP::GreaterByRank();
101             $i = DDC::PP::LessByMiddleContext();
102             $i = DDC::PP::GreaterByMiddleContext();
103             $i = DDC::PP::LessByLeftContext();
104             $i = DDC::PP::GreaterByLeftContext();
105             $i = DDC::PP::LessByRightContext();
106             $i = DDC::PP::GreaterByRightContext();
107             $i = DDC::PP::RandomSort();
108             $i = DDC::PP::LessByCountKey();
109             $i = DDC::PP::GreaterByCountKey();
110             $i = DDC::PP::LessByCountValue();
111             $i = DDC::PP::GreaterByCountValue();
112             $i = DDC::PP::LessByPruneKey();
113             $i = DDC::PP::GreaterByPruneKey();
114             $i = DDC::PP::HitSortsCount();
115              
116             # enum labels are also available as $DDC::PP::HitSortEnum[DDC::PP::NoSort], etc.
117             $s = DDC::PP::HitSortName($i);
118              
119              
120             =head1 DESCRIPTION
121              
122             The DDC::PP::Constants is pure-perl fork of the L module.
123              
124             =head1 SEE ALSO
125              
126             perl(1),
127             DDC::PP(3perl).
128              
129             =head1 AUTHOR
130              
131             Bryan Jurish Emoocow@cpan.orgE
132              
133             =head1 COPYRIGHT AND LICENSE
134              
135             Copyright (C) 2016-2020 by Bryan Jurish
136              
137             This library is free software; you can redistribute it and/or modify
138             it under the same terms as Perl itself, either Perl version 5.14.2 or,
139             at your option, any later version of Perl 5 you may have available.
140              
141             =cut
142