| 1 | |||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | require 5; | |||||||||||||||||||||||||||||||||||||||||
| 3 | package Getopt::Janus; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 7 | # TODO: progress meters? | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | if(defined &DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | # no-op | ||||||||||||||||||||||||||||||||||||||||||
| 12 | ▶ | } elsif( ($ENV{'JANUSDEBUG'} || '') =~ m/^(-?\d+)$/s) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'JANUSDEBUG'} || ''
MC/DC0%0/1
$ENV{'JANUSDEBUG'} || ''
$ENV{'JANUSDEBUG'}
Truth table50%1/2
A
A= $ENV{'JANUSDEBUG'}
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | eval "sub DEBUG () {$1}"; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | die "INSANE! $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | *DEBUG = sub () {0}; | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use vars qw(@ISA %EXPORT_TAGS @EXPORT $VERSION | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | @New_files $Facade_class $facade_obj | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | @ISA = ('Exporter'); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | %EXPORT_TAGS = ('ALL' => \@EXPORT); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | $VERSION = '1.03'; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | @EXPORT = qw{ | |||||||||||||||||||||||||||||||||||||||||
| 27 | yes_no string file new_file choose | ||||||||||||||||||||||||||||||||||||||||||
| 28 | license_artistic license_gnu license_either | ||||||||||||||||||||||||||||||||||||||||||
| 29 | licence_artistic licence_gnu licence_either | ||||||||||||||||||||||||||||||||||||||||||
| 30 | run | ||||||||||||||||||||||||||||||||||||||||||
| 31 | note_new_files note_new_file | ||||||||||||||||||||||||||||||||||||||||||
| 32 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 8 | ▶ | $Facade_class ||= __PACKAGE__ . '::Facade'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Getopt::Janus::Facade_class ||= "Getopt::Janus::Facade"
MC/DC0%0/1
$Getopt::Janus::Facade_class ||= "Getopt::Janus::Facade"
$Getopt::Janus::Facade_class
Truth table50%1/2
A
A= $Getopt::Janus::Facade_class
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 8 | DEBUG and print "Facade class: $Facade_class\n"; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | sub run ($@) { _self()-> run(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub string (\$$@) { _self()-> string(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | sub new_file (\$$@) { _self()->new_file(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | sub file (\$$@) { _self()-> file(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | sub yes_no (\$$@) { _self()-> yes_no(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
yes_no: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | sub choose (\$$@) { _self()-> choose(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
choose: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub license_artistic () { _self()->license_artistic(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
license_artistic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub license_gnu () { _self()->license_gnu(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
license_gnu: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | sub license_either () { _self()->license_either(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
license_either: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | # variant spelling: | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub licence_artistic () { _self()->license_artistic(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
licence_artistic: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub licence_gnu () { _self()->license_gnu(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
licence_gnu: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub licence_either () { _self()->license_either(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
licence_either: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | sub note_new_file { push @New_files, @_; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note_new_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | sub note_new_files { goto ¬e_new_file; } # alias | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note_new_files: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 16 | ▶ | sub _self { # This is the only place where we construct | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_self: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 16 | ▶ | return $facade_obj ||= | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$Getopt::Janus::facade_obj ||= (_require($Getopt::Janus::Facade_class) || die("Can't load $Getopt::Janus::Facade_class: $@"))->new
_require($Getopt::Janus::Facade_class) || die("Can't load $Getopt::Janus::Facade_class: $@")
MC/DC0%0/2
$Getopt::Janus::facade_obj ||= (_require($Getopt::Janus::Facade_class) || die("Can't load $Getopt::Janus::Facade_class: $@"))->new
$Getopt::Janus::facade_obj
(_require($Getopt::Janus::Facade_class) || die("Can't load $Getopt::Janus::Facade_class: $@"))->new
MC/DC0%0/1
_require($Getopt::Janus::Facade_class) || die("Can't load $Getopt::Janus::Facade_class: $@")
_require($Getopt::Janus::Facade_class)
Truth table66%2/3
A ||= B
A= $Getopt::Janus::facade_objB= (_require($Getopt::Janus::Facade_class) || die("Can't load $Getopt::Janus::Facade_class: $@"))->new
Truth table50%1/2
A
A= _require($Getopt::Janus::Facade_class)
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | ( _require($Facade_class) || die "Can't load $Facade_class: $@" | ||||||||||||||||||||||||||||||||||||||||||
| 61 | )->new() | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | sub _require { # returns classname if loadable, or nil if not | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_require: called CC=7 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | unless( defined $class and length $class ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $class and length $class
MC/DC0%0/2
defined $class and length $class
defined $class
length $class
Truth table33%1/3
A and B
A= defined $classB= length $class
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | Carp::confess( "What class?" ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | ▶ | unless( # unless it's already loaded... | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined ${"${class}::VERSION";} or @{"${class}::ISA";} or defined &{"${class}::new";}
defined ${"${class}::VERSION";} or @{"${class}::ISA";}
MC/DC0%0/3
defined ${"${class}::VERSION";} or @{"${class}::ISA";} or defined &{"${class}::new";}
defined ${"${class}::VERSION";}
@{"${class}::ISA";}
defined &{"${class}::new";}
Truth table25%1/4
A or B or C
A= defined ${"${class}::VERSION";}B= @{"${class}::ISA";}C= defined &{"${class}::new";}
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | defined( ${"$class\::VERSION"} ) | |||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | or @{"$class\::ISA"} | |||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | or defined &{"$class\::new"} | |||||||||||||||||||||||||||||||||||||||||
| 77 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | eval "require $class"; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | return if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | DEBUG and print "Loaded $class fine.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | return $class; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | __END__ | ||||||||||||||||||||||||||||||||||||||||||