DMOSS/Oracle.pm

filter: Statementstmt 32.6% 15 / 46 Branchbran 0.0% 0 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 50.0% 2 / 4 totaltotal 24.1% 21 / 87 CC 18 SCAR 40.9
CC
18
Cov
20%
type
110.0
group
42.0
type_by_extension
20.0
CRAP 59.8
↑ Summary DMOSS/Plugin/VerifyChanges.pm »
1 package DMOSS::Oracle;
2 # ABSTRACT: DMOSS file type oracle
3 3 $DMOSS::Oracle::VERSION = '0.01_2';
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use MIME::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10 2 my ($class) = @_;
11 2 my $self = bless({}, $class);
12  
13 2 return $self;
14 }
15  
16 0 ▶sub type {
Subroutine type: not called CC=10 SCAR=47.0
Pod documented
17 0 my ($self, $file) = @_;
18 0 my $type = '';
19  
20 # first, filter by extension
21 0 $type = $self->type_by_extension($file);
22 0 ▶ return $type if $type;
Branch: 1 branch
BranchTrueFalseTotal
if $type 0 0 0
23
24 # second, some hand made RE
25 0 ▶ return 'README' if ($file->basename =~ m/^read.*?me$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /^read.*?me$/i 0 0 0
26 0 ▶ return 'LICENSE' if ($file->basename =~ m/^licen.e$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /^licen.e$/i 0 0 0
27 0 ▶ return 'INSTALL' if ($file->basename =~ m/^install$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /^install$/i 0 0 0
28 0 ▶ return 'MAN' if ($file->path =~ m/\/man\//i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->path =~ m[/man/]i 0 0 0
29 0 ▶ return 'MAKEFILE' if ($file->basename =~ m/^makefile$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /^makefile$/i 0 0 0
30 0 ▶ return 'TEXT' if ($file->basename =~ m/\.txt$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /\.txt$/i 0 0 0
31 0 ▶ return 'CHANGES' if ($file->basename =~ m/^changes*(log)*$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /^changes*(log)*$/i 0 0 0
32  
33 # third, try to return mime type
34 0 my $types = MIME::Types->new;
35 0 my $mime = $types->mimeTypeOf($file->fullpath);
36 0 ▶ return $mime if $mime;
Branch: 1 branch
BranchTrueFalseTotal
if $mime 0 0 0
37  
38 # no type found
39 0 return undef;
40 }
41  
42 3 my $extensions = {
43 'ANT' => [qw/build.xml/],
44 'ASM' => [qw/asm ASM s S A51 29[kK] [68][68][kKsSxX] [xX][68][68]/],
45 'ASP' => [qw/asp asa/],
46 'AWK' => [qw/awk gawk mawk/],
47 'BASIC' => [qw/bas bi bb pb/],
48 'BETA' => [qw/bet/],
49 'C' => [qw/c/],
50 'C++' => [qw/c++ cc cp cpp cxx h h++ hh hp hpp hxx C H/],
51 'C#' => [qw/cs/],
52 'COBOL' => [qw/cbl cob CBL COB/],
53 'DOSBATCH' => [qw/bat cmd/],
54 'EIFFEL' => [qw/e/],
55 'ERLANG' => [qw/erl ERL hrl HRL/],
56 'FLEX' => [qw/as mxml/],
57 'FORTRAN' => [qw/f for ftn f77 f90 f95 F FOR FTN F77 F90 F95/],
58 'GO' => [qw/go/],
59 'HTML' => [qw/htm html/],
60 'JAVA' => [qw/java/],
61 'JAVASCRIPT' => [qw/js/],
62 'LISP' => [qw/cl clisp el l lisp lsp/],
63 'LUA' => [qw/lua/],
64 'MAKE' => [qw/mak mk [Mm]akefile GNUmakefile/],
65 'MATLAB' => [qw/m/],
66 'OBJECTIVEC' => [qw/m h/],
67 'OCAML' => [qw/ml mli/],
68 'PASCAL' => [qw/p pas/],
69 'PERL' => [qw/pl pm plx perl/],
70 'PHP' => [qw/php php3 phtml/],
71 'PYTHON' => [qw/py pyx pxd pxi scons/],
72 'REXX' => [qw/cmd rexx rx/],
73 'RUBY' => [qw/rb ruby/],
74 'SCHEME' => [qw/SCM SM sch scheme scm sm/],
75 'SH' => [qw/sh SH bsh bash ksh zsh/],
76 'SLANG' => [qw/sl/],
77 'SML' => [qw/sml sig/],
78 'SQL' => [qw/sql/],
79 'TCL' => [qw/tcl tk wish itcl/],
80 'TEX' => [qw/tex/],
81 'VERA' => [qw/vr vri vrh/],
82 'VERILOG' => [qw/v/],
83 'VHDL' => [qw/vhdl vhd/],
84 'VIM' => [qw/vim/],
85 'YACC' => [qw/y/],
86 };
87  
88 0 ▶sub type_by_extension {
Subroutine type_by_extension: not called CC=4 SCAR=30.0
Pod undocumented
89 0 my ($self, $file) = @_;
90  
91 0 foreach (keys %$extensions) {
92 0 foreach my $re (@{ $extensions->{$_} }) {
93 0 ▶ return $_ if ($file->basename =~ m/\.$re$/);
Branch: 1 branch
BranchTrueFalseTotal
if $file->basename =~ /\.$re$/ 0 0 0
94 }
95 }
96  
97 0 return undef;
98 }
99  
100 0 ▶sub group {
Subroutine group: not called CC=6 SCAR=37.4
Pod undocumented
101 0 my ($self, $group) = @_;
102 0 ▶ return () unless ($group =~ m/^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $group =~ /^_/ 0 0 0
103  
104 0 ▶ if ($group eq '_DOC') {
Branch: 1 branch
BranchTrueFalseTotal
if ($group eq "_DOC") 0 0 0
105 0 return qw/README INSTALL MAN TEXT/;
106 }
107 0 ▶ if ($group eq '_OTHER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($group eq "_OTHER") 0 0 0
108 0 return qw/LICENSE MAKEFILE CHANGES/;
109 }
110 0 ▶ if ($group eq '_SOURCE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($group eq "_SOURCE") 0 0 0
111 0 return (keys %$extensions);
112 }
113 0 ▶ if ($group eq '_ALL') {
Branch: 1 branch
BranchTrueFalseTotal
if ($group eq "_ALL") 0 0 0
114 0 return ( $self->group('_DOC'), $self->group('_OTHER'), $self->group('_SOURCE') );
115 }
116 }
117  
118 3 1;
119  
120 __END__
↑ Summary DMOSS/Plugin/VerifyChanges.pm »