| 1 | #!perl -w | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use File::Find::Rule; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use File::Spec::Functions qw(catdir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # bootstrap extensions | ||||||||||||||||||||||||||||
| 7 | 6 | for (@INC) { | |||||||||||||||||||||||||||
| 8 | 60 | my $dir = catdir($_, qw( File Find Rule ) ); | |||||||||||||||||||||||||||
| 9 | 60 | ▶ | next unless -d $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | my @pm = find( name => '*.pm', maxdepth => 1, | ||||||||||||||||||||||||||||
| 11 | 0 | ▶ | exec => sub { (my $name = $_) =~ s/\.pm$//; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 0 | eval "require File::Find::Rule::$name"; }, | |||||||||||||||||||||||||||
| 13 | 24 | in => $dir ); | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # what directories are we searching in? | ||||||||||||||||||||||||||||
| 17 | 6 | my @where; | |||||||||||||||||||||||||||
| 18 | 6 | ▶ | while (@ARGV) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 12 | local $_ = shift @ARGV; | |||||||||||||||||||||||||||
| 20 | 12 | ▶ | if (/^-/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 6 | unshift @ARGV, $_; | |||||||||||||||||||||||||||
| 22 | 6 | last; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | 6 | push @where, $_; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # parse arguments, build a rule object | ||||||||||||||||||||||||||||
| 28 | 6 | my $rule = new File::Find::Rule; | |||||||||||||||||||||||||||
| 29 | 6 | ▶ | while (@ARGV) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 13 | my $clause = shift @ARGV; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 13 | ▶ | unless ( $clause =~ s/^-// && $rule->can( $clause ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$clause =~ s/^-// and $rule->can($clause)
MC/DC50%1/2
$clause =~ s/^-// and $rule->can($clause)
$clause =~ s/^-//
$rule->can($clause)
Truth table66%2/3
A and B
A= $clause =~ s/^-//B= $rule->can($clause)
| |||||||||||||||||||||||||||||
| 33 | # not a known rule - complain about this | ||||||||||||||||||||||||||||
| 34 | 1 | die "unknown option '$clause'\n" | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # it was the last switch | ||||||||||||||||||||||||||||
| 38 | 12 | ▶ | unless (@ARGV) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 2 | $rule->$clause(); | |||||||||||||||||||||||||||
| 40 | 2 | next; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # consume the parameters | ||||||||||||||||||||||||||||
| 44 | 10 | my $param = shift @ARGV; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 10 | ▶ | if ($param =~ /^-/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | # it's the next switch - put it back, and add one with no params | ||||||||||||||||||||||||||||
| 48 | 4 | unshift @ARGV, $param; | |||||||||||||||||||||||||||
| 49 | 4 | $rule->$clause(); | |||||||||||||||||||||||||||
| 50 | 4 | next; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 6 | ▶ | if ($param eq '(') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | # multiple values - just look for the closing parenthesis | ||||||||||||||||||||||||||||
| 55 | 2 | my @p; | |||||||||||||||||||||||||||
| 56 | 2 | ▶ | while (@ARGV) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 6 | my $val = shift @ARGV; | |||||||||||||||||||||||||||
| 58 | 6 | ▶ | last if $val eq ')'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 4 | push @p, $val; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 2 | $rule->$clause( @p ); | |||||||||||||||||||||||||||
| 62 | 2 | next; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # a single argument | ||||||||||||||||||||||||||||
| 66 | 4 | $rule->$clause( $param ); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # add a print rule so things happen faster | ||||||||||||||||||||||||||||
| 70 | 5 | ▶ | $rule->exec( sub { print "$_[2]\n"; return; } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # profit | ||||||||||||||||||||||||||||
| 73 | 5 | ▶ | $rule->in( @where ? @where : '.' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 5 | exit 0; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||