App-CLI-Plugin-Config-YAML-Syck

 view release on metacpan or  search on metacpan

inc/Module/Install.pm  view on Meta::CPAN

333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
 
 
 
 
#####################################################################
# Common Utility Functions
 
sub _caller {
        my $depth = 0;
        my $call  = caller($depth);
        while ( $call eq __PACKAGE__ ) {
                $depth++;
                $call = caller($depth);
        }
        return $call;
}
 
sub _read {
        local *FH;
        if ( $] >= 5.006 ) {
                open( FH, '<', $_[0] ) or die "open($_[0]): $!";
        } else {
                open( FH, "< $_[0]"  ) or die "open($_[0]): $!";

inc/Module/Install/Makefile.pm  view on Meta::CPAN

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
}
 
sub Makefile { $_[0] }
 
my %seen = ();
 
sub prompt {
        shift;
 
        # Infinite loop protection
        my @c = caller();
        if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
                die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
        }
 
        # In automated testing, always use defaults
        if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
                local $ENV{PERL_MM_USE_DEFAULT} = 1;
                goto &ExtUtils::MakeMaker::prompt;
        } else {
                goto &ExtUtils::MakeMaker::prompt;

inc/Spiffy.pm  view on Meta::CPAN

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
our %EXPORT_TAGS = (XXX => [qw(WWW XXX YYY ZZZ)]);
 
my $stack_frame = 0;
my $dump = 'yaml';
my $bases_map = {};
 
sub WWW; sub XXX; sub YYY; sub ZZZ;
 
# This line is here to convince "autouse" into believing we are autousable.
sub can {
    ($_[1] eq 'import' and caller()->isa('autouse'))
        ? \&Exporter::import        # pacify autouse's equality test
        : $_[0]->SUPER::can($_[1])  # normal case
}
 
# TODO
#
# Exported functions like field and super should be hidden so as not to
# be confused with methods that can be inherited.
#

inc/Spiffy.pm  view on Meta::CPAN

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
    local *boolean_arguments = sub {
        qw(
            -base -Base -mixin -selfless
            -XXX -dumper -yaml
            -filter_dump -filter_save
        )
    };
    local *paired_arguments = sub { qw(-package) };
    $self_package->parse_arguments(@_);
};
return spiffy_mixin_import(scalar(caller(0)), $self_package, @export_list)
  if $args->{-mixin};
 
$filter_dump = 1 if $args->{-filter_dump};
$filter_save = 1 if $args->{-filter_save};
$dump = 'yaml' if $args->{-yaml};
$dump = 'dumper' if $args->{-dumper};
 
local @EXPORT_BASE = @EXPORT_BASE;
 
if ($args->{-XXX}) {
    push @EXPORT_BASE, @{$EXPORT_TAGS{XXX}}
      unless grep /^XXX$/, @EXPORT_BASE;
}
 
spiffy_filter()
  if ($args->{-selfless} or $args->{-Base}) and
     not $filtered_files->{(caller($stack_frame))[1]}++;
 
my $caller_package = $args->{-package} || caller($stack_frame);
push @{"$caller_package\::ISA"}, $self_package
  if $args->{-Base} or $args->{-base};
 
for my $class (@{all_my_bases($self_package)}) {
    next unless $class->isa('Spiffy');
    my @export = grep {
        not defined &{"$caller_package\::$_"};
    } ( @{"$class\::EXPORT"},
        ($args->{-Base} or $args->{-base})
          ? @{"$class\::EXPORT_BASE"} : (),

inc/Spiffy.pm  view on Meta::CPAN

319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
    return $1;
}
 
#===============================================================================
# It's super, man.
#===============================================================================
package DB;
{
    no warnings 'redefine';
    sub super_args {
        my @dummy = caller(@_ ? $_[0] : 2);
        return @DB::args;
    }
}
 
package Spiffy;
sub super {
    my $method;
    my $frame = 1;
    while ($method = (caller($frame++))[3]) {
        $method =~ s/.*::// and last;
    }
    my @args = DB::super_args($frame);
    @_ = @_ ? ($args[0], @_) : @args;
    my $class = ref $_[0] ? ref $_[0] : $_[0];
    my $caller_class = caller;
    my $seen = 0;
    my @super_classes = reverse grep {
        ($seen or $seen = ($_ eq $caller_class)) ? 0 : 1;
    } reverse @{all_my_bases($class)};

inc/Spiffy.pm  view on Meta::CPAN

370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
    require base unless defined $INC{'base.pm'};
    $INC{'mixin.pm'} ||= 'Spiffy/mixin.pm';
    $real_base_import = \&base::import;
    $real_mixin_import = \&mixin::import;
    no warnings;
    *base::import = \&spiffy_base_import;
    *mixin::import = \&spiffy_mixin_import;
}
 
# my $i = 0;
# while (my $caller = caller($i++)) {
#     next unless $caller eq 'base' or $caller eq 'mixin';
#     croak <<END;
# Spiffy.pm must be loaded before calling 'use base' or 'use mixin' with a
# Spiffy module. See the documentation of Spiffy.pm for details.
# END
# }
 
sub spiffy_base_import {
    my @base_classes = @_;
    shift @base_classes;
    no strict 'refs';
    goto &$real_base_import
      unless grep {
          eval "require $_" unless %{"$_\::"};
          $_->isa('Spiffy');
      } @base_classes;
    my $inheritor = caller(0);
    for my $base_class (@base_classes) {
        next if $inheritor->isa($base_class);
        croak "Can't mix Spiffy and non-Spiffy classes in 'use base'.\n",
              "See the documentation of Spiffy.pm for details\n  "
          unless $base_class->isa('Spiffy');
        $stack_frame = 1; # tell import to use different caller
        import($base_class, '-base');
        $stack_frame = 0;
    }
}
 
sub mixin {
    my $self = shift;
    my $target_class = ref($self);
    spiffy_mixin_import($target_class, @_)
}
 
sub spiffy_mixin_import {
    my $target_class = shift;
    $target_class = caller(0)
      if $target_class eq 'mixin';
    my $mixin_class = shift
      or die "Nothing to mixin";
    eval "require $mixin_class";
    my @roles = @_;
    my $pseudo_class = join '-', $target_class, $mixin_class, @roles;
    my %methods = spiffy_mixin_methods($mixin_class, @roles);
    no strict 'refs';
    no warnings;
    @{"$pseudo_class\::ISA"} = @{"$target_class\::ISA"};

inc/Spiffy.pm  view on Meta::CPAN

502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
        $Data::Dumper::Sortkeys = 1;
        $Data::Dumper::Indent = 1;
        return Data::Dumper::Dumper(@_);
    }
    require YAML;
    $YAML::UseVersion = 0;
    return YAML::Dump(@_) . "...\n";
}
 
