lib/Acme/Schlong.pm

filter: Statementstmt 60.9% 164 / 269 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 55 / 88 Podpod 0.0% 0 / 2 totaltotal 54.7% 219 / 400 CC 20 SCAR 8.7
CC
20
Cov
53%
__ANON__
12.8
__ANON__
9.9
__ANON__
3.5
CRAP 2.4
↑ Summary
1 package Acme::Schlong;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Acme::Schlong::AUTHORITY = 'cpan:DBR';
4 }
5 {
6 1 $Acme::Schlong::VERSION = '0.001';
7 }
8  
9 # PODNAME: Acme::Schlong
10 # ABSTRACT: Fun with Acme::Schlong!
11  
12 1 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use true;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶class Acme::Schlong with MooseX::Getopt::Strict {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=1.1
16 1 ▶ use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use feature 'switch';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # Moose behavior
20 1 ▶ use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use MooseX::AlwaysCoerce;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶ use MooseX::Types::Moose -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 # infrastructure
25 1 ▶ use MooseX::Attribute::ENV;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶ use MooseX::Types::Path::Class 'Dir';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶ use Path::Class 'dir', 'file';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶ use Config::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶ use MooseX::Types::Perl 'StrictVersionStr';
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 # information gathering helpers
33 1 ▶ use App::OS::Detect::MachineCores;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶ use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶ use File::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 1 ▶ use MetaCPAN::API;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 # Post-Construction phase.
42 0 ▶ method BUILD {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=2 SCAR=9.2
43 1 ▶ use Acme::Emoticarp;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 0 ▶ o_O "Your system is Windows. I won't even bother calculating your schlong-size, sorry!" unless! ($^O ~~ /Win/ ... /Win/) # Just for fun (again)
Branch: 1 branch
BranchTrueFalseTotal
unless not $^O ~~ qr/Win/ ... /Win/ 0 0 0
45 1 }
46  
47 0 ▶ sub true { 1 }
Subroutine true: not called CC=1 SCAR=6.9
Pod undocumented
48 0 ▶ sub false { 0 }
Subroutine false: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 # The all mighty, all elementary information!
51 1 has size => (
52 is => 'rw',
53 isa => Int,
54 traits => ['Number'],
55 handles => {
56 set_size => 'set',
57 add_size => 'add',
58 sub_size => 'sub',
59 mul_size => 'mul',
60 div_size => 'div',
61 mod_size => 'mod',
62 abs_size => 'abs',
63 },
64 required => 1,
65 lazy_build => 1,
66 documentation => q{The all might, all elementary information!},
67 );
68  
69 1 has perl_specific => ( is => 'ro', isa => Bool, traits => ['Getopt'], cmd_aliases => ['P'], default => 0 );
70  
71 1 has username => ( is => 'ro', isa => Str, traits => ['ENV'], env_key => 'user' );
72 1 has home_directory => ( is => 'ro', isa => Dir, traits => ['ENV'], env_key => 'home' );
73 1 has term => ( is => 'ro', isa => Str, traits => ['ENV'] );
74  
75 1 has useraccounts => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{Check if system is like /home/b/bruder ... then you have to also supply the hidden "I'm the administrator switch"} );
76 1 has username_length => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory} );
77 1 has shell => ( is => 'ro', isa => Str, lazy_build => 1, documentation => q{self explanatory} );
78 1 has harddrive_size => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory} );
79 1 has harddrive_used => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory} );
80 1 has uptime => ( is => 'ro', isa => Any, lazy_build => 1, documentation => q{self explanatory} );
81 1 has users => ( is => 'ro', isa => Any, lazy_build => 1, documentation => q{The number of users logged in on the system} );
82 1 has cores => ( is => 'ro', isa => Any, lazy_build => 1, documentation => q{The Number of cores of this machine} );
83 1 has using_multiplex => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using screen or tmux});
84 1 has using_byobu => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using byobu as multiplexer frontend!} );
85 1 has using_tmux => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using tmux as multiplexer} );
86 1 has using_screen => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using screen as multiplexer} );
87  
88 1 has perl_version => ( is => 'ro', isa => StrictVersionStr, lazy_build => 1, documentation => q{The executing Perl's version number});
89 1 has perl_version_is_dev => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{The executing Perl's version number});
90 1 has directories_in_path => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{The number of directories set in $PATH} );
91 1 has using_perlbrew => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
92 1 has using_cpanm => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
93 1 has using_cpanm_customized => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{Has the user set specific flags to cpanm?} );
94 1 has using_bash => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
95 1 has using_zsh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
96 1 has using_ksh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
97 1 has using_tcsh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
98 1 has using_csh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
99 1 has using_dzil => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
100
101 1 has pause_name => ( is => 'ro', isa => Maybe[Str], lazy_build => 1, documentation => q{self explanatory});
102 1 has cpan_modules => ( is => 'ro', isa => Num, lazy_build => 1, documentation => q[self explanatory]);
103  
104 1 has perls_installed => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{the number of perls installed through perlbrew} );
105  
106 1 has known_hosts => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory});
107 0 ▶ has f => ( is => 'ro', isa => 'File::Util', default => sub { File::Util->new } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
108  
109 # has followers_on_github =>
110
111 # has number_of_rc_files => ~/.*rc
112 # has length of .vimrc
113 # has length of .emacs
114 # has number of files in ~/.emacs.d
115 # has using .ssh/config
116 # has rvm/rbenv installed
117 #
118  
119 # has number_of_modules => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{} );
120  
121 0 ▶ method _build_useraccounts { scalar grep { !/Shared/ } grep { -d $_ } glob ( dir( $self->home_directory => '..') . '/*'); } #TODO Make safer for WIN
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
122 0 ▶ method _build_username_length { length $self->username }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
123 0 ▶ method _build_shell { $_ = $ENV{SHELL}; s/.*\/(.*?)$/$1/; $_ } # /r
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
124 0 ▶ method _build_harddrive_size { $_=`df -l | grep '\\/\$' | awk '{print \$2}'`; chomp; $_ } # -E 'use IPC::Run qw<run timeout>; my $out; my @cmd = (q<du>, q<-s>, q</>); run \@cmd, "", \undef, \$out, timeout( 100 ) echo `uptime|grep days|sed 's/.*up \([0-9]*\) day.*/\1\/10+/'; \or die qq<ls: $?>; say $out; join q<>, @$out'
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
125 0 ▶ method _build_harddrive_used { $_=`df -l | grep '\\/\$' | awk '{print \$3}'`; chomp; $_ } # -E 'use IPC::Run qw<run timeout>; my $out; my @cmd = (q<du>, q<-s>, q</>); run \@cmd, "", \undef, \$out, timeout( 100 ) echo `uptime|grep days|sed 's/.*up \([0-9]*\) day.*/\1\/10+/'; \or die qq<ls: $?>; say $out; join q<>, @$out'
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
126 0 ▶ method _build_uptime { 100 }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
127 0 ▶ method _build_users { 5 }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
128 0 ▶ method _build_cores { App::OS::Detect::MachineCores->new->cores }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
129 0 ▶ method _build_using_multiplex { $self->using_byobu or $self->using_tmux or $self->using_screen ? true : false }
Subroutine BEGIN: called CC=1 SCAR=4.4
Subroutine __ANON__: not called CC=4 SCAR=25.5
Branch: 2 branches
BranchTrueFalseTotal
$self->using_byobu or $self->using_tmux or $self->using_screen ? true() : false() 0 0 0
$self->using_screen ? : 0 0 0
Condition0%0/3
$self->using_byobu or $self->using_tmux
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->using_byobu or $self->using_tmux
$self->using_byobu $self->using_tmux
Truth table0%0/3
A or B
A= $self->using_byobuB= $self->using_tmux
ABresult
1X1
011
000
130 0 ▶ method _build_using_byobu { exists $ENV{BYOBU_BACKEND} ? 1 : 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'BYOBU_BACKEND'} ? : 0 0 0
131 0 ▶ method _build_using_tmux { $ENV{TERM} ~~ 'tmux' ? 1 : 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'TERM'} ~~ 'tmux' ? : 0 0 0
132 0 ▶ method _build_using_screen { $ENV{TERM} ~~ 'screen' ? 1 : 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'TERM'} ~~ 'screen' ? : 0 0 0
133 0 ▶ method _build_perl_version { $_ = `$^X --version`; m/perl.*\((?<vstring>v\d\.\d+.\d+)\) built for.*/; $+{vstring} }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
134 # method _build_perl_version_is_dev { version->new($self->perl_version)->version->[1] % 2 ? 1 : 0 } # is_alpha
135 0 ▶ method _build_directories_in_path { scalar split q<:> => $ENV{PATH} }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
136 0 ▶ method _build_using_perlbrew { (grep { /perlbrew/i } keys %ENV) ? 1 : 0 }
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine __ANON__: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
grep({/perlbrew/i;} keys %ENV) ? : 0 0 0
137 0 ▶ method _build_using_cpanm { (grep { /cpanm/i } keys %ENV) ? 1 : 0 }
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine __ANON__: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
grep({/cpanm/i;} keys %ENV) ? : 0 0 0
138 0 ▶ method _build_using_cpanm_customized { !! (grep { /cpanm_opt/i } keys %ENV) || 0 } # TIMTOWDI just for fun
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine __ANON__: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
not !grep({/cpanm_opt/i;} keys %ENV) or 0 0 0 0
139 0 ▶ method _build_using_bash { $self->shell ~~ 'bash' || 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$self->shell ~~ "bash" or 0 0 0 0
140 0 ▶ method _build_using_zsh { $self->shell ~~ 'zsh' || 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$self->shell ~~ "zsh" or 0 0 0 0
141 0 ▶ method _build_using_ksh { $self->shell ~~ 'ksh' || 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$self->shell ~~ "ksh" or 0 0 0 0
142 0 ▶ method _build_using_tcsh { $self->shell ~~ 'tcsh' || 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$self->shell ~~ "tcsh" or 0 0 0 0
143 0 ▶ method _build_using_csh { $self->shell ~~ 'csh' || 0 }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
$self->shell ~~ "csh" or 0 0 0 0
144 0 ▶ method _build_using_dzil { (grep {/.dzil/} glob (dir($self->home_directory) . '/' . '.*')) ? 1 : 0 }
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine __ANON__: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
grep({/.dzil/;} glob(dir($self->home_directory) . '/' . '.*')) ? : 0 0 0
145  
146 0 ▶ method _build_pause_name {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=2.6
147 Config::Any->load_files( {
148 files => [ file($self->home_directory, '.dzil', 'config.ini') ],
149 flatten_to_hash => 1,
150 use_ext => 1 }
151 )->{file($self->home_directory, '.dzil', 'config.ini')}
152 ->{'%PAUSE'}
153 0 ->{'username'};
154 1 }
155 0 ▶ method _build_cpan_modules { scalar MetaCPAN::API->new->release(search => {author => $self->pause_name, filter => "distribution", fields=>"name"})->{hits}->{hits} }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
156 0 ▶ method _build_perls_installed { $_ =()= $self->f->list_dir("$ENV{PERLBREW_ROOT}/perls", '--dirs-only', '--no-fsdots') if exists $ENV{PERLBREW_ROOT} }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=11.6
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"PERLBREW_ROOT"} 0 0 0
157 0 ▶ method _build_known_hosts { $_ = `wc -l ~/.ssh/known_hosts | awk '{print \$1}'`; chomp; $_ }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
158 0 ▶ method _build_size {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=23.0
159  
160 0 $self->size(0);
161  
162 # useraccounts
163 # username_length
164 # shell
165 # harddrive_size
166 # uptime
167 # users
168 # cores
169 # using_multiplex
170 # using_byobu
171 # using_tmux
172 # using_screen
173 #
174 # perl_version
175 # perl_version_is_dev
176 # directories_in_path
177 # using_perlbrew
178 # using_cpanm
179 # using_cpanm_customized
180 # using_bash
181 # using_zsh
182 # using_ksh
183 # using_tcsh
184 # using_csh
185
186 # say for glob (dir($self->home_directory) . '/' . '.*');
187  
188 0 ▶ $self->add_size(10) if $self->using_zsh;
Branch: 1 branch
BranchTrueFalseTotal
if $self->using_zsh 0 0 0
189 0 ▶ $self->add_size(100) if $self->using_multiplex;
Branch: 1 branch
BranchTrueFalseTotal
if $self->using_multiplex 0 0 0
190  
191 0 $self->add_size( 100 * $self->cores );
192  
193 0 $self->sub_size( 10 * $self->username_length );
194  
195 0 $self->abs_size
196 1 }
197  
198 0 ▶ method testdrive {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=6.3
199 0 say "Your Acme Schlong size is: ", $self->size;
200 0 say "Your username is: ", $self->username;
201 0 say "Your home directory is: ", $self->home_directory;
202 0 say "The number of useraccounts is ", $self->useraccounts;
203 0 say "Your TERM is ", $self->term;
204 0 say "Your shell is ", $self->shell;
205 0 say "You are using byobu ", $self->using_byobu;
206 0 say "Your username length is ", $self->username_length;
207 0 say "You harddrive_size is ", $self->harddrive_size;
208 0 say "The number of cores is ", $self->cores;
209 0 say "Your perl version is ", $self->perl_version;
210 # say "Your perl version is a dev_release: ", $self->perl_version_is_dev;
211 0 say "You have this many dirs in PATH: ", $self->directories_in_path;
212 0 say "You are using a multiplexer: ", $self->using_multiplex;
213 0 say "You are using perlbrew: ", $self->using_perlbrew;
214 0 say "You are using zsh: ", $self->using_zsh;
215 0 say "You are using bash: ", $self->using_bash;
216 0 say "You are using cpanm: ", $self->using_cpanm;
217 0 say "You are using cpanm customized: ", $self->using_cpanm_customized;
218 0 say "You are using Dist::Zilla: ", $self->using_dzil;
219 0 say "You have this many perls installed ", $self->perls_installed;
220 0 say "Your PAUSE name is ", $self->pause_name;
221 0 say "Your number of known hosts is ", $self->known_hosts;
222 # say "Your number of modules released to the cpan is ", $self->cpan_modules;
223 1 }
224  
225 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
226  
227  
228 __END__
↑ Summary