line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Starch::Util; |
2
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=encoding utf8 |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Starch::Util - Utility functions used internally by Starch. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
14
|
|
|
14
|
|
221978
|
use Carp qw(); |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
366
|
|
13
|
14
|
|
|
14
|
|
5787
|
use Module::Find qw( findallmod ); |
|
14
|
|
|
|
|
17166
|
|
|
14
|
|
|
|
|
830
|
|
14
|
14
|
|
|
14
|
|
557
|
use Module::Runtime qw( require_module is_module_name ); |
|
14
|
|
|
|
|
1706
|
|
|
14
|
|
|
|
|
89
|
|
15
|
|
|
|
|
|
|
|
16
|
14
|
|
|
14
|
|
755
|
use strictures 2; |
|
14
|
|
|
|
|
126
|
|
|
14
|
|
|
|
|
543
|
|
17
|
14
|
|
|
14
|
|
8683
|
use namespace::clean; |
|
14
|
|
|
|
|
151509
|
|
|
14
|
|
|
|
|
88
|
|
18
|
|
|
|
|
|
|
|
19
|
14
|
|
|
14
|
|
3565
|
use Exporter qw( import ); |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
2830
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 FUNCTIONS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 croak |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This is a custom L C function which finds and sets |
27
|
|
|
|
|
|
|
all installed C and C modules as internal to |
28
|
|
|
|
|
|
|
Carp so that Carp looks deeper in the stack for something to blame |
29
|
|
|
|
|
|
|
which makes exceptions be more contextually useful for users of |
30
|
|
|
|
|
|
|
Starch and means we don't need to use confess which generates giant |
31
|
|
|
|
|
|
|
stack traces. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $all_modules; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
push @EXPORT_OK, 'croak'; |
38
|
|
|
|
|
|
|
sub croak { |
39
|
9
|
|
50
|
9
|
1
|
129
|
$all_modules ||= [ |
40
|
|
|
|
|
|
|
'Starch', findallmod('Starch'), |
41
|
|
|
|
|
|
|
'Test::Starch', findallmod('Test::Starch'), |
42
|
|
|
|
|
|
|
]; |
43
|
9
|
|
|
|
|
124983
|
local @Carp::Internal{@$all_modules} = map { 1 } @$all_modules; |
|
252
|
|
|
|
|
561
|
|
44
|
9
|
|
|
|
|
1958
|
return Carp::croak( @_ ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 load_prefixed_module |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# These both return "Foo::Bar". |
50
|
|
|
|
|
|
|
my $module = load_prefixed_module( 'Foo', '::Bar' ); |
51
|
|
|
|
|
|
|
my $module = load_prefixed_module( 'Foo', 'Foo::Bar' ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Takes a prefix to be appended to a relative package name and a |
54
|
|
|
|
|
|
|
relative or absolute package name. It then resolves the relative |
55
|
|
|
|
|
|
|
package name to an absolute one, loads it, and returns the |
56
|
|
|
|
|
|
|
absolute name. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
push @EXPORT_OK, 'load_prefixed_module'; |
61
|
|
|
|
|
|
|
sub load_prefixed_module { |
62
|
234
|
|
|
234
|
1
|
16687
|
my ($prefix, $module) = @_; |
63
|
|
|
|
|
|
|
|
64
|
234
|
100
|
|
|
|
1086
|
$module = "$prefix$module" if $module =~ m{^::}; |
65
|
|
|
|
|
|
|
|
66
|
234
|
|
|
|
|
827
|
require_module( $module ); |
67
|
|
|
|
|
|
|
|
68
|
233
|
|
|
|
|
5431
|
return $module; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |