| 1 | package FFI::Platypus::ShareConfig; | ||||||||||
| 2 | |||||||||||
| 3 | 63 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 63 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 63 | ▶ | use 5.008004; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 63 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 63 | our $VERSION = '2.12'; # VERSION | |||||||||
| 9 | |||||||||||
| 10 | sub dist_dir ($) | ||||||||||
| 11 | 601 | ▶ | { | ||||||||
|
Subroutine
dist_dir: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 12 | 601 | my($dist_name) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 601 | my @pm = split /-/, $dist_name; | |||||||||
| 15 | 601 | $pm[-1] .= ".pm"; | |||||||||
| 16 | |||||||||||
| 17 | 601 | foreach my $inc (@INC) | |||||||||
| 18 | { | ||||||||||
| 19 | 1208 | ▶ | if(-f File::Spec->catfile($inc, @pm)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | { | ||||||||||
| 21 | 601 | my $share = File::Spec->catdir($inc, qw( auto share dist ), $dist_name ); | |||||||||
| 22 | 601 | ▶ | if(-d $share) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | { | ||||||||||
| 24 | 565 | return File::Spec->rel2abs($share); | |||||||||
| 25 | } | ||||||||||
| 26 | 36 | last; | |||||||||
| 27 | } | ||||||||||
| 28 | } | ||||||||||
| 29 | 36 | Carp::croak("unable to find dist share directory for $dist_name"); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub get | ||||||||||
| 33 | 524 | ▶ | { | ||||||||
|
Subroutine
get: called CC=7 SCAR=24.0
Pod
undocumented
| |||||||||||
| 34 | 524 | my(undef, $name) = @_; | |||||||||
| 35 | 524 | my $config; | |||||||||
| 36 | |||||||||||
| 37 | 524 | ▶ | unless($config) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | { | ||||||||||
| 39 | 524 | my $fn = File::Spec->catfile(dist_dir('FFI-Platypus'), 'config.pl'); | |||||||||
| 40 | 524 | ▶ | $fn = File::Spec->rel2abs($fn) unless File::Spec->file_name_is_absolute($fn); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 524 | local $@; | |||||||||
| 42 | 524 | ▶ | unless($config = do $fn) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | { | ||||||||||
| 44 | 0 | ▶ | die "couldn't parse configuration $fn $@" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | ▶ | die "couldn't do $fn $!" if $!; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | die "bad or missing config file $fn"; | |||||||||
| 47 | }; | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 524 | ▶ | defined $name ? $config->{$name} : $config; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 63 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||