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   81490 use strict;
  7         11  
  7         155  
4 7     7   30 use warnings;
  7         12  
  7         152  
5 7     7   30 use Carp;
  7         13  
  7         339  
6 7     7   763 use Module::Load;
  7         966  
  7         45  
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 587 my $ret = [];
36 3         9 my ($list, $debug) = @_;
37 3         15 for(split(/\+/, $list)) {
38              
39 3         6 eval {
40 3         9 my $module = 'App::Tel::Color::'.$_;
41 3         15 Module::Load::load $module;
42 0         0 push(@$ret, $module->new);
43             };
44 3 50       2092 if ($@) {
45 3 100       35 carp $@ if ($debug);
46             }
47             }
48 3         782 return $ret;
49             }
50              
51             1;