| 1 | # -*- coding: utf-8 -*- | ||||||||||
| 2 | |||||||||||
| 3 | |||||||||||
| 4 | package Crane::Base; | ||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 5 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 5 | ▶ | use feature qw( :5.14 ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 5 | ▶ | use open qw( :std :utf8 ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 5 | ▶ | use base qw( Exporter ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 5 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 5 | ▶ | use English qw( -no_match_vars ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 5 | ▶ | use IO::Handle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 5 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 5 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | 5 | our @EXPORT = ( | |||||||||
| 22 | @Carp::EXPORT, | ||||||||||
| 23 | @English::EXPORT, | ||||||||||
| 24 | @Try::Tiny::EXPORT, | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | 18 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=4 SCAR=13.9
| |||||||||||
| 29 | |||||||||||
| 30 | 18 | my ( $class, @isa ) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 18 | my $caller = caller; | |||||||||
| 33 | |||||||||||
| 34 | 18 | strict->import(); | |||||||||
| 35 | 18 | warnings->import(); | |||||||||
| 36 | 18 | utf8->import(); | |||||||||
| 37 | 18 | feature->import(qw( :5.14 )); | |||||||||
| 38 | |||||||||||
| 39 | 18 | ▶ | if ( scalar @isa ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 13 | foreach my $isa ( @isa ) { | |||||||||
| 41 | 13 | ▶ | if ( eval "require $isa" ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 5 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 13 | push @{ "${caller}::ISA" }, $isa; | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 18 | $class->export_to_level(1, $caller); | |||||||||
| 49 | |||||||||||
| 50 | 18 | return; | |||||||||
| 51 | |||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | 5 | 1; | |||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | =head1 NAME | ||||||||||
| 59 | |||||||||||
| 60 | Crane::Base - Minimal base class for Crane projects | ||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | =head1 SYNOPSIS | ||||||||||
| 64 | |||||||||||
| 65 | use Crane::Base; | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | =head1 DESCRIPTION | ||||||||||
| 69 | |||||||||||
| 70 | Import this package is equivalent to: | ||||||||||
| 71 | |||||||||||
| 72 | use strict; | ||||||||||
| 73 | use warnings; | ||||||||||
| 74 | use utf8; | ||||||||||
| 75 | use feature qw( :5.14 ); | ||||||||||
| 76 | use open qw( :std :utf8 ); | ||||||||||
| 77 | |||||||||||
| 78 | use Carp; | ||||||||||
| 79 | use English qw( -no_match_vars ); | ||||||||||
| 80 | use IO::Handle; | ||||||||||
| 81 | use Readonly; | ||||||||||
| 82 | use Try::Tiny; | ||||||||||
| 83 | |||||||||||
| 84 | |||||||||||
| 85 | =head1 EXAMPLES | ||||||||||
| 86 | |||||||||||
| 87 | |||||||||||
| 88 | =head2 Script usage | ||||||||||
| 89 | |||||||||||
| 90 | use Crane::Base; | ||||||||||
| 91 | |||||||||||
| 92 | say 'Hello!' or confess($OS_ERROR); | ||||||||||
| 93 | |||||||||||
| 94 | |||||||||||
| 95 | =head2 Package usage | ||||||||||
| 96 | |||||||||||
| 97 | package Example; | ||||||||||
| 98 | |||||||||||
| 99 | use Crane::Base qw( Exporter ); | ||||||||||
| 100 | |||||||||||
| 101 | Readonly::Scalar(our $CONST => 'value'); | ||||||||||
| 102 | |||||||||||
| 103 | our @EXPORT = qw( | ||||||||||
| 104 | &example | ||||||||||
| 105 | $CONST | ||||||||||
| 106 | ); | ||||||||||
| 107 | |||||||||||
| 108 | sub example { | ||||||||||
| 109 | say 'This is an example!' or confess($OS_ERROR); | ||||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | 1; | ||||||||||
| 113 | |||||||||||
| 114 | |||||||||||
| 115 | =head1 BUGS | ||||||||||
| 116 | |||||||||||
| 117 | Please report any bugs or feature requests to | ||||||||||
| 118 | L<https://rt.cpan.org/Public/Bug/Report.html?Queue=Crane> or to | ||||||||||
| 119 | L<https://github.com/temoon/crane/issues>. | ||||||||||
| 120 | |||||||||||
| 121 | |||||||||||
| 122 | =head1 AUTHOR | ||||||||||
| 123 | |||||||||||
| 124 | Tema Novikov, <novikov.tema@gmail.com> | ||||||||||
| 125 | |||||||||||
| 126 | |||||||||||
| 127 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 128 | |||||||||||
| 129 | Copyright (C) 2013-2014 Tema Novikov. | ||||||||||
| 130 | |||||||||||
| 131 | This library is free software; you can redistribute it and/or modify it under | ||||||||||
| 132 | the terms of the Artistic License 2.0. For details, see the full text of the | ||||||||||
| 133 | license in the file LICENSE. | ||||||||||
| 134 | |||||||||||
| 135 | |||||||||||
| 136 | =head1 SEE ALSO | ||||||||||
| 137 | |||||||||||
| 138 | =over | ||||||||||
| 139 | |||||||||||
| 140 | =item * B<RT Cpan> | ||||||||||
| 141 | |||||||||||
| 142 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=Crane> | ||||||||||
| 143 | |||||||||||
| 144 | =item * B<Github> | ||||||||||
| 145 | |||||||||||
| 146 | L<https://github.com/temoon/crane> | ||||||||||
| 147 | |||||||||||
| 148 | =back | ||||||||||