NumSeq/OEIS/Catalogue.pm

filter: Statementstmt 68.1% 30 / 44 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 66.6% 4 / 6 totaltotal 68.7% 44 / 64 CC 5 SCAR 12.8
CC
5
Cov
67%
anum_list
12.0
anum_to_info
3.2
anum_after
2.0
CRAP 3.6
« NumSeq/Primorials.pm ↑ Summary NumSeq/Xenodromes.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
2  
3 # This file is part of Math-NumSeq.
4 #
5 # Math-NumSeq is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Math-NumSeq is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
17  
18  
19 # my $catalogue = Math::Values::OeisCatalogue->new(exclude_files=>1);
20 #
21  
22  
23  
24 package Math::NumSeq::OEIS::Catalogue;
25 2 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # uncomment this to run the ### lines
30 #use Smart::Comments;
31  
32 2 ▶use Module::Pluggable require => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 2 my @plugins = sort __PACKAGE__->plugins;
34 ### @plugins
35  
36 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 $VERSION = 75;
38  
39 # sub seq_to_num {
40 # my ($class, $num) = @_;
41 # }
42  
43  
44 2 ▶sub anum_to_info {
Subroutine anum_to_info: called CC=3 SCAR=11.7
Pod undocumented
45 2 my ($class, $anum) = @_;
46 ### Catalogue anum_to_info(): $anum
47  
48 2 foreach my $plugin (@plugins) {
49 ### $plugin
50 2 ▶ if (my $info = $plugin->anum_to_info($anum)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $info = $plugin->anum_to_info($anum)) 2 0 2
51 2 return $info;
52 }
53 }
54 0 return undef;
55 }
56  
57 0 ▶sub anum_list {
Subroutine anum_list: not called CC=3 SCAR=24.8
Pod undocumented
58 0 my ($class) = @_;
59 0 my %ret;
60 0 foreach my $plugin (@plugins) {
61 ### $plugin
62 0 foreach my $info (@{$plugin->info_arrayref}) {
63 0 $ret{$info->{'anum'}} = 1;
64 }
65 }
66 0 my @ret = sort {$a<=>$b} keys %ret;
67 0 return @ret;
68 }
69  
70 130 ▶sub _method_apply {
Subroutine _method_apply: called CC=1 SCAR=0.0
71 130 my $acc = shift;
72 130 my $method = shift;
73 ### plugin anums: map {$_->$method(@_)} @plugins
74 130 return $acc->(grep {defined} map {$_->$method(@_)} @plugins);
75 }
76 0 ▶sub anum_after {
Subroutine anum_after: not called CC=1 SCAR=6.9
Pod documented
77 0 my ($class, $after_anum) = @_;
78 ### Catalogue anum_after(): $after_anum
79  
80 0 _method_apply (\&List::Util::minstr, 'anum_after', $after_anum);
81 }
82 0 ▶sub anum_before {
Subroutine anum_before: not called CC=1 SCAR=6.9
Pod documented
83 0 my ($class, $before_anum) = @_;
84 0 _method_apply (\&List::Util::maxstr, 'anum_before', $before_anum);
85 }
86  
87 65 ▶sub anum_first {
Subroutine anum_first: called CC=1 SCAR=0.0
Pod documented
88 65 my ($class) = @_;
89 65 _method_apply (\&List::Util::minstr, 'anum_first');
90 }
91 65 ▶sub anum_last {
Subroutine anum_last: called CC=1 SCAR=0.0
Pod documented
92 65 my ($class) = @_;
93 65 _method_apply (\&List::Util::maxstr, 'anum_last');
94 }
95  
96  
97 # sub anum_to_class {
98 # my ($class, $anum) = @_;
99 # ### anum_to_class(): @_
100 # my @ret;
101 # foreach my $plugin (@plugins) {
102 # ### $plugin
103 # my $href = $plugin->anum_to_class_hashref;
104 # if (my $aref = $href->{$anum}) {
105 # return @$aref;
106 # }
107 # }
108 # return;
109 # }
110 #
111 # sub _file_anum_list {
112 # my ($class) = @_;
113 # ### anum_list()
114 # my %ret;
115 # foreach my $plugin (@plugins) {
116 # ### $plugin
117 # my $href = $plugin->anum_to_class_hashref;
118 # %ret = (%ret, %$href);
119 # }
120 # return sort keys %ret;
121 # }
122  
123  
124 2 1;
125 __END__
« NumSeq/Primorials.pm ↑ Summary NumSeq/Xenodromes.pm »