| 1 | # Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved. | ||||||||||
| 2 | # This program is free software; you can redistribute it and/or modify | ||||||||||
| 3 | # it under the same terms as Perl itself. | ||||||||||
| 4 | |||||||||||
| 5 | package HTML::Mason::Component::FileBased; | ||||||||||
| 6 | 31 | $HTML::Mason::Component::FileBased::VERSION = '1.60'; | |||||||||
| 7 | 31 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 31 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 31 | ▶ | use File::Basename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 31 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 31 | ▶ | use HTML::Mason::Component; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 31 | ▶ | use base qw(HTML::Mason::Component); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 31 | ▶ | use HTML::Mason::Exceptions( abbr => ['error'] ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 31 | ▶ | use HTML::Mason::MethodMaker ( read_only => [ qw( path source_file name dir_path ) ] ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 7 | ▶ | sub is_file_based { 1 } | ||||||||
|
Subroutine
is_file_based: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 3 | ▶ | sub persistent { 1 } | ||||||||
|
Subroutine
persistent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 22 | 3 | ▶ | sub source_dir { | ||||||||
|
Subroutine
source_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 3 | my $dir = dirname($_[0]->source_file); | |||||||||
| 24 | 3 | return File::Spec->canonpath($dir); | |||||||||
| 25 | } | ||||||||||
| 26 | 177 | ▶ | sub title { | ||||||||
|
Subroutine
title: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 27 | 177 | my ($self) = @_; | |||||||||
| 28 | 177 | ▶ | return $self->path . ($self->{source_root_key} ? " [".lc($self->{source_root_key})."]" : ""); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | #return $self->path . ($self->{source_root_key} ? " [$self->{source_root_key}]" : ""); | ||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | # Ends up setting $self->{path, source_root_key, source_file} and a few in the parent class | ||||||||||
| 33 | 650 | ▶ | sub assign_runtime_properties { | ||||||||
|
Subroutine
assign_runtime_properties: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 34 | 650 | my ($self, $interp, $source) = @_; | |||||||||
| 35 | |||||||||||
| 36 | 650 | $self->{source_file} = $source->friendly_name; | |||||||||
| 37 | 650 | $self->{source_root_key} = $source->extra->{comp_root}; | |||||||||
| 38 | |||||||||||
| 39 | # We used to use File::Basename for this but that is broken | ||||||||||
| 40 | # because URL paths always use '/' as the dir-separator but we | ||||||||||
| 41 | # could be running on any OS. | ||||||||||
| 42 | # | ||||||||||
| 43 | # The regex itself is taken from File::Basename. | ||||||||||
| 44 | # | ||||||||||
| 45 | 650 | @{$self}{ 'dir_path', 'name'} = $source->comp_path =~ m,^(.*/)?(.*),s; | |||||||||
| 46 | 650 | ▶ | $self->{dir_path} =~ s,/$,, unless $self->{dir_path} eq '/'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 650 | $self->SUPER::assign_runtime_properties($interp, $source); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 31 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||