| 1 | package Pod::HTMLEmbed; | ||||||||||
| 2 | 4 | ▶ | use Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 4 | our $VERSION = '0.04'; | |||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use Carp::Clan '^(Mo[ou]se::|Pod::HTMLEmbed(::)?)'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Pod::Simple::Search; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use Pod::HTMLEmbed::Entry; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 4 | has search_dir => ( | |||||||||
| 11 | is => 'rw', | ||||||||||
| 12 | isa => 'ArrayRef', | ||||||||||
| 13 | predicate => 'has_search_dir', | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 4 | has url_prefix => ( | |||||||||
| 17 | is => 'rw', | ||||||||||
| 18 | isa => 'Str', | ||||||||||
| 19 | predicate => 'has_url_prefix', | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 4 | ▶ | no Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | sub load { | ||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 25 | 3 | my ($self, $file) = @_; | |||||||||
| 26 | 3 | Pod::HTMLEmbed::Entry->new( file => $file, _context => $self ); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 2 | ▶ | sub find { | ||||||||
|
Subroutine
find: called CC=4 SCAR=16.5
Pod
documented
| |||||||||||
| 30 | 2 | my ($self, $name) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 2 | my $file; | |||||||||
| 33 | 2 | my $finder = Pod::Simple::Search->new; | |||||||||
| 34 | |||||||||||
| 35 | 2 | ▶ | if ($self->has_search_dir) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 2 | $finder->inc(0); | |||||||||
| 37 | 2 | $file = $finder->find( $name, @{ $self->search_dir } ); | |||||||||
| 38 | } | ||||||||||
| 39 | else { | ||||||||||
| 40 | 0 | $file = $finder->find( $name ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 2 | ▶ | unless ($file) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | my $dirs = join ':', $self->has_search_dir ? | ||||||||||
| 45 | 0 | ▶ | (@{ $self->search_dir }) : (@INC); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | |||||||||||
| 47 | 0 | croak qq[No pod found by name "$name" in $dirs]; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 2 | $self->load($file); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||