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