ProcAlike/ModuleInfo.pm

filter: Statementstmt 38.3% 18 / 47 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.6% 5 / 12 Podpod 33.3% 1 / 3 totaltotal 36.3% 24 / 66 CC 3 SCAR 10.2
CC
3
Cov
35%
register
6.0
unregister
6.0
new
2.0
CRAP 2.8
« ProcAlike/PerlInfo.pm ↑ Summary ProcAlike.pm »
1 # Declare our package
2 package POE::Devel::ProcAlike::ModuleInfo;
3 1 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # Initialize our version
6 1 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $VERSION = '0.02';
8  
9 # Set our superclass
10 1 ▶use base 'Filesys::Virtual::Async::inMemory';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # portable tools
13 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
16 # make sure we set a readonly filesystem!
17 0 return __PACKAGE__->SUPER::new(
18 'readonly' => 1,
19 );
20 }
21  
22 #/modules
23 # # place for modules to dump their info ( those who are aware of poe-devel-procalike )
24 #
25 # /poe-component-server-simplehttp
26 # # module name will be converted to above format
27 # # allowed only one object per module, they can stuff any data they want in their area
28 1 my %fs = (
29 # start with no modules loaded
30 );
31  
32 # helper sub to munge package names
33 0 ▶sub _mungepkg {
Subroutine _mungepkg: not called CC=1 SCAR=6.9
34 0 my( $self, $pkg ) = @_;
35  
36 # change :: to -
37 0 $pkg =~ s|::|-|g;
38  
39 # lowercase everything
40 0 $pkg = lc( $pkg );
41  
42 # all done!
43 0 return $pkg;
44 }
45  
46 # adds a package
47 0 ▶sub register {
Subroutine register: not called CC=2 SCAR=17.9
Pod undocumented
48 0 my( $self, $pkg ) = @_;
49  
50 # munge the package name to our "standard" format
51 0 $pkg = $self->_mungepkg( $pkg );
52  
53 # sanity check
54 0 ▶ if ( exists $fs{ $pkg } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fs{$pkg}) 0 0 0
55 0 return;
56 }
57  
58 # yay, we can add the package!
59 0 $fs{ $pkg } = 1;
60 0 return 1;
61 }
62  
63 # removes a package
64 0 ▶sub unregister {
Subroutine unregister: not called CC=2 SCAR=17.9
Pod undocumented
65 0 my( $self, $pkg ) = @_;
66  
67 # munge the package name to our "standard" format
68 0 $pkg = $self->_mungepkg( $pkg );
69  
70 # sanity check
71 0 ▶ if ( ! exists $fs{ $pkg } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $fs{$pkg}) 0 0 0
72 0 return;
73 }
74  
75 # yay, we can remove the package!
76 0 delete $fs{ $pkg };
77 0 return 1;
78 }
79  
80 # we cheat here and not implement a lot of stuff because we know the FUSE api never calls the "extra" APIs
81 # that ::Async provides. Furthermore, this is a read-only filesystem so we can skip even more APIs :)
82  
83 # _rmtree
84  
85 # _scandir
86  
87 # _move
88  
89 # _copy
90  
91 # _load
92  
93 0 ▶sub _readdir {
Subroutine _readdir: not called CC=1 SCAR=6.9
94 0 my( $self, $path ) = @_;
95  
96 # return our modules
97 0 return [ keys %fs ];
98 }
99  
100 # _rmdir
101  
102 # _mkdir
103  
104 # _rename
105  
106 # _mknod
107  
108 # _unlink
109  
110 # _chmod
111  
112 # _truncate
113  
114 # _chown
115  
116 # _utime
117  
118 0 ▶sub _stat {
Subroutine _stat: not called CC=1 SCAR=6.9
119 0 my( $self, $path ) = @_;
120  
121 # return generic info
122 0 my ($atime, $ctime, $mtime, $size, $modes);
123 0 $atime = $ctime = $mtime = time();
124 0 my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 );
125 0 $size = 0;
126 0 $modes = oct( '040755' );
127  
128 # count subdirs
129 0 $nlink = 2 + scalar keys %fs;
130  
131 0 return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] );
132 }
133  
134 # _write
135  
136 0 ▶sub _open {
Subroutine _open: not called CC=1 SCAR=6.9
137 0 my( $self, $path ) = @_;
138  
139 # we don't have anything to open!
140 0 return;
141 }
142  
143 1 1;
144 __END__
« ProcAlike/PerlInfo.pm ↑ Summary ProcAlike.pm »