| 1 | package Analizo::Extractor; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 23 | ▶ | use parent qw(Class::Accessor::Fast Analizo::Filter::Client); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use Analizo::Model; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use Analizo::FilenameFilter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 21 | ▶ | use Analizo::LanguageFilter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 20 | our $QUIET = undef; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 20 | __PACKAGE__->mk_ro_accessors(qw(current_member)); | |||||||||||||||||||||||||||
| 15 | 20 | __PACKAGE__->mk_accessors(qw(current_file)); | |||||||||||||||||||||||||||
| 16 | 20 | __PACKAGE__->mk_accessors('includedir'); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 1 | die(sprintf("%s cannot be instantied. Try %s->load() instead", __PACKAGE__, __PACKAGE__)); | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 21 | ▶ | sub alias { | ||||||||||||||||||||||||||
|
Subroutine
alias: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 21 | my ($alias) = @_; | |||||||||||||||||||||||||||
| 24 | 21 | my %aliases = ( | |||||||||||||||||||||||||||
| 25 | doxy => 'Doxyparse', | ||||||||||||||||||||||||||||
| 26 | excluding_dirs => 0, | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | 21 | ▶ | exists $aliases{$alias} ? $aliases{$alias} : $alias; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 21 | ▶ | sub sanitize { | ||||||||||||||||||||||||||
|
Subroutine
sanitize: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 21 | my ($extractor_name) = @_; | |||||||||||||||||||||||||||
| 33 | 21 | ▶ | if ($extractor_name && $extractor_name =~ /^\w+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$extractor_name and $extractor_name =~ /^\w+$/
MC/DC100%2/2
$extractor_name and $extractor_name =~ /^\w+$/
$extractor_name
$extractor_name =~ /^\w+$/
Truth table100%3/3
A and B
A= $extractor_nameB= $extractor_name =~ /^\w+$/
| |||||||||||||||||||||||||||||
| 34 | 17 | return $extractor_name; | |||||||||||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||||||||||
| 36 | 5 | return 'Doxyparse'; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 20 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 21 | my ($self, $extractor_method, @options) = @_; | |||||||||||||||||||||||||||
| 42 | 20 | $extractor_method = alias(sanitize($extractor_method)); | |||||||||||||||||||||||||||
| 43 | 20 | my $extractor = "Analizo::Extractor::$extractor_method"; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 20 | ▶ | eval "use $extractor"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 20 | ▶ | die "error loading $extractor_method extractor: $@" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 19 | eval { $extractor = $extractor->new(@options) }; | |||||||||||||||||||||||||||
| 49 | 19 | ▶ | die "error instancing extractor: $@" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 19 | return $extractor; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 70 | ▶ | sub model { | ||||||||||||||||||||||||||
|
Subroutine
model: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 70 | my ($self) = @_; | |||||||||||||||||||||||||||
| 56 | 70 | ▶ | if (!exists($self->{model})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 14 | $self->{model} = Analizo::Model->new; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 70 | return $self->{model}; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 61 | ▶ | sub current_module { | ||||||||||||||||||||||||||
|
Subroutine
current_module: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 61 | my ($self, $current_module) = @_; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # set the new value | ||||||||||||||||||||||||||||
| 66 | 61 | ▶ | if (scalar $current_module) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 19 | ($self->{current_module}) = $current_module; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | #declare | ||||||||||||||||||||||||||||
| 70 | 19 | $self->model->declare_module($self->{current_module}, $self->current_file); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 61 | return $self->{current_module}; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | sub actually_process { | ||||||||||||||||||||||||||
|
Subroutine
actually_process: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | # This method must be overriden by subclasses | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # To disable filtering override this method returning false | ||||||||||||||||||||||||||||
| 81 | 10 | ▶ | sub use_filters { | ||||||||||||||||||||||||||
|
Subroutine
use_filters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 10 | 1; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 11 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 11 | my ($self, @input) = @_; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 11 | ▶ | if ($self->use_filters) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 10 | @input = $self->apply_filters(@input); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 10 | $self->actually_process(@input); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | return if $QUIET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||
| 97 | 0 | print STDERR "I: $msg\n"; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub warning { | ||||||||||||||||||||||||||
|
Subroutine
warning: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return if $QUIET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||
| 103 | 0 | print STDERR "W: $msg\n"; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||
|
Subroutine
error: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return if $QUIET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||
| 109 | 0 | print STDERR "E: $msg\n"; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 20 | 1; | |||||||||||||||||||||||||||