Chart-GGPlot

 view release on metacpan or  search on metacpan

lib/Chart/GGPlot/Setup.pm  view on Meta::CPAN

package Chart::GGPlot::Setup;

# ABSTRACT: Import stuffs into Chart::GGPlot classes

use 5.016;
use warnings;

our $VERSION = '0.002003'; # VERSION

use utf8;
use feature ':5.16';

use Import::Into;

use Data::Frame 0.006002;
use Data::Frame::Autobox ();

use Carp;
use Data::Dumper ();
use Function::Parameters 2.001003;
use Log::Any qw($log);
use Log::Any::Adapter;
use Safe::Isa 1.000010 ();
use PerlX::Maybe ();

use Feature::Compat::Try ();
use Module::Load;
use Moose 2.1400;
use Moose::Role               ();
use MooseX::MungeHas 0.011;
use MooseX::StrictConstructor ();
use boolean                   ();

use List::AllUtils qw(uniq);

# for debug
if (my $trace_level = $ENV{CHART_GGPLOT_TRACE} ) {
    load Log::Dispatch;
    load POSIX, qw(strftime);
    my $logger = Log::Dispatch->new(
        outputs => [
            [
                'Screen',
                min_level => 'debug',
                newline   => 1,
                stderr    => 1,
            ]
        ],
        callbacks => sub {
            my %params = @_;
            my $msg = $params{message};
            my $level = uc($params{level});
            return sprintf("%s [Chart::GGPlot $level] %s", strftime('%Y-%m-%d %H:%M:%S', localtime(time)), $msg);
        },
    );
    Log::Any::Adapter->set( { category => qr/^Chart::GGPlot/ },
        'Dispatch', dispatcher => $logger, );
}

sub import {
    my ( $class, @tags ) = @_;

    unless (@tags) {
        @tags = qw(:base);
    }
    $class->_import( scalar(caller), @tags );
}

sub _import {
    my ( $class, $target, @tags ) = @_;

    my @remove_module = @tags;
    for my $tag ( uniq @tags ) {
        $class->_import_tag( $target, $tag );
    }
}

sub _import_tag {
    my ( $class, $target, $tag ) = @_;

    if ( $tag eq ':base' ) {
        strict->import::into($target);
        warnings->import::into($target);
        utf8->import::into($target);
        feature->import::into( $target, ':5.16' );

        Carp->import::into($target);
        Data::Dumper->import::into($target);
        Function::Parameters->import::into($target);
        Log::Any->import::into( $target, '$log' );
        Safe::Isa->import::into($target);
        PerlX::Maybe->import::into($target);
        Feature::Compat::Try->import::into($target);
        boolean->import::into($target);

        Data::Frame::Autobox->import::into($target);
    }
    elsif ( $tag eq ':class' ) {
        $class->_import_tag( $target, ':base' );

        Function::Parameters->import::into( $target,
            qw(classmethod :modifiers) );

        Moose->import::into($target);
        MooseX::MungeHas->import::into($target);
        MooseX::StrictConstructor->import::into($target);
    }
    elsif ( $tag eq ':role' ) {
        $class->_import_tag( $target, ':base' );



( run in 1.366 second using v1.01-cache-2.11-cpan-39bf76dae61 )