| 1 | package Chart::GGPlot::Setup; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | # ABSTRACT: Import stuffs into Chart::GGPlot classes | ||||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | 29 | ▶ | use 5.016; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 29 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 29 | our $VERSION = '0.002003'; # VERSION | |||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 29 | ▶ | use utf8; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 29 | ▶ | use feature ':5.16'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 29 | ▶ | use Import::Into; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 14 | |||||||||||||||||||||||
| 15 | 29 | ▶ | use Data::Frame 0.006002; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 16 | 29 | ▶ | use Data::Frame::Autobox (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 17 | |||||||||||||||||||||||
| 18 | 29 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 19 | 29 | ▶ | use Data::Dumper (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 20 | 29 | ▶ | use Function::Parameters 2.001003; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 21 | 29 | ▶ | use Log::Any qw($log); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 22 | 29 | ▶ | use Log::Any::Adapter; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 23 | 29 | ▶ | use Safe::Isa 1.000010 (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 24 | 29 | ▶ | use PerlX::Maybe (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 25 | |||||||||||||||||||||||
| 26 | 29 | ▶ | use Feature::Compat::Try (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 27 | 29 | ▶ | use Module::Load; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 28 | 29 | ▶ | use Moose 2.1400; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 29 | 29 | ▶ | use Moose::Role (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 30 | 29 | ▶ | use MooseX::MungeHas 0.011; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 31 | 29 | ▶ | use MooseX::StrictConstructor (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 32 | 29 | ▶ | use boolean (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | 29 | ▶ | use List::AllUtils qw(uniq); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 35 | |||||||||||||||||||||||
| 36 | # for debug | ||||||||||||||||||||||
| 37 | 29 | ▶ | if (my $trace_level = $ENV{CHART_GGPLOT_TRACE} ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 38 | 0 | load Log::Dispatch; | |||||||||||||||||||||
| 39 | 0 | load POSIX, qw(strftime); | |||||||||||||||||||||
| 40 | my $logger = Log::Dispatch->new( | ||||||||||||||||||||||
| 41 | outputs => [ | ||||||||||||||||||||||
| 42 | [ | ||||||||||||||||||||||
| 43 | 'Screen', | ||||||||||||||||||||||
| 44 | min_level => 'debug', | ||||||||||||||||||||||
| 45 | newline => 1, | ||||||||||||||||||||||
| 46 | stderr => 1, | ||||||||||||||||||||||
| 47 | ] | ||||||||||||||||||||||
| 48 | ], | ||||||||||||||||||||||
| 49 | 0 | ▶ | callbacks => sub { | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 50 | 0 | my %params = @_; | |||||||||||||||||||||
| 51 | 0 | my $msg = $params{message}; | |||||||||||||||||||||
| 52 | 0 | my $level = uc($params{level}); | |||||||||||||||||||||
| 53 | 0 | return sprintf("%s [Chart::GGPlot $level] %s", strftime('%Y-%m-%d %H:%M:%S', localtime(time)), $msg); | |||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||
| 55 | 0 | ); | |||||||||||||||||||||
| 56 | 0 | Log::Any::Adapter->set( { category => qr/^Chart::GGPlot/ }, | |||||||||||||||||||||
| 57 | 'Dispatch', dispatcher => $logger, ); | ||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||
| 59 | |||||||||||||||||||||||
| 60 | 321 | ▶ | sub import { | ||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||
| 61 | 321 | my ( $class, @tags ) = @_; | |||||||||||||||||||||
| 62 | |||||||||||||||||||||||
| 63 | 321 | ▶ | unless (@tags) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 64 | 144 | @tags = qw(:base); | |||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||
| 66 | 321 | $class->_import( scalar(caller), @tags ); | |||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||
| 68 | |||||||||||||||||||||||
| 69 | 630 | ▶ | sub _import { | ||||||||||||||||||||
|
Subroutine
_import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||
| 70 | 630 | my ( $class, $target, @tags ) = @_; | |||||||||||||||||||||
| 71 | |||||||||||||||||||||||
| 72 | 630 | my @remove_module = @tags; | |||||||||||||||||||||
| 73 | 630 | for my $tag ( uniq @tags ) { | |||||||||||||||||||||
| 74 | 1006 | $class->_import_tag( $target, $tag ); | |||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||
| 77 | |||||||||||||||||||||||
| 78 | 1316 | ▶ | sub _import_tag { | ||||||||||||||||||||
|
Subroutine
_import_tag: called CC=5 SCAR=16.1
| |||||||||||||||||||||||
| 79 | 1316 | my ( $class, $target, $tag ) = @_; | |||||||||||||||||||||
| 80 | |||||||||||||||||||||||
| 81 | 1316 | ▶ | if ( $tag eq ':base' ) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 82 | 627 | strict->import::into($target); | |||||||||||||||||||||
| 83 | 627 | warnings->import::into($target); | |||||||||||||||||||||
| 84 | 627 | utf8->import::into($target); | |||||||||||||||||||||
| 85 | 627 | feature->import::into( $target, ':5.16' ); | |||||||||||||||||||||
| 86 | |||||||||||||||||||||||
| 87 | 627 | Carp->import::into($target); | |||||||||||||||||||||
| 88 | 627 | Data::Dumper->import::into($target); | |||||||||||||||||||||
| 89 | 627 | Function::Parameters->import::into($target); | |||||||||||||||||||||
| 90 | 627 | Log::Any->import::into( $target, '$log' ); | |||||||||||||||||||||
| 91 | 627 | Safe::Isa->import::into($target); | |||||||||||||||||||||
| 92 | 627 | PerlX::Maybe->import::into($target); | |||||||||||||||||||||
| 93 | 627 | Feature::Compat::Try->import::into($target); | |||||||||||||||||||||
| 94 | 627 | boolean->import::into($target); | |||||||||||||||||||||
| 95 | |||||||||||||||||||||||
| 96 | 627 | Data::Frame::Autobox->import::into($target); | |||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||
| 98 | elsif ( $tag eq ':class' ) { | ||||||||||||||||||||||
| 99 | 219 | $class->_import_tag( $target, ':base' ); | |||||||||||||||||||||
| 100 | |||||||||||||||||||||||
| 101 | 219 | Function::Parameters->import::into( $target, | |||||||||||||||||||||
| 102 | qw(classmethod :modifiers) ); | ||||||||||||||||||||||
| 103 | |||||||||||||||||||||||
| 104 | 219 | Moose->import::into($target); | |||||||||||||||||||||
| 105 | 219 | MooseX::MungeHas->import::into($target); | |||||||||||||||||||||
| 106 | 219 | MooseX::StrictConstructor->import::into($target); | |||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||
| 108 | elsif ( $tag eq ':role' ) { | ||||||||||||||||||||||
| 109 | 91 | $class->_import_tag( $target, ':base' ); | |||||||||||||||||||||
| 110 | |||||||||||||||||||||||
| 111 | 91 | Function::Parameters->import::into( $target, | |||||||||||||||||||||
| 112 | qw(classmethod :modifiers) ); | ||||||||||||||||||||||
| 113 | |||||||||||||||||||||||
| 114 | 91 | Moose::Role->import::into($target); | |||||||||||||||||||||
| 115 | 91 | MooseX::MungeHas->import::into($target); | |||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||
| 117 | elsif ( $tag eq ':pdl' ) { | ||||||||||||||||||||||
| 118 | 378 | require PDL::Lite; | |||||||||||||||||||||
| 119 | 378 | require PDL::Core; | |||||||||||||||||||||
| 120 | 378 | require PDL::SV; | |||||||||||||||||||||
| 121 | 378 | require PDL::Factor; | |||||||||||||||||||||
| 122 | 378 | require PDL::DateTime; | |||||||||||||||||||||
| 123 | 378 | require Role::Tiny; | |||||||||||||||||||||
| 124 | |||||||||||||||||||||||
| 125 | 378 | PDL::Lite->import::into($target); | |||||||||||||||||||||
| 126 | 378 | PDL::Core->import::into( $target, qw(pdl null) ); | |||||||||||||||||||||
| 127 | |||||||||||||||||||||||
| 128 | 378 | Role::Tiny->apply_roles_to_package( 'PDL', 'Data::Frame::PDL' ); | |||||||||||||||||||||
| 129 | |||||||||||||||||||||||
| 130 | # "use PDL::SV;" (or PDL::Factor) would import names like float, | ||||||||||||||||||||||
| 131 | # thus would pollute caller namespace and cause a warning with | ||||||||||||||||||||||
| 132 | # Test::V0. So we don't do PDL::SV->import::into | ||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||
| 135 | 1 | croak qq["$tag" is not exported by the $class module\n]; | |||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||
| 138 | |||||||||||||||||||||||
| 139 | # this is similar to what the "aliased" module does, but "aliased" | ||||||||||||||||||||||
| 140 | # does not work with Import::Into. | ||||||||||||||||||||||
| 141 | 0 | ▶ | sub _alias { | ||||||||||||||||||||
|
Subroutine
_alias: not called CC=1 SCAR=2.2
| |||||||||||||||||||||||
| 142 | 0 | my ( $class, $target, $from, $to ) = @_; | |||||||||||||||||||||
| 143 | |||||||||||||||||||||||
| 144 | 0 | $from->import::into($target); | |||||||||||||||||||||
| 145 | 29 | ▶ | no strict 'refs'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 146 | 0 | ▶ | *{"${target}::${to}"} = sub { $from }; | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||
| 148 | |||||||||||||||||||||||
| 149 | 29 | 1; | |||||||||||||||||||||
| 150 | |||||||||||||||||||||||
| 151 | __END__ | ||||||||||||||||||||||