Acme-Schlong
view release on metacpan or search on metacpan
lib/Acme/Schlong.pm view on Meta::CPAN
use App::OS::Detect::MachineCores;
use version;
use Carp;
use File::Util;
use MetaCPAN::API;
# Post-Construction phase.
method BUILD {
use Acme::Emoticarp;
o_O "Your system is Windows. I won't even bother calculating your schlong-size, sorry!" unless! ($^O ~~ /Win/ ... /Win/) # Just for fun (again)
}
sub true { 1 }
sub false { 0 }
# The all mighty, all elementary information!
has size => (
is => 'rw',
isa => Int,
traits => ['Number'],
handles => {
set_size => 'set',
add_size => 'add',
sub_size => 'sub',
mul_size => 'mul',
div_size => 'div',
mod_size => 'mod',
abs_size => 'abs',
},
required => 1,
lazy_build => 1,
documentation => q{The all might, all elementary information!},
);
has perl_specific => ( is => 'ro', isa => Bool, traits => ['Getopt'], cmd_aliases => ['P'], default => 0 );
has username => ( is => 'ro', isa => Str, traits => ['ENV'], env_key => 'user' );
has home_directory => ( is => 'ro', isa => Dir, traits => ['ENV'], env_key => 'home' );
has term => ( is => 'ro', isa => Str, traits => ['ENV'] );
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"} );
has username_length => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory} );
has shell => ( is => 'ro', isa => Str, lazy_build => 1, documentation => q{self explanatory} );
has harddrive_size => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory} );
has harddrive_used => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory} );
has uptime => ( is => 'ro', isa => Any, lazy_build => 1, documentation => q{self explanatory} );
has users => ( is => 'ro', isa => Any, lazy_build => 1, documentation => q{The number of users logged in on the system} );
has cores => ( is => 'ro', isa => Any, lazy_build => 1, documentation => q{The Number of cores of this machine} );
has using_multiplex => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using screen or tmux});
has using_byobu => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using byobu as multiplexer frontend!} );
has using_tmux => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using tmux as multiplexer} );
has using_screen => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{using screen as multiplexer} );
has perl_version => ( is => 'ro', isa => StrictVersionStr, lazy_build => 1, documentation => q{The executing Perl's version number});
has perl_version_is_dev => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{The executing Perl's version number});
has directories_in_path => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{The number of directories set in $PATH} );
has using_perlbrew => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_cpanm => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_cpanm_customized => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{Has the user set specific flags to cpanm?} );
has using_bash => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_zsh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_ksh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_tcsh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_csh => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has using_dzil => ( is => 'ro', isa => Bool, lazy_build => 1, documentation => q{self explanatory} );
has pause_name => ( is => 'ro', isa => Maybe[Str], lazy_build => 1, documentation => q{self explanatory});
has cpan_modules => ( is => 'ro', isa => Num, lazy_build => 1, documentation => q[self explanatory]);
has perls_installed => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{the number of perls installed through perlbrew} );
has known_hosts => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{self explanatory});
has f => ( is => 'ro', isa => 'File::Util', default => sub { File::Util->new } );
# has followers_on_github =>
# has number_of_rc_files => ~/.*rc
# has length of .vimrc
# has length of .emacs
# has number of files in ~/.emacs.d
# has using .ssh/config
# has rvm/rbenv installed
#
# has number_of_modules => ( is => 'ro', isa => Int, lazy_build => 1, documentation => q{} );
method _build_useraccounts { scalar grep { !/Shared/ } grep { -d $_ } glob ( dir( $self->home_directory => '..') . '/*'); } #TODO Make safer for WIN
method _build_username_length { length $self->username }
method _build_shell { $_ = $ENV{SHELL}; s/.*\/(.*?)$/$1/; $_ } # /r
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...
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...
method _build_uptime { 100 }
method _build_users { 5 }
method _build_cores { App::OS::Detect::MachineCores->new->cores }
method _build_using_multiplex { $self->using_byobu or $self->using_tmux or $self->using_screen ? true : false }
method _build_using_byobu { exists $ENV{BYOBU_BACKEND} ? 1 : 0 }
method _build_using_tmux { $ENV{TERM} ~~ 'tmux' ? 1 : 0 }
method _build_using_screen { $ENV{TERM} ~~ 'screen' ? 1 : 0 }
method _build_perl_version { $_ = `$^X --version`; m/perl.*\((?<vstring>v\d\.\d+.\d+)\) built for.*/; $+{vstring} }
# method _build_perl_version_is_dev { version->new($self->perl_version)->version->[1] % 2 ? 1 : 0 } # is_alpha
method _build_directories_in_path { scalar split q<:> => $ENV{PATH} }
method _build_using_perlbrew { (grep { /perlbrew/i } keys %ENV) ? 1 : 0 }
method _build_using_cpanm { (grep { /cpanm/i } keys %ENV) ? 1 : 0 }
method _build_using_cpanm_customized { !! (grep { /cpanm_opt/i } keys %ENV) || 0 } # TIMTOWDI just for fun
method _build_using_bash { $self->shell ~~ 'bash' || 0 }
method _build_using_zsh { $self->shell ~~ 'zsh' || 0 }
method _build_using_ksh { $self->shell ~~ 'ksh' || 0 }
method _build_using_tcsh { $self->shell ~~ 'tcsh' || 0 }
method _build_using_csh { $self->shell ~~ 'csh' || 0 }
method _build_using_dzil { (grep {/.dzil/} glob (dir($self->home_directory) . '/' . '.*')) ? 1 : 0 }
method _build_pause_name {
Config::Any->load_files( {
files => [ file($self->home_directory, '.dzil', 'config.ini') ],
flatten_to_hash => 1,
use_ext => 1 }
)->{file($self->home_directory, '.dzil', 'config.ini')}
->{'%PAUSE'}
->{'username'};
( run in 0.780 second using v1.01-cache-2.11-cpan-140bd7fdf52 )