File Coverage

blib/lib/RPerl/AfterSubclass.pm
Criterion Covered Total %
statement 42 60 70.0
branch 7 16 43.7
condition 4 9 44.4
subroutine 9 10 90.0
pod 0 3 0.0
total 62 98 63.2


line stmt bran cond sub pod time code
1             # DEV NOTE: all code originally in RPerl.pm, moved here when filter() added, now called in code generated by filter()
2              
3             # [[[ HEADER ]]]
4             package RPerl::AfterSubclass;
5 7     7   65485 use strict;
  7         58  
  7         186  
6 7     7   38 use warnings;
  7         11  
  7         286  
7             our $VERSION = 0.003_000;
8              
9             # [[[ INCLUDES ]]]
10 7     7   3115 use RPerl::CompileUnit::Module::Class;
  7         23  
  7         264  
11             1; # end of package
12              
13              
14             # [[[ HEADER ]]]
15             package RPerl;
16 7     7   51 use strict;
  7         17  
  7         159  
17 7     7   38 use warnings;
  7         14  
  7         276  
18              
19             # [[[ INCLUDES ]]]
20 7     7   42 use File::Basename;
  7         17  
  7         711  
21              
22             # [[[ INCLUDES SPECIAL ]]]
23             require RPerl::Config;
24             #use RPerl::Config;
25              
26             #BEGIN { use Data::Dumper; print 'in RPerl::AfterSubclass, have @INC = ' . "\n" . Dumper(\@INC) . "\n"; }
27              
28             #no magic; # require data types, full declarations, other non-magic
29             # DEV NOTE, CORRELATION #rp008: circular dependency causes "subroutine FOO redefined" errors, solved by replacing use with require below
30             #use rperltypes;
31             require rperltypes;
32             #require rperloperations;
33             #require rperlrules;
34             require rperlnames;
35             #require rperlnamespaces;
36              
37             # NEED ADD: use/require HelperFunctions*.pm here (not just in rperltypes.pm) to match dependency path of C++ code?
38              
39             # [[[ CONSTANTS ]]]
40             #use constant TEST_CONSTANT => my string $TYPED_TEST_CONSTANT = 'Hello, World!';
41 7     7   47 use constant TEST_CONSTANT => 'Hello, World!';
  7         17  
  7         3448  
42              
43             # [[[ SUBROUTINES ]]]
44              
45             sub package_to_namespace_root {
46 62     62 0 203 ( my $package ) = @ARG;
47             # print {*STDERR} 'in RPerl::package_to_namespace_root(), received $package = ' . $package . "\n";
48              
49 62         172 my $namespace_root = q{};
50 62         367 my $package_split = [ ( split /::/, $package ) ];
51 62 50 33     600 if ( ( defined $package_split->[0] ) and ( $package_split->[0] ne q{} ) ) {
52 62         204 $namespace_root = $package_split->[0] . '::';
53             }
54              
55             # print {*STDERR} 'in RPerl::package_to_namespace_root(), about to return $namespace_root = ' . $namespace_root . "\n";
56 62         242 return $namespace_root;
57             }
58              
59             sub filename_short_to_namespace_root_guess {
60 43044     43044 0 64379 ( my $filename_short ) = @ARG;
61             # print {*STDERR} 'in RPerl::filename_short_to_namespace_root_guess(), received $filename_short = ' . $filename_short . "\n";
62             # # DEV NOTE, CORRELATION #rp021: remove hard-coded fake 'rperl::' namespace?
63 43044 50       65766 if ($filename_short eq 'rperl') { return 'rperl::'; }
  0         0  
64 43044         50342 my $namespace_root = q{};
65 43044         602874 ( my $filename_prefix, my $filename_path, my $filename_suffix ) = fileparse( $filename_short, qr/[.][^.]*/xms );
66             # DEV NOTE: allow *.pl files to guess a namespace instead of empty string, both here and in filename_short_to_package_guess() below
67             # due to Perl core and/or RPerl deps calls to 'use' or 'require' *.pl files, such as Config_git.pl and Config_heavy.pl
68             # if ( $filename_suffix eq '.pm' ) {
69 43044 100 100     130114 if ( ( $filename_suffix eq '.pm' ) or ( $filename_suffix eq '.pl' ) ) {
70 42985         51083 my $filename_path_split;
71 42985 50       74489 if ( $OSNAME eq 'MSWin32' ) {
72 0         0 $filename_path_split = [ split /[\/\\]/, $filename_path ];
73             #absolute paths cant go through here anymore, this was dropping the
74             #first part of the package on some modules
75             #shift @{$filename_path_split}; # discard leading drive letter
76             }
77             else {
78 42985         105757 $filename_path_split = [ split /\//, $filename_path ];
79             }
80              
81             # join then re-split in case there are no directories in path, only the *.pm filename
82 42985         61937 my $namespace_root_split = [ split /::/, ( join '::', ( @{$filename_path_split}, $filename_prefix ) ) ];
  42985         129116  
83 42985 100       93647 if ( $namespace_root_split->[0] eq '.' ) {
84 3696         4384 shift @{$namespace_root_split};
  3696         4876  
85             }
86             # print {*STDERR} 'in RPerl::filename_short_to_namespace_root_guess(), have $namespace_root_split = ' . Dumper($namespace_root_split) . "\n";
87 42985         80442 $namespace_root = $namespace_root_split->[0] . '::';
88             }
89             # print {*STDERR} 'in RPerl::filename_short_to_namespace_root_guess(), about to return $namespace_root = ' . $namespace_root . "\n";
90 43044         83879 return $namespace_root;
91             }
92              
93             sub filename_short_to_package_guess {
94 0     0 0   ( my $filename_short ) = @ARG;
95             # print {*STDERR} 'in RPerl::filename_short_to_package_guess(), received $filename_short = ' . $filename_short . "\n";
96 0           my $package = q{};
97 0           ( my $filename_prefix, my $filename_path, my $filename_suffix ) = fileparse( $filename_short, qr/[.][^.]*/xms );
98              
99             # print {*STDERR} 'in RPerl::filename_short_to_package_guess(), have $filename_prefix = ' . $filename_prefix . "\n";
100             # print {*STDERR} 'in RPerl::filename_short_to_package_guess(), have $filename_path = ' . $filename_path . "\n";
101             # print {*STDERR} 'in RPerl::filename_short_to_package_guess(), have $filename_suffix = ' . $filename_suffix . "\n";
102              
103             # if ( $filename_suffix eq '.pm' ) {
104 0 0 0       if ( ( $filename_suffix eq '.pm' ) or ( $filename_suffix eq '.pl' ) ) {
105 0           my $filename_path_split;
106 0 0         if ( $OSNAME eq 'MSWin32' ) {
107 0           $filename_path_split = [ split /\\/, $filename_path ];
108 0           shift @{$filename_path_split}; # discard leading drive letter
  0            
109             }
110             else {
111 0           $filename_path_split = [ split /\//, $filename_path ];
112             }
113 0 0         if ($filename_path_split->[0] eq '.') {
114 0           shift @{$filename_path_split};
  0            
115             }
116             # print {*STDERR} 'in RPerl::filename_short_to_package_guess(), have $filename_path_split = ' . Dumper($filename_path_split) . "\n";
117 0           $package = join '::', ( @{$filename_path_split}, $filename_prefix );
  0            
118             }
119             # print {*STDERR} 'in RPerl::filename_short_to_package_guess(), about to return $package = ' . $package . "\n";
120 0           return $package;
121             }
122              
123             1; # end of package