line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Starch::Util; |
2
|
14
|
|
|
14
|
|
210794
|
use 5.008001; |
|
14
|
|
|
|
|
71
|
|
3
|
14
|
|
|
14
|
|
90
|
use strictures 2; |
|
14
|
|
|
|
|
113
|
|
|
14
|
|
|
|
|
594
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Starch::Util - Utility functions used internally by Starch. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
14
|
|
|
14
|
|
3210
|
use Carp qw(); |
|
14
|
|
|
|
|
41
|
|
|
14
|
|
|
|
|
398
|
|
13
|
14
|
|
|
14
|
|
575
|
use Module::Runtime qw( require_module is_module_name ); |
|
14
|
|
|
|
|
2142
|
|
|
14
|
|
|
|
|
110
|
|
14
|
14
|
|
|
14
|
|
7229
|
use Module::Find qw( findallmod ); |
|
14
|
|
|
|
|
18983
|
|
|
14
|
|
|
|
|
912
|
|
15
|
|
|
|
|
|
|
|
16
|
14
|
|
|
14
|
|
6356
|
use namespace::clean; |
|
14
|
|
|
|
|
162548
|
|
|
14
|
|
|
|
|
92
|
|
17
|
|
|
|
|
|
|
|
18
|
14
|
|
|
14
|
|
3786
|
use Exporter qw( import ); |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
2939
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 FUNCTIONS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 croak |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This is a custom L C function which finds and sets |
26
|
|
|
|
|
|
|
all installed C and C modules as internal to |
27
|
|
|
|
|
|
|
Carp so that Carp looks deeper in the stack for something to blame |
28
|
|
|
|
|
|
|
which makes exceptions be more contextually useful for users of |
29
|
|
|
|
|
|
|
Starch and means we don't need to use confess which generates giant |
30
|
|
|
|
|
|
|
stack traces. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $all_modules; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
push @EXPORT_OK, 'croak'; |
37
|
|
|
|
|
|
|
sub croak { |
38
|
9
|
|
50
|
9
|
1
|
114
|
$all_modules ||= [ |
39
|
|
|
|
|
|
|
'Starch', findallmod('Starch'), |
40
|
|
|
|
|
|
|
'Test::Starch', findallmod('Test::Starch'), |
41
|
|
|
|
|
|
|
]; |
42
|
9
|
|
|
|
|
126691
|
local @Carp::Internal{@$all_modules} = map { 1 } @$all_modules; |
|
252
|
|
|
|
|
572
|
|
43
|
9
|
|
|
|
|
1937
|
return Carp::croak( @_ ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 load_prefixed_module |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# These both return "Foo::Bar". |
49
|
|
|
|
|
|
|
my $module = load_prefixed_module( 'Foo', '::Bar' ); |
50
|
|
|
|
|
|
|
my $module = load_prefixed_module( 'Foo', 'Foo::Bar' ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Takes a prefix to be appended to a relative package name and a |
53
|
|
|
|
|
|
|
relative or absolute package name. It then resolves the relative |
54
|
|
|
|
|
|
|
package name to an absolute one, loads it, and returns the |
55
|
|
|
|
|
|
|
absolute name. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
push @EXPORT_OK, 'load_prefixed_module'; |
60
|
|
|
|
|
|
|
sub load_prefixed_module { |
61
|
234
|
|
|
234
|
1
|
16589
|
my ($prefix, $module) = @_; |
62
|
|
|
|
|
|
|
|
63
|
234
|
100
|
|
|
|
1113
|
$module = "$prefix$module" if $module =~ m{^::}; |
64
|
|
|
|
|
|
|
|
65
|
234
|
|
|
|
|
859
|
require_module( $module ); |
66
|
|
|
|
|
|
|
|
67
|
233
|
|
|
|
|
5677
|
return $module; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |