Acme-Schlong

 view release on metacpan or  search on metacpan

lib/Acme/Schlong.pm  view on Meta::CPAN

        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'};
    }
    method _build_cpan_modules  { scalar MetaCPAN::API->new->release(search => {author => $self->pause_name, filter => "distribution", fields=>"name"})->{hits}->{hits} }
    method _build_perls_installed { $_ =()= $self->f->list_dir("$ENV{PERLBREW_ROOT}/perls", '--dirs-only', '--no-fsdots') if exists $ENV{PERLBREW_ROOT} }
    method _build_known_hosts { $_ = `wc -l ~/.ssh/known_hosts | awk '{print \$1}'`; chomp; $_ }
    method _build_size {

        $self->size(0);

        # useraccounts
        # username_length
        # shell
        # harddrive_size
        # uptime
        # users
        # cores
        # using_multiplex
        # using_byobu
        # using_tmux
        # using_screen
        #
        # perl_version
        # perl_version_is_dev
        # directories_in_path
        # using_perlbrew
        # using_cpanm
        # using_cpanm_customized
        # using_bash
        # using_zsh
        # using_ksh
        # using_tcsh
        # using_csh
        



( run in 1.188 second using v1.01-cache-2.11-cpan-e1769b4cff6 )