File Coverage

lib/App/Tel/Color.pm
Criterion Covered Total %
statement 21 22 95.4
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package App::Tel::Color;
2              
3 7     7   82478 use strict;
  7         14  
  7         187  
4 7     7   33 use warnings;
  7         11  
  7         167  
5 7     7   31 use Carp;
  7         13  
  7         369  
6 7     7   819 use Module::Load;
  7         1113  
  7         44  
7             require Exporter;
8             our @ISA = qw(Exporter);
9             our @EXPORT = qw();
10             our @EXPORT_OK = qw ( load_syntax );
11              
12             =head1 NAME
13              
14             App::Tel::Color - Methods for managing App::Tel::Color:: modules
15              
16             =cut
17              
18             =head2 load_syntax
19              
20             my $mod = $self->load_syntax('Cisco');
21              
22             This attempts to load syntax highlighting modules. In the above example,
23             Cisco would append Colors to the end and get CiscoColors.pm. If it can't find
24             the module it just won't load it.
25              
26             Returns an arrayref of module references.
27              
28             Multiple files can be chain loaded by using plus:
29              
30             my $ret = $self->load_syntax('Default+Cisco');
31              
32             =cut
33              
34             sub load_syntax {
35 3     3 1 1989 my $ret = [];
36 3         11 my ($list, $debug) = @_;
37 3         15 for(split(/\+/, $list)) {
38              
39 3         8 eval {
40 3         10 my $module = 'App::Tel::Color::'.$_;
41 3         16 Module::Load::load $module;
42 0         0 push(@$ret, $module->new);
43             };
44 3 50       560226 if ($@) {
45 3 100       62 carp $@ if ($debug);
46             }
47             }
48 3         1161 return $ret;
49             }
50              
51             1;