sub at_line_number {
    my ($file_path, $line_number) = (caller(1))[1,2];
    "  at $file_path line $line_number\n";
}
 
sub WWW {
    warn spiffy_dump(@_) . at_line_number;
    return wantarray ? @_ : $_[0];
}
 
sub XXX {
    die spiffy_dump(@_) . at_line_number;

inc/Test/Base.pm  view on Meta::CPAN

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
    return $class if $class->can('new');
    $class = __PACKAGE__ . "::$suffix";
    return $class if $class->can('new');
    eval "require $class";
    return $class if $class->can('new');
    die "Can't find a class for $suffix";
}
 
sub check_late {
    if ($self->{block_list}) {
        my $caller = (caller(1))[3];
        $caller =~ s/.*:://;
        croak "Too late to call $caller()"
    }
}
 
sub find_my_self() {
    my $self = ref($_[0]) eq $default_class
    ? splice(@_, 0, 1)
    : default_object();
    return $self, @_;
}

inc/Test/Base/Filter.pm  view on Meta::CPAN

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    return undef unless defined $arguments;
    my $args = $arguments;
    $args =~ s/(\\s)/ /g;
    $args =~ s/(\\[a-z])/'"' . $1 . '"'/gee;
    return $args;
}
 
sub assert_scalar {
    return if @_ == 1;
    require Carp;
    my $filter = (caller(1))[3];
    $filter =~ s/.*:://;
    Carp::croak "Input to the '$filter' filter must be a scalar, not a list";
}
 
sub _apply_deepest {
    my $method = shift;
    return () unless @_;
    if (ref $_[0] eq 'ARRAY') {
        for my $aref (@_) {
            @$aref = $self->_apply_deepest($method, @$aref);

inc/Test/Builder.pm  view on Meta::CPAN

602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
    %s
        %s
    %s
DIAGNOSTIC
}
 
 
sub _caller_context {
    my $self = shift;
 
    my($pack, $file, $line) = $self->caller(1);
 
    my $code = '';
    $code .= "#line $line $file\n" if defined $file and defined $line;
 
    return $code;
}
 
 
#line 860

inc/Test/Builder.pm  view on Meta::CPAN

954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
sub details {
    my $self = shift;
    return @{ $self->{Test_Results} };
}
 
#line 1473
 
sub todo {
    my($self, $pack) = @_;
 
    $pack = $pack || $self->exported_to || $self->caller($Level);
    return 0 unless $pack;
 
    no strict 'refs';
    return defined ${$pack.'::TODO'} ? ${$pack.'::TODO'}
                                     : 0;
}
 
#line 1494
 
sub caller {
    my($self, $height) = @_;
    $height ||= 0;
 
    my @caller = CORE::caller($self->level + $height + 1);
    return wantarray ? @caller : $caller[0];
}
 
#line 1506
 
#line 1520
 
#'#
sub _sanity_check {
    my $self = shift;

inc/Test/Builder.pm  view on Meta::CPAN

1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
 
#line 1575
 
$SIG{__DIE__} = sub {
    # We don't want to muck with death in an eval, but $^S isn't
    # totally reliable.  5.005_03 and 5.6.1 both do the wrong thing
    # with it.  Instead, we use caller.  This also means it runs under
    # 5.004!
    my $in_eval = 0;
    for( my $stack = 1;  my $sub = (CORE::caller($stack))[3];  $stack++ ) {
        $in_eval = 1 if $sub =~ /^\(eval\)/;
    }
    $Test->{Test_Died} = 1 unless $in_eval;
};
 
sub _ending {
    my $self = shift;
 
    $self->_sanity_check();

inc/Test/Builder/Module.pm  view on Meta::CPAN

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$VERSION = '0.02';
 
use strict;
 
# 5.004's Exporter doesn't have export_to_level.
my $_export_to_level = sub {
      my $pkg = shift;
      my $level = shift;
      (undef) = shift;                  # redundant arg
      my $callpkg = caller($level);
      $pkg->export($callpkg, @_);
};
 
 
#line 82
 
sub import {
    my($class) = shift;
 
    my $test = $class->builder;

inc/Test/More.pm  view on Meta::CPAN

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use 5.004;
 
use strict;
 
 
# Can't use Carp because it might cause use_ok() to accidentally succeed
# even though the module being used forgot to use Carp.  Yes, this
# actually happened.
sub _carp {
    my($file, $line) = (caller(1))[1,2];
    warn @_, " at $file line $line\n";
}
 
 
 
use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);
$VERSION = '0.62';
$VERSION = eval $VERSION;    # make the alpha version come out as a number
 



( run in 0.306 second using v1.01-cache-2.11-cpan-cba739cd03b )