| 1 | package YATT::Lite::Factory; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 45 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 45 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 45 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 45 | ▶ | use YATT::Lite::Breakpoint; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||
| 7 | 45 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 45 | ▶ | use constant DEBUG_FACTORY => $ENV{DEBUG_YATT_FACTORY}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 45 | ▶ | use constant DEBUG_REFCNT => $ENV{DEBUG_YATT_REFCNT}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 45 | ▶ | use if DEBUG_REFCNT, B => qw/svref_2object/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 45 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 45 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 45 | ▶ | use Encode qw/decode/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 45 | ▶ | use parent qw/File::Spec YATT::Lite::Site YATT::Lite::NSBuilder/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 45 | ▶ | use File::Path (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 45 | ▶ | use File::Basename qw/dirname/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 45 | ▶ | use YATT::Lite::PSGIEnv; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | # Subclass may override this to 0 to revert old behavior. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | ▶ | sub use_sibling_config_dir { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_sibling_config_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # Note: Definition of default values are not yet gathered here. | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # Some are in YATT::Lite, others are in YATT::Lite::Core, CGen.. and so on. | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | use YATT::Lite::MFields | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 45 | ▶ | ([namespace => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | (doc => "namespace prefix for yatt. (default: [yatt, perl])")] | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | , ["^doc_root" => | ||||||||||||||||||||||||||||||||||||||||||
| 38 | (doc => "Primary template directory")] | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # Note: Don't confuse 'app_rootname' below with 'app_root'. | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # 'app_root' is defined in YATT::Lite::Partial::AppPath. | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||||||||||||
| 43 | , [app_rootname => | ||||||||||||||||||||||||||||||||||||||||||
| 44 | (doc => "rootname() of app.psgi. Used to find app.site_config.yml")] | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | , ["^app_base" => | ||||||||||||||||||||||||||||||||||||||||||
| 47 | (doc => "Base template dir for all DirApps")] | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | , ["^site_prefix" => | ||||||||||||||||||||||||||||||||||||||||||
| 50 | (doc => "Location prefix for this siteapp")] | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | , [index_name => | ||||||||||||||||||||||||||||||||||||||||||
| 53 | (doc => "Rootname of index template. (default: index)")] | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | , [ext_public => | ||||||||||||||||||||||||||||||||||||||||||
| 56 | (doc => "public file extension for yatt. (default: yatt)")] | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | , [ext_private => | ||||||||||||||||||||||||||||||||||||||||||
| 59 | (doc => "hidden file extension for yatt. (default: ytmpl)")] | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | , [header_charset => | ||||||||||||||||||||||||||||||||||||||||||
| 62 | (doc => "Charset for outgoing HTTP Content-Type. (default: utf-8)")] | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | , [tmpl_encoding => | ||||||||||||||||||||||||||||||||||||||||||
| 65 | (doc => "Perl encoding used while reading yatt templates. (default: 'utf-8')")] | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | , [output_encoding => | ||||||||||||||||||||||||||||||||||||||||||
| 68 | (doc => "Perl encoding used for outgoing response body." | ||||||||||||||||||||||||||||||||||||||||||
| 69 | ." Also this is used to decode incoming request parameters and PATH_INFO." | ||||||||||||||||||||||||||||||||||||||||||
| 70 | ." (default: 'utf-8')")] | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | , [render_as_bytes => | ||||||||||||||||||||||||||||||||||||||||||
| 73 | (doc => "Force render() to return raw bytes. (default: false)")] | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | , ["^offline" => | ||||||||||||||||||||||||||||||||||||||||||
| 76 | (doc => "Whether header should be emitted or not.")] | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | , [binary_config => | ||||||||||||||||||||||||||||||||||||||||||
| 79 | (doc => "(This may be changed in future release) Whether .htyattconfig.* should be read with encoding or not.")] | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | , [no_unicode => | ||||||||||||||||||||||||||||||||||||||||||
| 82 | (doc => "(Compatibility option) Avoid use of utf8.")] | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | , [no_unicode_params => | ||||||||||||||||||||||||||||||||||||||||||
| 85 | (doc => "(Compatibility option) Avoid encoding conversion of input params.")] | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | , [use_subpath => | ||||||||||||||||||||||||||||||||||||||||||
| 88 | (doc => "pass sub-path_info")] | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | , qw/ | ||||||||||||||||||||||||||||||||||||||||||
| 91 | allow_missing_dir | ||||||||||||||||||||||||||||||||||||||||||
| 92 | no_preload_app_base | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | _tmpldirs | ||||||||||||||||||||||||||||||||||||||||||
| 95 | _loc2yatt | ||||||||||||||||||||||||||||||||||||||||||
| 96 | _path2yatt | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | _loc2psgi_re | ||||||||||||||||||||||||||||||||||||||||||
| 99 | _loc2psgi_dict | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | _tmpl_cache | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | _path2entns | ||||||||||||||||||||||||||||||||||||||||||
| 104 | _entns2vfs_item | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | debug_cgen | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | only_parse | ||||||||||||||||||||||||||||||||||||||||||
| 109 | config_filetypes | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | dont_map_args | ||||||||||||||||||||||||||||||||||||||||||
| 112 | dont_debug_param | ||||||||||||||||||||||||||||||||||||||||||
| 113 | always_refresh_deps | ||||||||||||||||||||||||||||||||||||||||||
| 114 | no_mro_c3 | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | special_entities | ||||||||||||||||||||||||||||||||||||||||||
| 117 | default_lang | ||||||||||||||||||||||||||||||||||||||||||
| 118 | no_lineinfo | ||||||||||||||||||||||||||||||||||||||||||
| 119 | debug_parser | ||||||||||||||||||||||||||||||||||||||||||
| 120 | check_lineno | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | _outer_psgi_app | ||||||||||||||||||||||||||||||||||||||||||
| 123 | _my_psgi_app | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | match_argsroute_first | ||||||||||||||||||||||||||||||||||||||||||
| 126 | allow_bare_entity_in_decl | ||||||||||||||||||||||||||||||||||||||||||
| 127 | no_chdir | ||||||||||||||||||||||||||||||||||||||||||
| 128 | / | ||||||||||||||||||||||||||||||||||||||||||
| 129 | , [stash_unknown_params_to => | ||||||||||||||||||||||||||||||||||||||||||
| 130 | (doc => "Stash unknown foreign parameters into this name. Set to 'yatt.unknown_params' when PLACK_ENV is *not* development.")] | ||||||||||||||||||||||||||||||||||||||||||
| 131 | , [body_argument => | ||||||||||||||||||||||||||||||||||||||||||
| 132 | (doc => "Name of 'body' argument. (default: body)")] | ||||||||||||||||||||||||||||||||||||||||||
| 133 | , [body_argument_type => | ||||||||||||||||||||||||||||||||||||||||||
| 134 | (doc => "Type of 'body' argument. (default: code)")] | ||||||||||||||||||||||||||||||||||||||||||
| 135 | , [prefer_call_for_entity => | ||||||||||||||||||||||||||||||||||||||||||
| 136 | (doc => ":name is interpreted as call if appropriate")] | ||||||||||||||||||||||||||||||||||||||||||
| 137 | , [no_conditional_call => | ||||||||||||||||||||||||||||||||||||||||||
| 138 | (doc => "Disable conditional call (if=/unless= in widget call arguments)")] | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 45 | ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 45 | ▶ | use YATT::Lite::Util::AsBase qw/-as_base import/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 45 | ▶ | use YATT::Lite::Util qw/lexpand globref untaint_any ckrequire dofile_in | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | lookup_dir fields_hash | ||||||||||||||||||||||||||||||||||||||||||
| 144 | lookup_path | ||||||||||||||||||||||||||||||||||||||||||
| 145 | trim_ext | ||||||||||||||||||||||||||||||||||||||||||
| 146 | secure_text_plain | ||||||||||||||||||||||||||||||||||||||||||
| 147 | psgi_error | ||||||||||||||||||||||||||||||||||||||||||
| 148 | psgi_text | ||||||||||||||||||||||||||||||||||||||||||
| 149 | globref_default | ||||||||||||||||||||||||||||||||||||||||||
| 150 | define_const | ||||||||||||||||||||||||||||||||||||||||||
| 151 | terse_dump | ||||||||||||||||||||||||||||||||||||||||||
| 152 | psgi_dump | ||||||||||||||||||||||||||||||||||||||||||
| 153 | raise_psgi_dump | ||||||||||||||||||||||||||||||||||||||||||
| 154 | raise_response | ||||||||||||||||||||||||||||||||||||||||||
| 155 | trimleft_length | ||||||||||||||||||||||||||||||||||||||||||
| 156 | get_entity_symbol | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 45 | /; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 45 | ▶ | use YATT::Lite::XHF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 45 | ▶ | use YATT::Lite::Partial::ErrorReporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 45 | ▶ | use YATT::Lite::Partial::AppPath; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 45 | ▶ | use YATT::Lite qw/Entity *SYS *YATT *CON/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 45 | our @EXPORT_OK = qw/*CON/; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 45 | ▶ | use YATT::Lite::Util::CycleDetector qw/Visits/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 45 | our $want_object; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | ▶ | sub want_object { $want_object } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | sub find_load_factory_script { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_load_factory_script: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | my ($pack, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 179 | my ($found) = $pack->find_factory_script(delete $opts{dir}) | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | my $self = $pack->load_factory_script($found) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | or croak "Can't load YATT::Lite::Factory instance from $found"; | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | $self->configure(%opts); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub load_factory_offline { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_factory_offline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | shift->find_load_factory_script(offline => 1, @_); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 22 | ▶ | sub configure_offline { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_offline: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 22 | (my MY $self, my $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 22 | $self->{offline} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 22 | ▶ | if ($self->{offline}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 9 | ▶ | $self->configure(error_handler => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 9 | my ($type, $err) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 9 | die $err; | |||||||||||||||||||||||||||||||||||||||||
| 198 | }) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 22 | } | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | # | ||||||||||||||||||||||||||||||||||||||||||
| 205 | # $class->create_factory_class($fresh_classname) | ||||||||||||||||||||||||||||||||||||||||||
| 206 | # Make $fresh_classname inherit Factory. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | # Mainly for tests which create many factory classes in single run. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | # | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 8 | ▶ | sub create_factory_class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_factory_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 8 | my ($pack, $factory_class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 8 | define_const(globref($factory_class, 'default_app_ns') | |||||||||||||||||||||||||||||||||||||||||
| 213 | , $factory_class."::YATT"); | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | $pack->_import_as_base($factory_class); | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 8 | $factory_class; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 13 | ▶ | sub load_factory_for_psgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_factory_for_psgi: called CC=14 SCAR=30.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 13 | my ($pack, $psgi, %default) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 13 | ▶ | unless (defined $psgi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | croak "Usage: Factory->load_factory_for_psgi(psgi_filename, \%opts)"; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 13 | ▶ | unless (-r $psgi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | croak "psgi is not readable: $psgi"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # GH-260: rel2abs does not collapse "..". Without normalization, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | # "$app_root.config.d" built from ".../t/.." can never exist. | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 13 | (my $app_rootname = YATT::Lite::Util::normalize_fs_path($pack->rel2abs($psgi))) | |||||||||||||||||||||||||||||||||||||||||
| 231 | =~ s/\.psgi$//; | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 13 | ▶ | $default{app_rootname} //= $app_rootname; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$default{"app_rootname"} //= $app_rootname
MC/DC0%0/2
$default{"app_rootname"} //= $app_rootname
$default{"app_rootname"}
$app_rootname
Truth table33%1/3
A //= B
A= $default{"app_rootname"}B= $app_rootname
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | # | ||||||||||||||||||||||||||||||||||||||||||
| 236 | # Assume app_root is safe. | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 13 | my $app_root = untaint_any(dirname($app_rootname)); | |||||||||||||||||||||||||||||||||||||||||
| 239 | 13 | ▶ | unless (-d $app_root) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | croak "Can't find app_root for $psgi"; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 13 | ▶ | $default{doc_root} ||= "$app_root/html"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$default{"doc_root"} ||= "$app_root/html"
MC/DC100%1/1
$default{"doc_root"} ||= "$app_root/html"
$default{"doc_root"}
Truth table100%2/2
A
A= $default{"doc_root"}
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 13 | ▶ | if (-d "$app_root/ytmpl") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | $default{app_base} ||= '@ytmpl'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$default{"app_base"} ||= "\@ytmpl"
MC/DC0%0/1
$default{"app_base"} ||= "\@ytmpl"
$default{"app_base"}
Truth table0%0/2
A
A= $default{"app_base"}
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 13 | my $env = delete $default{environment}; | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 13 | my (@cf) = $pack->list_app_config_files($app_root, File::Basename::basename($app_rootname)); | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 13 | ▶ | if (@cf and $env) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
@cf and $env
MC/DC0%0/2
@cf and $env
@cf
$env
Truth table66%2/3
A and B
A= @cfB= $env
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | croak "Can't use environment and @cf at once!"; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } elsif (@cf > 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | croak "Multiple configuration files!: @cf"; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 13 | ▶ | if ($env) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | my $config = $pack->config_for_env($app_root, $env); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | ▶ | return $pack->_with_loading_file($config, sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | $pack->new(app_root => $app_root, %default | |||||||||||||||||||||||||||||||||||||||||
| 262 | , $pack->load_config($config)); | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 12 | my MY $self = do { | |||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | ▶ | if (@cf) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | ▶ | $pack->_with_loading_file($cf[0], sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | $pack->new(app_root => $app_root, %default | |||||||||||||||||||||||||||||||||||||||||
| 270 | , $pack->read_file($cf[0])); | ||||||||||||||||||||||||||||||||||||||||||
| 271 | }) | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 3 | } else { | |||||||||||||||||||||||||||||||||||||||||
| 273 | 9 | $pack->new(app_root => $app_root, %default); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 12 | ▶ | unless ($self->{__after_new_is_called__}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | Carp::croak("after_new is not called correctly!"); | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 12 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 13 | ▶ | sub list_app_config_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_app_config_files: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 13 | my ($pack, $app_root, $app_base) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | # When psgi is at $app_root/app.psgi, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | # test $app_root.config.d/app.{xhf,yml} and return them if exists. | ||||||||||||||||||||||||||||||||||||||||||
| 289 | # Otherwise list $app_root/app.{xhf,yml}. | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 13 | ▶ | if ($pack->use_sibling_config_dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 13 | my $sibling_config_dir = "$app_root.config.d"; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 13 | ▶ | if (-d $sibling_config_dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | my @cf = $pack->list_config_files("$sibling_config_dir/$app_base"); | |||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | ▶ | return @cf if @cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 11 | $pack->list_config_files("$app_root/$app_base"); | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # Load Amon2 style config.pl | ||||||||||||||||||||||||||||||||||||||||||
| 304 | # | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | sub config_for_env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_for_env: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | my ($pack, $app_root, $environment) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | "$app_root/config/$environment.pl"; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | ▶ | sub load_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | my ($pack, $cf) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | my $config = dofile_in($pack, $cf); | |||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | unless (defined $config) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | croak "config script '$cf' returned undef!"; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | ▶ | unless (ref $config eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | croak "config script '$cf' doesn't return HASH! $config"; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | ▶ | wantarray ? %$config : $config; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 45 | my ($_n_created, $_n_destroyed); | |||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | sub n_created {$_n_created} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n_created: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | sub n_destroyed {$_n_destroyed} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n_destroyed: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 45 | our %sub2self; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 109 | ▶ | DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 109 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 109 | if (DEBUG_FACTORY) { | |||||||||||||||||||||||||||||||||||||||||
| 332 | if (DEBUG_REFCNT) { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | printf STDERR "# DESTROY %s refcnt=%d\n", $self, svref_2object($self)->REFCNT; | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | print STDERR "# DESTROY $self\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 109 | delete $self->{_my_psgi_app}; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 109 | ▶ | if (my $outer = delete $self->{_outer_psgi_app}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | delete $sub2self{$outer}; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 109 | ++$_n_destroyed; | |||||||||||||||||||||||||||||||||||||||||
| 343 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub to_app_and_forget { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_app_and_forget: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $sub = $self->to_app; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | delete $self->{_my_psgi_app}; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | delete $self->{_outer_psgi_app}; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | delete $sub2self{$sub}; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $sub; | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 37 | ▶ | sub to_app { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_app: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 37 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 37 | ▶ | if (@_ >= 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | croak "cascade support is dropped.Use wrapped_by(builder {}) instead."; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 37 | ▶ | $self->{_outer_psgi_app} // do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"_outer_psgi_app"} // do {
if (my $old = delete $self->{"_my_psgi_app"}) {
delete $YATT::Lite::Factory::sub2self{$old};
};
$self->prepare_app;
my $sub = sub {
$self->call(@_);
}
;
$self->{"_my_psgi_app"} = $sub;
builtin::weaken($self->{"_my_psgi_app"}) unless $YATT::Lite::Factory::want_object;
builtin::weaken($YATT::Lite::Factory::sub2self{$sub} = $self);
'???';
$sub
}
MC/DC0%0/2
$self->{"_outer_psgi_app"} // do {
if (my $old = delete $self->{"_my_psgi_app"}) {
delete $YATT::Lite::Factory::sub2self{$old};
};
$self->prepare_app;
my $sub = sub {
$self->call(@_);
}
;
$self->{"_my_psgi_app"} = $sub;
builtin::weaken($self->{"_my_psgi_app"}) unless $YATT::Lite::Factory::want_object;
builtin::weaken($YATT::Lite::Factory::sub2self{$sub} = $self);
'???';
$sub
}
$self->{"_outer_psgi_app"}
do {
if (my $old = delete $self->{"_my_psgi_app"}) {
delete $YATT::Lite::Factory::sub2self{$old};
};
$self->prepare_app;
my $sub = sub {
$self->call(@_);
}
;
$self->{"_my_psgi_app"} = $sub;
builtin::weaken($self->{"_my_psgi_app"}) unless $YATT::Lite::Factory::want_object;
builtin::weaken($YATT::Lite::Factory::sub2self{$sub} = $self);
'???';
$sub
}
Truth table33%1/3
A // B
A= $self->{"_outer_psgi_app"}B= do {
if (my $old = delete $self->{"_my_psgi_app"}) {
delete $YATT::Lite::Factory::sub2self{$old};
};
$self->prepare_app;
my $sub = sub {
$self->call(@_);
}
;
$self->{"_my_psgi_app"} = $sub;
builtin::weaken($self->{"_my_psgi_app"}) unless $YATT::Lite::Factory::want_object;
builtin::weaken($YATT::Lite::Factory::sub2self{$sub} = $self);
'???';
$sub
}
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 37 | ▶ | if (my $old = delete $self->{_my_psgi_app}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | delete $sub2self{$old}; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 37 | $self->prepare_app; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 37 | ▶ | my $sub = sub { $self->call(@_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 37 | $self->{_my_psgi_app} = $sub; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 37 | ▶ | weaken($self->{_my_psgi_app}) if not $want_object; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 37 | weaken($sub2self{$sub} = $self); | |||||||||||||||||||||||||||||||||||||||||
| 366 | 37 | print STDERR "to_app($self) returned $sub\n" if DEBUG_FACTORY; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 37 | $sub; | |||||||||||||||||||||||||||||||||||||||||
| 368 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | ▶ | sub wrapped_by { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrapped_by: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | my ($self, $outer_app) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | ▶ | unless ($self->{_my_psgi_app}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | croak "wrapped_by is called without calling Site->to_app"; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | delete $sub2self{$self->{_my_psgi_app}}; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 2 | $self->{_outer_psgi_app} = $outer_app; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | $sub2self{$outer_app} = $self; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | ▶ | weaken($self->{_outer_psgi_app}) if not $want_object; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | weaken($sub2self{$outer_app}); | |||||||||||||||||||||||||||||||||||||||||
| 380 | 2 | $outer_app; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 11 | ▶ | sub load_psgi_script { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_psgi_script: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 11 | my ($pack, $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 11 | local $want_object = 1; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 11 | local $0 = $fn; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 11 | my $sub = $pack->sandbox_dofile($fn); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 11 | ▶ | if (ref $sub eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | $sub2self{$sub}; | |||||||||||||||||||||||||||||||||||||||||
| 389 | ▶ | } elsif ($sub->isa($pack) or $sub->isa(MY)) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$sub->isa($pack) or $sub->isa("YATT::Lite::Factory")
MC/DC0%0/2
$sub->isa($pack) or $sub->isa("YATT::Lite::Factory")
$sub->isa($pack)
$sub->isa("YATT::Lite::Factory")
Truth table33%1/3
A or B
A= $sub->isa($pack)B= $sub->isa("YATT::Lite::Factory")
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 9 | $sub; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | die "Unknown load result from: $fn"; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 39 | ▶ | sub prepare_app { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 39 | (my MY $self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 39 | $self->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 123 | ▶ | sub prepare_deployment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_deployment: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 123 | (my MY $self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 123 | $self->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 402 | $self->{stash_unknown_params_to} | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 123 | ▶ | //= $self->default_stash_unknown_params_to; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"stash_unknown_params_to"} //= $self->default_stash_unknown_params_to
MC/DC0%0/2
$self->{"stash_unknown_params_to"} //= $self->default_stash_unknown_params_to
$self->{"stash_unknown_params_to"}
$self->default_stash_unknown_params_to
Truth table33%1/3
A //= B
A= $self->{"stash_unknown_params_to"}B= $self->default_stash_unknown_params_to
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 280 | ▶ | sub finalize_response { shift->maybe::next::method(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 45 | our $load_count; | |||||||||||||||||||||||||||||||||||||||||
| 408 | 11 | ▶ | sub sandbox_dofile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sandbox_dofile: called CC=4 SCAR=14.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 11 | my ($pack, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 11 | my $sandbox = sprintf "%s::Sandbox::S%d", __PACKAGE__, ++$load_count; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 11 | my @__result__; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 11 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | @__result__ = dofile_in($sandbox, $file); | |||||||||||||||||||||||||||||||||||||||||
| 414 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 11 | $__result__[0] = dofile_in($sandbox, $file); | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 11 | my $sym = globref($sandbox, 'filename'); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 11 | ▶ | unless (*{$sym}{CODE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 11 | ▶ | *$sym = sub {$file}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | 11 | ▶ | wantarray ? @__result__ : $__result__[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 45 | ▶ | sub load_factory_script { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_factory_script: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 11 | my ($pack, $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 11 | local $want_object = 1; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 11 | local $0 = $fn; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 11 | local ($FindBin::Bin, $FindBin::Script | |||||||||||||||||||||||||||||||||||||||||
| 430 | , $FindBin::RealBin, $FindBin::RealScript); | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 11 | ▶ | FindBin->again if FindBin->can("again"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 11 | ▶ | if ($fn =~ /\.psgi$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 11 | $pack->load_psgi_script($fn); | |||||||||||||||||||||||||||||||||||||||||
| 434 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $pack->sandbox_dofile($fn); | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 65 | ▶ | sub find_factory_script { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_factory_script: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 65 | my $pack = shift; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 65 | ▶ | my $dir = $pack->rel2abs($_[0] // $pack->curdir); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0] // $pack->curdir
MC/DC0%0/2
$_[0] // $pack->curdir
$_[0]
$pack->curdir
Truth table33%1/3
A // B
A= $_[0]B= $pack->curdir
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 65 | my @path = $pack->no_upwards($pack->splitdir($dir)); | |||||||||||||||||||||||||||||||||||||||||
| 443 | 65 | my $rootdir = $pack->rootdir; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 65 | ▶ | while (@path and length($dir = $pack->catdir(@path)) > length($rootdir)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@path and length($dir = $pack->catdir(@path)) > length $rootdir
MC/DC50%1/2
@path and length($dir = $pack->catdir(@path)) > length $rootdir
@path
length($dir = $pack->catdir(@path)) > length $rootdir
Truth table66%2/3
A and B
A= @pathB= length($dir = $pack->catdir(@path)) > length $rootdir
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 163 | ▶ | if (my ($found) = grep {-r} map {"$dir/$_.psgi"} qw(runyatt app)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 33 | return $found; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 130 | } continue { pop @path } | |||||||||||||||||||||||||||||||||||||||||
| 449 | 32 | return; | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 453 | # `use Factory -as_base` in app.psgi will come here. | ||||||||||||||||||||||||||||||||||||||||||
| 454 | # | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 24 | ▶ | sub _import_as_base { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_import_as_base: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 24 | my ($myPack, $callpack) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 24 | $myPack->SUPER::_import_as_base($callpack); | |||||||||||||||||||||||||||||||||||||||||
| 458 | # To define EntNS in $callpack and set $myPack to @{$callpack::ISA}. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 24 | $myPack->default_default_app->define_Entity(undef, $callpack); | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | # Just to allow writing `use Factory -Entity;` in your app.psgi. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | # Not actually required. | ||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | sub _import_Entity { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_import_Entity: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my ($myPack, $callpack) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $myPack->default_default_app->define_Entity(undef, $callpack); | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 125 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 125 | my ($class) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 473 | 125 | my MY $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 474 | 124 | ▶ | $self->preload_app_base unless $self->{no_preload_app_base}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 124 | ++$_n_created; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 124 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | # | ||||||||||||||||||||||||||||||||||||||||||
| 480 | # preload app_base (to avoid potential double-loading bug for base loading) | ||||||||||||||||||||||||||||||||||||||||||
| 481 | # | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 124 | ▶ | sub preload_app_base { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preload_app_base: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | 124 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 124 | foreach my $dir (lexpand($self->{app_base})) { | |||||||||||||||||||||||||||||||||||||||||
| 486 | 10 | ▶ | next if $dir =~ m{^::}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 8 | $self->load_yatt($self->app_path_expand($dir)); | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 125 | ▶ | sub init_app_ns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_app_ns: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 125 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 125 | $self->SUPER::init_app_ns; | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | # EntNS is initialized here. | ||||||||||||||||||||||||||||||||||||||||||
| 496 | # Note: CGEN_perl is not initialized here and delayed until it is required. | ||||||||||||||||||||||||||||||||||||||||||
| 497 | # This helps to avoid loading CGen::Perl for *.ydo in CGI. | ||||||||||||||||||||||||||||||||||||||||||
| 498 | 125 | $self->{_default_app}->ensure_entns($self->{_app_ns}); | |||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 125 | ▶ | sub after_new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_new: called CC=21 SCAR=38.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 125 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 125 | $self->SUPER::after_new; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 125 | ▶ | $self->{app_root} //= YATT::Lite::Util::maybe_findbin_bin(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"app_root"} //= YATT::Lite::Util::maybe_findbin_bin()
MC/DC0%0/2
$self->{"app_root"} //= YATT::Lite::Util::maybe_findbin_bin()
$self->{"app_root"}
YATT::Lite::Util::maybe_findbin_bin()
Truth table66%2/3
A //= B
A= $self->{"app_root"}B= YATT::Lite::Util::maybe_findbin_bin()
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 125 | ▶ | if (defined $self->{app_root}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 125 | $self->{app_root} = YATT::Lite::Util::normalize_fs_path($self->{app_root}); | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 125 | ▶ | $self->{index_name} //= $self->default_index_name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"index_name"} //= $self->default_index_name
MC/DC0%0/2
$self->{"index_name"} //= $self->default_index_name
$self->{"index_name"}
$self->default_index_name
Truth table33%1/3
A //= B
A= $self->{"index_name"}B= $self->default_index_name
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 125 | ▶ | $self->{ext_public} //= $self->default_ext_public; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"ext_public"} //= $self->default_ext_public
MC/DC0%0/2
$self->{"ext_public"} //= $self->default_ext_public
$self->{"ext_public"}
$self->default_ext_public
Truth table66%2/3
A //= B
A= $self->{"ext_public"}B= $self->default_ext_public
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 125 | ▶ | $self->{ext_private} //= $self->default_ext_private; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"ext_private"} //= $self->default_ext_private
MC/DC0%0/2
$self->{"ext_private"} //= $self->default_ext_private
$self->{"ext_private"}
$self->default_ext_private
Truth table33%1/3
A //= B
A= $self->{"ext_private"}B= $self->default_ext_private
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 125 | ▶ | if ($self->{no_unicode}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $self->{no_unicode_params} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $self->{binary_config} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 514 | $self->{header_charset} | ||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | //= ($self->{output_encoding} || $self->default_header_charset); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{"header_charset"} //= $self->{"output_encoding"} || $self->default_header_charset
$self->{'output_encoding'} || $self->default_header_charset
MC/DC0%0/3
$self->{"header_charset"} //= $self->{"output_encoding"} || $self->default_header_charset
$self->{"header_charset"}
$self->{'output_encoding'}
$self->default_header_charset
Truth table0%0/4
A //= B || C
A= $self->{"header_charset"}B= $self->{'output_encoding'}C= $self->default_header_charset
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | $self->{output_encoding} | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | //= $self->compat_default_output_encoding; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"output_encoding"} //= $self->compat_default_output_encoding
MC/DC0%0/2
$self->{"output_encoding"} //= $self->compat_default_output_encoding
$self->{"output_encoding"}
$self->compat_default_output_encoding
Truth table0%0/3
A //= B
A= $self->{"output_encoding"}B= $self->compat_default_output_encoding
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->{render_as_bytes} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 519 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 520 | $self->{header_charset} | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 125 | ▶ | //= ($self->{output_encoding} // $self->default_header_charset); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$self->{"header_charset"} //= $self->{"output_encoding"} // $self->default_header_charset
$self->{"output_encoding"} // $self->default_header_charset
MC/DC0%0/3
$self->{"header_charset"} //= $self->{"output_encoding"} // $self->default_header_charset
$self->{"header_charset"}
$self->{"output_encoding"}
$self->default_header_charset
Truth table0%0/4
A //= B // C
A= $self->{"header_charset"}B= $self->{"output_encoding"}C= $self->default_header_charset
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | $self->{tmpl_encoding} | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 125 | ▶ | //= ($self->{output_encoding} // $self->default_tmpl_encoding); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$self->{"tmpl_encoding"} //= $self->{"output_encoding"} // $self->default_tmpl_encoding
$self->{"output_encoding"} // $self->default_tmpl_encoding
MC/DC0%0/3
$self->{"tmpl_encoding"} //= $self->{"output_encoding"} // $self->default_tmpl_encoding
$self->{"tmpl_encoding"}
$self->{"output_encoding"}
$self->default_tmpl_encoding
Truth table0%0/4
A //= B // C
A= $self->{"tmpl_encoding"}B= $self->{"output_encoding"}C= $self->default_tmpl_encoding
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 125 | ▶ | $self->{output_encoding} //= $self->default_output_encoding; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"output_encoding"} //= $self->default_output_encoding
MC/DC0%0/2
$self->{"output_encoding"} //= $self->default_output_encoding
$self->{"output_encoding"}
$self->default_output_encoding
Truth table66%2/3
A //= B
A= $self->{"output_encoding"}B= $self->default_output_encoding
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 125 | ▶ | $self->{use_subpath} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"use_subpath"} //= 1
MC/DC100%1/1
$self->{"use_subpath"} //= 1
$self->{"use_subpath"}
Truth table100%2/2
A
A= $self->{"use_subpath"}
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 125 | ▶ | $self->{always_refresh_deps} //= $self->default_always_refresh_deps; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"always_refresh_deps"} //= $self->default_always_refresh_deps
MC/DC0%0/2
$self->{"always_refresh_deps"} //= $self->default_always_refresh_deps
$self->{"always_refresh_deps"}
$self->default_always_refresh_deps
Truth table66%2/3
A //= B
A= $self->{"always_refresh_deps"}B= $self->default_always_refresh_deps
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 125 | ▶ | $self->{body_argument} //= $self->default_body_argument; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"body_argument"} //= $self->default_body_argument
MC/DC0%0/2
$self->{"body_argument"} //= $self->default_body_argument
$self->{"body_argument"}
$self->default_body_argument
Truth table33%1/3
A //= B
A= $self->{"body_argument"}B= $self->default_body_argument
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 125 | ▶ | $self->{body_argument_type} //= $self->default_body_argument_type; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"body_argument_type"} //= $self->default_body_argument_type
MC/DC0%0/2
$self->{"body_argument_type"} //= $self->default_body_argument_type
$self->{"body_argument_type"}
$self->default_body_argument_type
Truth table66%2/3
A //= B
A= $self->{"body_argument_type"}B= $self->default_body_argument_type
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | # prepare_app is too late to set delegated params | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 125 | ▶ | if (($ENV{PLACK_ENV} // '') ne 'development') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ENV{"PLACK_ENV"} // ""
MC/DC100%1/1
$ENV{"PLACK_ENV"} // ""
$ENV{"PLACK_ENV"}
Truth table100%2/2
A
A= $ENV{"PLACK_ENV"}
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 123 | $self->prepare_deployment; | |||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | sub compat_default_output_encoding { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compat_default_output_encoding: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 99 | ▶ | sub default_output_encoding { 'utf-8' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_output_encoding: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 98 | ▶ | sub default_header_charset { 'utf-8' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_header_charset: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 99 | ▶ | sub default_tmpl_encoding { 'utf-8' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_tmpl_encoding: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 125 | ▶ | sub default_index_name { 'index' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_index_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 123 | ▶ | sub default_ext_public {'yatt'} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ext_public: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 125 | ▶ | sub default_ext_private {'ytmpl'} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ext_private: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 123 | ▶ | sub default_stash_unknown_params_to {'yatt.unknown_params'} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_stash_unknown_params_to: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 122 | ▶ | sub default_always_refresh_deps { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_always_refresh_deps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | 125 | ▶ | sub default_body_argument { 'body' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_body_argument: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 124 | ▶ | sub default_body_argument_type { 'code' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_body_argument_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 125 | ▶ | sub _after_after_new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_after_after_new: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 125 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 554 | 125 | $self->SUPER::_after_after_new; | |||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 125 | ▶ | if ($self->{doc_root}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | # GH-260: keep doc_root textually consistent with the normalized | ||||||||||||||||||||||||||||||||||||||||||
| 558 | # app_root; rel_app_name relies on prefix-length arithmetic. | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 124 | $self->{doc_root} = YATT::Lite::Util::normalize_fs_path($self->{doc_root}); | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | 125 | ▶ | if (not $self->{allow_missing_dir} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $self->{"allow_missing_dir"} and $self->{"doc_root"} and not -d $self->{"doc_root"}
not $self->{"allow_missing_dir"} and $self->{"doc_root"}
MC/DC0%0/3
not $self->{"allow_missing_dir"} and $self->{"doc_root"} and not -d $self->{"doc_root"}
not $self->{"allow_missing_dir"}
$self->{"doc_root"}
not -d $self->{"doc_root"}
Truth table50%2/4
not(A) and B and not(C)
A= not $self->{"allow_missing_dir"}B= $self->{"doc_root"}C= not -d $self->{"doc_root"}
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | and $self->{doc_root} | ||||||||||||||||||||||||||||||||||||||||||
| 563 | and not -d $self->{doc_root}) { | ||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | croak "document_root '$self->{doc_root}' is missing!"; | |||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | 125 | ▶ | if ($self->{doc_root}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 124 | trim_slash($self->{doc_root}); | |||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 569 | # XXX: $self->{tmpldirs} | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 125 | ▶ | $self->{site_prefix} //= ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"site_prefix"} //= ""
MC/DC100%1/1
$self->{"site_prefix"} //= ""
$self->{"site_prefix"}
Truth table100%2/2
A
A= $self->{"site_prefix"}
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 125 | $self->{_tmpldirs} = []; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 125 | ▶ | if (my $dir = $self->{doc_root}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 124 | push @{$self->{_tmpldirs}}, $dir; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 124 | my $refcnt; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 124 | if (DEBUG_REFCNT) { | |||||||||||||||||||||||||||||||||||||||||
| 578 | $refcnt = svref_2object($self)->REFCNT; | ||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 124 | $self->get_yatt('/'); | |||||||||||||||||||||||||||||||||||||||||
| 581 | 123 | if (DEBUG_REFCNT) { | |||||||||||||||||||||||||||||||||||||||||
| 582 | if (svref_2object($self)->REFCNT != $refcnt) { | ||||||||||||||||||||||||||||||||||||||||||
| 583 | croak "Reference count of $self is increased from $refcnt to " | ||||||||||||||||||||||||||||||||||||||||||
| 584 | . svref_2object($self)->REFCNT . "!"; | ||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 124 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 63 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 63 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 595 | 63 | my $raw_bytes = $self->render_encoded(@_); | |||||||||||||||||||||||||||||||||||||||||
| 596 | 63 | ▶ | if ($self->{render_as_bytes}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | $raw_bytes; | |||||||||||||||||||||||||||||||||||||||||
| 598 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 62 | decode(utf8 => $raw_bytes); | |||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 70 | ▶ | sub parse_path_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_path_info: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 70 | (my MY $self, my ($reqrec)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 605 | # [$path_info, $subpage, $action] | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 70 | ▶ | my ($path_info, @rest) = ref $reqrec ? @$reqrec : $reqrec; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | 70 | $path_info =~ s,^/*,/,; | |||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 70 | my ($tmpldir, $loc, $file, $trailer, $is_index) | |||||||||||||||||||||||||||||||||||||||||
| 611 | = my @pi = $self->lookup_split_path_info($path_info); | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 70 | ▶ | unless (@pi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 70 | ▶ | ($path_info, $tmpldir, $loc, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | (@rest ? [$file, @rest] : $file), | ||||||||||||||||||||||||||||||||||||||||||
| 618 | , $self->pi_to_connection_quad(\@pi) | ||||||||||||||||||||||||||||||||||||||||||
| 619 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 70 | ▶ | sub prepare_processing_context { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_processing_context: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | 70 | (my MY $self, my ($reqrec, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | my ($path_info, $tmpldir, $loc, $widgetSpec, @rest) | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 70 | ▶ | = $self->parse_path_info($reqrec) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | die "No such location: ".terse_dump($reqrec); | |||||||||||||||||||||||||||||||||||||||||
| 628 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | 70 | ▶ | my $dh = $self->get_lochandler(map {untaint_any($_)} $loc, $tmpldir) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | die "No such directory: $path_info"; | |||||||||||||||||||||||||||||||||||||||||
| 632 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | my $con = $self->make_connection | ||||||||||||||||||||||||||||||||||||||||||
| 635 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 636 | undef, @rest, | ||||||||||||||||||||||||||||||||||||||||||
| 637 | , yatt => $dh, noheader => 1, path_info => $path_info, | ||||||||||||||||||||||||||||||||||||||||||
| 638 | , encoding => $self->{output_encoding} | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 70 | , $self->make_debug_params($reqrec, $args) | |||||||||||||||||||||||||||||||||||||||||
| 640 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 70 | ($dh, $con, $widgetSpec); | |||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | 63 | ▶ | sub render_encoded { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_encoded: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | 63 | (my MY $self, my ($reqrec, $args, @opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | 63 | my ($dh, $con, $widgetSpec) = $self->prepare_processing_context($reqrec, $args); | |||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 63 | $self->render_into_context($dh, $con, $widgetSpec, $args, @opts); | |||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 63 | $con->buffer; | |||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | sub render_into { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_into: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | (my MY $self, my ($con, $reqrec, $args, @opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | my ($path_info, $tmpldir, $loc, $widgetSpec, @rest) | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | = $self->parse_path_info($reqrec) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | die "No such location: ".terse_dump($reqrec); | |||||||||||||||||||||||||||||||||||||||||
| 661 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | my $dh = $self->get_lochandler(map {untaint_any($_)} $loc, $tmpldir) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | die "No such directory: $path_info"; | |||||||||||||||||||||||||||||||||||||||||
| 665 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $con->configure(yatt => $dh); | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $self->render_into_context($dh, $con, $widgetSpec, $args, @opts); | |||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | # | ||||||||||||||||||||||||||||||||||||||||||
| 673 | # Common context wrapper for the render path: sets $SYS/$YATT/$CON, | ||||||||||||||||||||||||||||||||||||||||||
| 674 | # runs before/after_dirhandler (site_config entities) and the chdir | ||||||||||||||||||||||||||||||||||||||||||
| 675 | # guard, but does NOT install the __DIE__/__WARN__ traps - that is the | ||||||||||||||||||||||||||||||||||||||||||
| 676 | # web handle path's intentional distinction (perl -d friendliness). | ||||||||||||||||||||||||||||||||||||||||||
| 677 | # GH-267 | ||||||||||||||||||||||||||||||||||||||||||
| 678 | # | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 63 | ▶ | sub render_into_context { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_into_context: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | 63 | (my MY $self, my ($dh, $con, $widgetSpec, $args, @opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 63 | local ($SYS, $YATT, $CON) = ($self, $dh, $con); | |||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | 63 | $self->before_dirhandler($dh, $con, lexpand($widgetSpec)); | |||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | 63 | my $chdir_guard = $dh->chdir_guard; | |||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 63 | $self->invoke_dirhandler | |||||||||||||||||||||||||||||||||||||||||
| 689 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 690 | $dh, | ||||||||||||||||||||||||||||||||||||||||||
| 691 | , render_into => $con | ||||||||||||||||||||||||||||||||||||||||||
| 692 | , $widgetSpec | ||||||||||||||||||||||||||||||||||||||||||
| 693 | , $args, @opts | ||||||||||||||||||||||||||||||||||||||||||
| 694 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 63 | $self->after_dirhandler($dh, $con, lexpand($widgetSpec)); | |||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | 63 | YATT::Lite::Util::try_invoke($con, 'flush_headers'); | |||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | sub make_connection_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_connection_for: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | (my MY $self, my ($reqrec, $args, @other)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my ($path_info, $tmpldir, $loc, $widgetSpec, @rest) | |||||||||||||||||||||||||||||||||||||||||
| 705 | = $self->parse_path_info($reqrec); | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | $self->make_connection | ||||||||||||||||||||||||||||||||||||||||||
| 708 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 709 | undef, @rest, | ||||||||||||||||||||||||||||||||||||||||||
| 710 | , noheader => 1, path_info => $path_info, | ||||||||||||||||||||||||||||||||||||||||||
| 711 | , encoding => $self->{output_encoding}, | ||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | , $self->make_debug_params($reqrec, $args), | |||||||||||||||||||||||||||||||||||||||||
| 713 | , @other, | ||||||||||||||||||||||||||||||||||||||||||
| 714 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | 106 | ▶ | sub lookup_split_path_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_split_path_info: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 718 | 106 | (my MY $self, my $path_info) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 719 | lookup_path($path_info | ||||||||||||||||||||||||||||||||||||||||||
| 720 | , $self->{_tmpldirs} | ||||||||||||||||||||||||||||||||||||||||||
| 721 | , $self->{index_name} | ||||||||||||||||||||||||||||||||||||||||||
| 722 | , $self->{ext_public} | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 106 | , $self->{use_subpath}); | |||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | sub K_MOUNT_MATCH () { "__yatt" } | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 32 | ▶ | sub lookup_psgi_mount { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_psgi_mount: called CC=6 SCAR=18.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | 32 | (my MY $self, my $path_info) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 32 | ▶ | $self->{_loc2psgi_re} // $self->rebuild_psgi_mount; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_loc2psgi_re"} // $self->rebuild_psgi_mount
MC/DC0%0/2
$self->{"_loc2psgi_re"} // $self->rebuild_psgi_mount
$self->{"_loc2psgi_re"}
$self->rebuild_psgi_mount
Truth table66%2/3
A // B
A= $self->{"_loc2psgi_re"}B= $self->rebuild_psgi_mount
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | $path_info =~ $self->{_loc2psgi_re} | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 32 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | 7 | ▶ | my @mount_match = grep {/^@{[K_MOUNT_MATCH()]}/o} keys %+ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 737 | 7 | ▶ | if (@mount_match >= 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | croak "Multiple match found for psgi_mount: \n" | ||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | . join("\n ", map {$self->{_loc2psgi_dict}{$_}[0]} @mount_match); | |||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | 7 | my $path_prefix = $+{$mount_match[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | 7 | my $item = $self->{_loc2psgi_dict}{$path_prefix}; | |||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | 7 | ▶ | wantarray ? @{$item}[1..$#$item] : $item->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | 7 | ▶ | sub mount_psgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mount_psgi: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 750 | 7 | (my MY $self, my ($path_prefix, $app, @opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 751 | 7 | ▶ | unless (defined $path_prefix) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | croak "path_prefix is empty! mount_psgi(path_prefix, psgi_app)"; | |||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 7 | ▶ | if (not ref $path_prefix) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | 7 | $path_prefix =~ s,^/*,/,; | |||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 757 | 7 | ▶ | my $dict = $self->{_loc2psgi_dict} //= +{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_loc2psgi_dict"} //= {}
MC/DC100%1/1
$self->{"_loc2psgi_dict"} //= {}
$self->{"_loc2psgi_dict"}
Truth table100%2/2
A
A= $self->{"_loc2psgi_dict"}
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | 7 | my $key = K_MOUNT_MATCH() . (keys %$dict); | |||||||||||||||||||||||||||||||||||||||||
| 759 | 7 | (my $strip = $path_prefix) =~ s,/\z,,; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 7 | $dict->{$path_prefix} = [$key => $strip => $app, @opts]; | |||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 7 | undef $self->{_loc2psgi_re}; | |||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | # For cascading call | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 7 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | 7 | ▶ | sub rebuild_psgi_mount { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rebuild_psgi_mount: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 769 | 7 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 770 | 7 | my @re; | |||||||||||||||||||||||||||||||||||||||||
| 771 | 7 | foreach my $path_prefix (sort {length($b) <=> length($a)} | |||||||||||||||||||||||||||||||||||||||||
| 772 | 7 | ▶ | keys %{$self->{_loc2psgi_dict} //= +{}}) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_loc2psgi_dict"} //= {}
MC/DC0%0/1
$self->{"_loc2psgi_dict"} //= {}
$self->{"_loc2psgi_dict"}
Truth table50%1/2
A
A= $self->{"_loc2psgi_dict"}
| |||||||||||||||||||||||||||||||||||||||||||
| 773 | 20 | my ($key, undef, $app) = @{$self->{_loc2psgi_dict}{$path_prefix}}; | |||||||||||||||||||||||||||||||||||||||||
| 774 | 20 | push @re, qr{(?<$key>$path_prefix)}; | |||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||
| 776 | 7 | my $all = join("|", @re); | |||||||||||||||||||||||||||||||||||||||||
| 777 | 7 | $self->{_loc2psgi_re} = qr{^(?:$all)}; | |||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | 4 | ▶ | sub psgi_file_app { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_file_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 781 | 4 | my ($pack, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 782 | 4 | require Plack::App::File; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 4 | Plack::App::File->new(root => $path)->to_app; | |||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | ▶ | sub mount_static { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mount_static: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 787 | 1 | (my MY $self, my ($location, $realpath)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 788 | 1 | ▶ | my $app = ref $realpath eq 'CODE' ? $realpath | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | : $self->psgi_file_app($realpath); | ||||||||||||||||||||||||||||||||||||||||||
| 790 | 1 | $self->mount_psgi($location, $app); | |||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | 36 | ▶ | sub mount_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mount_action: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 796 | 36 | (my MY $self, my ($path_info, $action)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 797 | 36 | ▶ | if (my $ref = ref $path_info) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | croak "mount_action doesn't support $ref path_info, sorry"; | |||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 36 | my ($tmpldir, $loc, $file, $trailer, $is_index) | |||||||||||||||||||||||||||||||||||||||||
| 801 | = my @pi = $self->lookup_split_path_info($path_info); | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 36 | ▶ | unless (@pi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | croak "Can't find acutal directory for $path_info"; | |||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 36 | ▶ | unless ($is_index) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | croak "Conflicting mount_action($path_info) with file=$file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | 36 | my $realdir = $tmpldir.$loc; | |||||||||||||||||||||||||||||||||||||||||
| 809 | 36 | my $dh = $self->get_dirhandler($realdir); | |||||||||||||||||||||||||||||||||||||||||
| 810 | 36 | $dh->set_action_handler($trailer, $action); | |||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | # For cascading call. | ||||||||||||||||||||||||||||||||||||||||||
| 813 | 36 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | sub Connection () {'YATT::Lite::Connection'}; | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | sub make_simple_connection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_simple_connection: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | (my MY $self, my ($quad, @rest)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my @params = $self->pi_to_connection_quad($quad); | |||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $self->make_connection(undef, @params, @rest); | |||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | 70 | ▶ | sub pi_to_connection_quad { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pi_to_connection_quad: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 827 | 70 | (my MY $self, my ($pi)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 70 | my ($tmpldir, $loc, $file, $trailer, $is_index, $request_file) = @$pi; | |||||||||||||||||||||||||||||||||||||||||
| 829 | 70 | my $virtdir = "$self->{doc_root}$loc"; | |||||||||||||||||||||||||||||||||||||||||
| 830 | 70 | my $realdir = "$tmpldir$loc"; | |||||||||||||||||||||||||||||||||||||||||
| 831 | # GH-251: When request_file is not given (e.g. synthetic quads), | ||||||||||||||||||||||||||||||||||||||||||
| 832 | # default to the canonical (extension-less) form. | ||||||||||||||||||||||||||||||||||||||||||
| 833 | 70 | ▶ | $request_file //= $is_index ? '' : trim_ext($file, $self->{ext_public}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$request_file //= $is_index ? "" : trim_ext($file, $self->{"ext_public"})
MC/DC0%0/2
$request_file //= $is_index ? "" : trim_ext($file, $self->{"ext_public"})
$request_file
$is_index ? "" : trim_ext($file, $self->{"ext_public"})
Truth table33%1/3
A //= B
A= $request_fileB= $is_index ? "" : trim_ext($file, $self->{"ext_public"})
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | 70 | $self->connection_quad([$virtdir, $loc, $file, $trailer, $request_file]); | |||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | 70 | ▶ | sub make_debug_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_debug_params: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | 70 | (my MY $self, my ($reqrec, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 839 | 70 | (); | |||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | 436 | ▶ | sub make_connection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_connection: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 436 | (my MY $self, my ($fh, @params)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 436 | require YATT::Lite::Connection; | |||||||||||||||||||||||||||||||||||||||||
| 845 | $self->Connection->create( | ||||||||||||||||||||||||||||||||||||||||||
| 846 | $fh, @params, system => $self, root => $self->{doc_root} | ||||||||||||||||||||||||||||||||||||||||||
| 847 | 436 | ); | |||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 2 | ▶ | sub finalize_connection {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_connection: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | sub connection_param { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connection_param: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | croak "Use of YATT::Lite::Factory::connection_param is deprecated!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | 386 | ▶ | sub connection_quad { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connection_quad: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 386 | (my MY $self, my ($quad)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 857 | 386 | my ($virtdir, $loc, $file, $subpath, $request_file) = @$quad; | |||||||||||||||||||||||||||||||||||||||||
| 858 | 386 | ▶ | (dir => $virtdir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | , location => $loc | ||||||||||||||||||||||||||||||||||||||||||
| 860 | , file => $file | ||||||||||||||||||||||||||||||||||||||||||
| 861 | , subpath => $subpath | ||||||||||||||||||||||||||||||||||||||||||
| 862 | , (defined $request_file ? (request_file => $request_file) : ())); | ||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 866 | # | ||||||||||||||||||||||||||||||||||||||||||
| 867 | # Hook for subclassing | ||||||||||||||||||||||||||||||||||||||||||
| 868 | # | ||||||||||||||||||||||||||||||||||||||||||
| 869 | 331 | ▶ | sub run_dirhandler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_dirhandler: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | 331 | (my MY $self, my ($dh, $con, $file)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 871 | 331 | local ($SYS, $YATT, $CON) = ($self, $dh, $con); | |||||||||||||||||||||||||||||||||||||||||
| 872 | 331 | $self->before_dirhandler($dh, $con, $file); | |||||||||||||||||||||||||||||||||||||||||
| 873 | 331 | my $result = $self->invoke_dirhandler( | |||||||||||||||||||||||||||||||||||||||||
| 874 | $dh, | ||||||||||||||||||||||||||||||||||||||||||
| 875 | handle => $dh->cut_ext($file), $con, $file | ||||||||||||||||||||||||||||||||||||||||||
| 876 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 877 | 291 | $self->after_dirhandler($dh, $con, $file); | |||||||||||||||||||||||||||||||||||||||||
| 878 | 291 | ▶ | if (defined $result and ref $result eq 'ARRAY' and @$result == 3) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $result and ref $result eq "ARRAY" and @$result == 3
defined $result and ref $result eq "ARRAY"
MC/DC0%0/3
defined $result and ref $result eq "ARRAY" and @$result == 3
defined $result
ref $result eq "ARRAY"
@$result == 3
Truth table25%1/4
A and B and C
A= defined $resultB= ref $result eq "ARRAY"C= @$result == 3
| |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | $self->raise_response($result) | |||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||
| 883 | 385 | ▶ | sub before_dirhandler { &maybe::next::method; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_dirhandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | 361 | ▶ | sub after_dirhandler { &maybe::next::method; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_dirhandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 394 | ▶ | sub invoke_dirhandler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invoke_dirhandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 887 | 394 | (my MY $self, my ($dh, $method, @args)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 888 | 394 | $dh->with_system($self, $method, @args); | |||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | 7 | ▶ | sub invoke_sub_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invoke_sub_in: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 7 | (my MY $self, my ($reqrec, $args, $sub, @rest)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | 7 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | 7 | my ($dh, $con, $widgetSpec) | |||||||||||||||||||||||||||||||||||||||||
| 897 | = $self->prepare_processing_context($reqrec, $args); | ||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||
| 899 | 7 | local ($SYS, $YATT, $CON) = ($self, $dh, $con); | |||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | 7 | $self->before_dirhandler($dh, $con, lexpand($widgetSpec)); | |||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | 7 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 904 | 7 | ▶ | if ($wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | 4 | @result = $sub->($dh, $con, @rest); | |||||||||||||||||||||||||||||||||||||||||
| 906 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 907 | 3 | $result[0] = $sub->($dh, $con, @rest); | |||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | 7 | $self->after_dirhandler($dh, $con, lexpand($widgetSpec)); | |||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | 7 | YATT::Lite::Util::try_invoke($con, 'flush_headers'); | |||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||
| 914 | 7 | ▶ | $wantarray ? @result : $result[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | 420 | ▶ | sub get_lochandler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_lochandler: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | 420 | (my MY $self, my ($location, $tmpldir)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 921 | 420 | ▶ | $tmpldir //= $self->{doc_root}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$tmpldir //= $self->{"doc_root"}
MC/DC0%0/2
$tmpldir //= $self->{"doc_root"}
$tmpldir
$self->{"doc_root"}
Truth table66%2/3
A //= B
A= $tmpldirB= $self->{"doc_root"}
| |||||||||||||||||||||||||||||||||||||||||||
| 922 | 420 | ▶ | $self->get_yatt($location) || do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | $self->{_loc2yatt}{$location} = $self->load_yatt("$tmpldir$location"); | |||||||||||||||||||||||||||||||||||||||||
| 924 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | # location => yatt (dirhandler, dirapp) | ||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||
| 929 | 569 | ▶ | sub get_yatt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_yatt: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 930 | 569 | (my MY $self, my $loc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 931 | 569 | ▶ | if (my $yatt = $self->{_loc2yatt}{$loc}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 932 | 1 | return $yatt; | |||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||
| 934 | # print STDERR Carp::longmess("get_yatt for $loc" | ||||||||||||||||||||||||||||||||||||||||||
| 935 | # , YATT::Lite::Util::terse_dump($self->{_tmpldirs})); | ||||||||||||||||||||||||||||||||||||||||||
| 936 | 568 | my ($realdir, $basedir) = lookup_dir(trim_slash($loc), $self->{_tmpldirs}); | |||||||||||||||||||||||||||||||||||||||||
| 937 | 568 | ▶ | unless ($realdir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | $self->error("Can't find template directory for location '%s'", $loc); | |||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 568 | $self->{_loc2yatt}{$loc} = $self->load_yatt($realdir, $basedir); | |||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | # phys-path => yatt | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | 45 | *get_dirhandler = *load_yatt; *get_dirhandler = *load_yatt; | |||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | 795 | ▶ | sub load_yatt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_yatt: called CC=11 SCAR=25.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 948 | 795 | (my MY $self, my ($path, $basedir, $visits, $from)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | 795 | ▶ | unless (defined $path and $path ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $path and $path ne ""
MC/DC0%0/2
defined $path and $path ne ""
defined $path
$path ne ""
Truth table33%1/3
A and B
A= defined $pathB= $path ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | croak "empty path for load_yatt!" | |||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | 795 | $path = $self->rel2abs($path, $self->{app_root}); | |||||||||||||||||||||||||||||||||||||||||
| 955 | 795 | ▶ | if (my $yatt = $self->{_path2yatt}{$path}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 956 | 616 | return $yatt; | |||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||
| 958 | 179 | ▶ | unless (-e $path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | croak "Can't load YATT directory '$path'! No such directory!"; | |||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||
| 961 | 179 | ▶ | if (not $visits) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 962 | 160 | $visits = Visits->start($path); | |||||||||||||||||||||||||||||||||||||||||
| 963 | } elsif (my $preds = $visits->check_cycle($path, $from)) { | ||||||||||||||||||||||||||||||||||||||||||
| 964 | 1 | $self->error("Template config error! base has cycle!:\n %s\n" | |||||||||||||||||||||||||||||||||||||||||
| 965 | , join "\n -> ", $from, @$preds); | ||||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | #-- DFS-visits -- | ||||||||||||||||||||||||||||||||||||||||||
| 968 | 178 | ▶ | if (not $self->{allow_missing_dir} and not -d $path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"allow_missing_dir"} or -d $path
MC/DC0%0/2
$self->{"allow_missing_dir"} or -d $path
$self->{"allow_missing_dir"}
-d $path
Truth table33%1/3
A or B
A= $self->{"allow_missing_dir"}B= -d $path
| |||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | croak "Can't find '$path'!"; | |||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||
| 971 | 178 | ▶ | if (my (@cf) = $self->list_config_files(untaint_any($path)."/.htyattconfig")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 972 | 20 | ▶ | $self->error("Multiple configuration files!", @cf) if @cf > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 973 | 20 | ▶ | _with_loading_file {$self} $cf[0], sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 974 | 20 | $self->build_yatt($path, $basedir, $visits, $self->read_file($cf[0])); | |||||||||||||||||||||||||||||||||||||||||
| 975 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||
| 976 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 977 | 158 | $self->build_yatt($path, $basedir, $visits); | |||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | 178 | ▶ | sub build_yatt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_yatt: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | 178 | (my MY $self, my ($path, $basedir, $visits, %opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 178 | trim_slash($path); | |||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | 178 | my $app_name = $self->app_name_for($path, $basedir); | |||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||
| 987 | # | ||||||||||||||||||||||||||||||||||||||||||
| 988 | # base package と base vfs object の決定 | ||||||||||||||||||||||||||||||||||||||||||
| 989 | # | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 178 | my (@basepkg, @basevfs); | |||||||||||||||||||||||||||||||||||||||||
| 991 | 178 | $self->_list_base_spec_in($path, delete $opts{base}, $visits | |||||||||||||||||||||||||||||||||||||||||
| 992 | , \@basepkg, \@basevfs); | ||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | 175 | my $app_ns = $self->buildns(my @log = (INST => \@basepkg, $path)); | |||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | 175 | print STDERR "# Factory::buildns(" | |||||||||||||||||||||||||||||||||||||||||
| 997 | , terse_dump(@log), ") => $app_ns\n" if DEBUG_FACTORY; | ||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||
| 999 | 175 | my $has_rc; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 175 | ▶ | if ($has_rc = (-e (my $rc = "$path/.htyattrc.pl"))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | # Note: This can do "use fields (...)" | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | 10 | dofile_in($app_ns, $rc); | |||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 10 | print STDERR "# Loaded: $rc\n" if DEBUG_FACTORY; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | my @args = (vfs => [dir => $path | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | , entns => $self->{_path2entns}{$path} | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | , encoding => $self->{tmpl_encoding} | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | , @basevfs ? (base => \@basevfs) : ()] | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | , dir => $path | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | , app_ns => $app_ns | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | , app_name => $app_name | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | , factory => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | # XXX: Design flaw! Use of tmpl_cache will cause problem. | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | # because VFS->create for base do not respect Factory->get_yatt. | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | # To solve this, I should redesign all Factory/VFS related stuffs. | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | , tmpl_cache => $self->{_tmpl_cache} //= {} | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | , entns2vfs_item => $self->{_entns2vfs_item} //= {} | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 175 | ▶ | , $self->configparams_for(fields_hash($app_ns))); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%4/4
$self->{"_tmpl_cache"} //= {}
$self->{"_entns2vfs_item"} //= {}
MC/DC100%1/1
$self->{"_tmpl_cache"} //= {}
$self->{"_tmpl_cache"}
MC/DC100%1/1
$self->{"_entns2vfs_item"} //= {}
$self->{"_entns2vfs_item"}
Truth table100%2/2
A
A= $self->{"_tmpl_cache"}
Truth table100%2/2
A
A= $self->{"_entns2vfs_item"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||
| 1024 | 175 | ▶ | if (my @unk = $app_ns->YATT::Lite::Object::cf_unknowns(%opts)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $self->error("Unknown option for yatt app '%s': '%s'" | |||||||||||||||||||||||||||||||||||||||||
| 1026 | , $path, join(", ", @unk)); | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 175 | printf STDERR "build_yatt.before_app_ns_new: refcnt=%d\n", svref_2object($self)->REFCNT if DEBUG_REFCNT && DEBUG_FACTORY; | |||||||||||||||||||||||||||||||||||||||||
| 1030 | 175 | my $yatt = $self->{_path2yatt}{$path} = $app_ns->new(@args, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 1031 | 175 | printf STDERR "build_yatt.after_app_ns_new: refcnt=%d\n", svref_2object($self)->REFCNT if DEBUG_REFCNT && DEBUG_FACTORY; | |||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | 175 | ▶ | unless ($yatt->after_new_is_called) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | Carp::croak("after_new is not called for $path!"); | |||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||
| 1037 | 175 | ▶ | if ($has_rc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 10 | print STDERR "# setting up rc actions\n" if DEBUG_FACTORY; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 10 | $yatt->setup_rc_actions; | |||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | 175 | $yatt; | |||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 178 | ▶ | sub _list_base_spec_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_base_spec_in: called CC=18 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1046 | 178 | (my MY $self, my ($in, $desc, $visits, $basepkg, $basevfs)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | print STDERR "# Factory::list_base_in(" | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | 178 | , terse_dump($in, $desc, $self->{app_base}), ")\n" if DEBUG_FACTORY; | |||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | # YATT::Lite->base can be either specified explicitly | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | # or implicitly copied from YATT::Lite::Factory->app_base. | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | # Later case can lead circular inheritance for app_base itself. | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | # To avoid this, $is_implicit flag is used. | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | 178 | my $is_implicit = not defined $desc; | |||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||
| 1060 | 178 | ▶ | $desc //= $self->{app_base}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$desc //= $self->{"app_base"}
MC/DC100%2/2
$desc //= $self->{"app_base"}
$desc
$self->{"app_base"}
Truth table100%3/3
A //= B
A= $descB= $self->{"app_base"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | # First item in base is treated *primary* base. | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | # Rest of them are treated mixin. | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | 178 | ▶ | my ($base, @mixin) = lexpand($desc) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | # This builds [$package => $path] pairs and separately store | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | # as primary and mixin. | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | 35 | my (@primary_pair, @mixin_pair); | |||||||||||||||||||||||||||||||||||||||||
| 1074 | 35 | foreach my $task ([1, $base], [0, @mixin]) { | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 70 | my ($is_primary, @spec) = @$task; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | 70 | foreach my $basespec (@spec) { | |||||||||||||||||||||||||||||||||||||||||
| 1077 | 54 | my ($pkg, $yatt); | |||||||||||||||||||||||||||||||||||||||||
| 1078 | 54 | ▶ | if ($basespec =~ /^::(.*)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1079 | 5 | ckrequire($1); | |||||||||||||||||||||||||||||||||||||||||
| 1080 | 5 | ▶ | push @{$is_primary ? \@primary_pair : \@mixin_pair}, [$1, undef]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1081 | } elsif (my $realpath = $self->app_path_find_dir_in($in, $basespec)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | 49 | ▶ | if ($is_implicit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | # Simply drop circular inheritance for implicit case. | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | 13 | ▶ | next if $visits->has_node($realpath); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | 42 | $visits->ensure_make_node($realpath); | |||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 42 | ▶ | push @{$is_primary ? \@primary_pair : \@mixin_pair}, [undef, $realpath]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1092 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $self->error("Invalid base spec: %s", $basespec); | |||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | # This builds $basevfs for YATT::Lite::VFS::Folder::vivify_base_descs() | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | # This preallocates YATT::Lite and its entns for each realpath. | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | 35 | foreach my $pair (@primary_pair, @mixin_pair) { | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 47 | my ($pkg, $dir) = @$pair; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | 47 | ▶ | next unless $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 42 | my $yatt = $self->load_yatt($dir, undef, $visits, $in); | |||||||||||||||||||||||||||||||||||||||||
| 1106 | 39 | $pair->[0] = ref $yatt; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 39 | my $realdir = $yatt->cget('dir'); | |||||||||||||||||||||||||||||||||||||||||
| 1108 | 39 | push @$basevfs, [dir => $realdir, entns => $self->{_path2entns}{$realdir}]; | |||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | # This builds $basepkg for buildns() | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | 32 | ▶ | push @$basepkg, map {defined $_->[0] ? $_->[0] : ()} do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 32 | ▶ | if (not $self->{no_mro_c3}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1116 | 32 | my %known_pkg; | |||||||||||||||||||||||||||||||||||||||||
| 1117 | 32 | foreach my $pair (grep {defined $_->[0]} @primary_pair) { | |||||||||||||||||||||||||||||||||||||||||
| 1118 | 25 | $known_pkg{$_} = 1 for @{mro::get_linear_isa($pair->[0])}; | |||||||||||||||||||||||||||||||||||||||||
| 1119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | 32 | ▶ | (grep(!$_->[0] || !$known_pkg{$_->[0]}, @mixin_pair) | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->[0] && $known_pkg{$_->[0]}
MC/DC50%1/2
$_->[0] && $known_pkg{$_->[0]}
$_->[0]
$known_pkg{$_->[0]}
Truth table66%2/3
A && B
A= $_->[0]B= $known_pkg{$_->[0]}
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | , @primary_pair); | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | @primary_pair; | |||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||
| 1127 | 32 | $visits->finish_node($in); | |||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 2 | ▶ | sub get_yatt_by_entns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_yatt_by_entns: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1131 | 2 | (my MY $self, my $entns) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | 2 | $self->{_entns2vfs_item}{$entns}; | |||||||||||||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||
| 1135 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | 175 | ▶ | sub buildns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
buildns: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1138 | 175 | (my MY $self, my ($kind, $baselist, $path)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1139 | 175 | my $newns = $self->SUPER::buildns($kind, $baselist, $path); | |||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | # EntNS を足し、Entity も呼べるようにする。 | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | $self->{_default_app}->define_Entity(undef, $newns | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | 175 | , map {$_->EntNS} @$baselist); | |||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | # instns には MY を定義しておく。 | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | 175 | my $my = globref($newns, 'MY'); | |||||||||||||||||||||||||||||||||||||||||
| 1147 | 175 | ▶ | unless (*{$my}{CODE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1148 | 175 | define_const($my, $newns); | |||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||
| 1151 | # もし $newns の EntNS が Factory(SiteApp, app.psgi) の EntNS を継承していない | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | # なら、継承する | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | 175 | ▶ | unless ($newns->EntNS->isa($self->EntNS)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1154 | 5 | push @{globref_default(globref($newns->EntNS, 'ISA') | |||||||||||||||||||||||||||||||||||||||||
| 1155 | , [])}, $self->EntNS; | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||
| 1158 | # basevfs に entns を渡せるように。 | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | 175 | $self->{_path2entns}{$path} = $newns->EntNS; | |||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | 175 | $newns; | |||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | 176 | ▶ | sub _cf_delegates { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cf_delegates: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1165 | 176 | qw(no_unicode | |||||||||||||||||||||||||||||||||||||||||
| 1166 | no_unicode_params | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | output_encoding | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | header_charset | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | tmpl_encoding | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | render_as_bytes | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | debug_cgen | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | at_done | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | app_root | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | namespace | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | index_name | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | ext_public | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | ext_private | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | only_parse | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | use_subpath | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | dont_map_args | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | dont_debug_param | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | always_refresh_deps | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | no_mro_c3 | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | die_in_error | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | special_entities | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | default_lang | ||||||||||||||||||||||||||||||||||||||||||
| 1187 | no_lineinfo | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | ext_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | debug_parser | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | check_lineno | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | match_argsroute_first | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | stash_unknown_params_to | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | body_argument | ||||||||||||||||||||||||||||||||||||||||||
| 1194 | body_argument_type | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | prefer_call_for_entity | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | no_conditional_call | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | allow_bare_entity_in_decl | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | no_chdir | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||
| 1202 | 175 | ▶ | sub configparams_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configparams_for: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1203 | 175 | (my MY $self, my $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1204 | # my @base = map { [dir => $_] } lexpand($self->{tmpldirs}); | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | # (@base ? (base => \@base) : ()) | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||
| 1207 | 175 | my $debugging = YATT::Lite::Util::is_debugging(); | |||||||||||||||||||||||||||||||||||||||||
| 1208 | 175 | ▶ | if ($debugging) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | print STDERR "# Note: Factory->die_in_error is turned off for debugging\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||
| 1212 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | $self->cf_delegate_known(0, $hash, $self->_cf_delegates) | ||||||||||||||||||||||||||||||||||||||||||
| 1214 | , (exists $hash->{error_handler} | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 175 | ▶ | ? (error_handler => \ $self->{error_handler}) : ()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1216 | , die_in_error => ! $debugging | ||||||||||||||||||||||||||||||||||||||||||
| 1217 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | # XXX: Should have better interface. | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | 1 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1222 | 1 | (my MY $self, my ($fmt, @args)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 1 | croak sprintf $fmt, @args; | |||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||
| 1228 | 178 | ▶ | sub app_name_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
app_name_for: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1229 | 178 | (my MY $self, my ($path, $basedir)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1230 | 178 | ensure_slash($path); | |||||||||||||||||||||||||||||||||||||||||
| 1231 | 178 | ▶ | if ($basedir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 153 | ensure_slash($basedir); | |||||||||||||||||||||||||||||||||||||||||
| 1233 | 153 | ▶ | $self->_extract_app_name($path, $basedir) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->_extract_app_name($path, $basedir) // $self->error("Can't extract app_name path=%s, base=%s", $path, $basedir)
MC/DC0%0/2
$self->_extract_app_name($path, $basedir) // $self->error("Can't extract app_name path=%s, base=%s", $path, $basedir)
$self->_extract_app_name($path, $basedir)
$self->error("Can't extract app_name path=%s, base=%s", $path, $basedir)
Truth table33%1/3
A // B
A= $self->_extract_app_name($path, $basedir)B= $self->error("Can't extract app_name path=%s, base=%s", $path, $basedir)
| |||||||||||||||||||||||||||||||||||||||||||
| 1234 | // $self->error("Can't extract app_name path=%s, base=%s" | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | , $path, $basedir); | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | 25 | foreach my $tmpldir (lexpand($self->{_tmpldirs})) { | |||||||||||||||||||||||||||||||||||||||||
| 1238 | 25 | ensure_slash(my $cp = $tmpldir); | |||||||||||||||||||||||||||||||||||||||||
| 1239 | 25 | ▶ | if (defined(my $app_name = $self->_extract_app_name($path, $cp))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1240 | # Can be empty string. | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | 12 | return $app_name; | |||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | 13 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||
| 1248 | 181 | ▶ | sub _extract_app_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_app_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1249 | 181 | (my MY $self, my ($path, $basedir)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | 181 | my ($bs, $name) = unpack('A'.length($basedir).'A*', $path); | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 181 | ▶ | return undef unless $bs eq $basedir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 167 | $name =~ s{[/\\]+$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 1253 | 167 | $name; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||
| 1256 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||
| 1258 | 36 | ▶ | sub read_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 36 | (my MY $self, my $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 36 | ▶ | my ($ext) = $fn =~ /\.(\w+)$/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1261 | or croak "Can't extract fileext from filename: $fn"; | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | 36 | ▶ | my $sub = $self->can("read_file_$ext") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1263 | or croak "filetype $ext is not supported: $fn"; | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | 36 | $sub->($self, $fn); | |||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||
| 1267 | 604 | ▶ | sub default_config_filetypes {qw/xhf yml/} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_config_filetypes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1268 | 604 | ▶ | sub config_filetypes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_filetypes: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1269 | 604 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1270 | 604 | ▶ | if (ref $self and my $item = $self->{config_filetypes}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self and my $item = $self->{"config_filetypes"}
MC/DC0%0/2
ref $self and my $item = $self->{"config_filetypes"}
ref $self
my $item = $self->{"config_filetypes"}
Truth table66%2/3
A and B
A= ref $selfB= my $item = $self->{"config_filetypes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | lexpand($item) | |||||||||||||||||||||||||||||||||||||||||
| 1272 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | 604 | $self->default_config_filetypes | |||||||||||||||||||||||||||||||||||||||||
| 1274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||
| 1277 | 764 | ▶ | sub find_unique_config_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_unique_config_file: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1278 | 764 | (my MY $self, my ($base_path, @rest)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1279 | 764 | ▶ | return if grep {not defined} $base_path, @rest; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1280 | 413 | my @cf = $self->list_config_files(join("", $base_path, @rest)); | |||||||||||||||||||||||||||||||||||||||||
| 1281 | 413 | ▶ | $self->error("Multiple configuration files!", @cf) if @cf > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1282 | 413 | ▶ | return $cf[0] if @cf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1283 | 403 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||
| 1286 | 604 | ▶ | sub list_config_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_config_files: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1287 | 604 | (my MY $self, my $base_path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1288 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | 604 | my $cf = "$base_path.$_"; | |||||||||||||||||||||||||||||||||||||||||
| 1290 | 1208 | ▶ | -e $cf ? $cf : () | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1291 | } $self->config_filetypes | ||||||||||||||||||||||||||||||||||||||||||
| 1292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||
| 1294 | 29 | ▶ | sub read_file_xhf { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file_xhf: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1295 | 29 | (my MY $self, my $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1296 | 29 | ▶ | my $bytes_semantics = ref $self && $self->{binary_config}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $self && $self->{'binary_config'}
MC/DC0%0/2
ref $self && $self->{'binary_config'}
ref $self
$self->{'binary_config'}
Truth table66%2/3
A && B
A= ref $selfB= $self->{'binary_config'}
| |||||||||||||||||||||||||||||||||||||||||||
| 1297 | 29 | $self->YATT::Lite::XHF::read_file_xhf | |||||||||||||||||||||||||||||||||||||||||
| 1298 | ($fn, bytes => $bytes_semantics); | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||
| 1301 | 7 | ▶ | sub read_file_yml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file_yml: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1302 | 7 | (my MY $self, my $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1303 | 7 | require YAML::Tiny; | |||||||||||||||||||||||||||||||||||||||||
| 1304 | 7 | my $yaml = YAML::Tiny->read($fn); | |||||||||||||||||||||||||||||||||||||||||
| 1305 | 6 | ▶ | unless (defined $yaml) { # YAML::Tiny old version doesn't raise error. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | Carp::croak(YAML::Tiny->errstr . ""); # errstr is deprecated, but only old version can reach this line. | |||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | 6 | ▶ | wantarray ? lexpand($yaml->[0]) : $yaml->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||
| 1311 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||
| 1313 | 870 | ▶ | sub trim_slash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim_slash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1314 | 870 | $_[0] =~ s,/*$,,; | |||||||||||||||||||||||||||||||||||||||||
| 1315 | 870 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||
| 1318 | 356 | ▶ | sub ensure_slash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_slash: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1319 | 356 | ▶ | unless (defined $_[0] and $_[0] ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and $_[0] ne ""
MC/DC0%0/2
defined $_[0] and $_[0] ne ""
defined $_[0]
$_[0] ne ""
Truth table33%1/3
A and B
A= defined $_[0]B= $_[0] ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | $_[0] = '/'; | |||||||||||||||||||||||||||||||||||||||||
| 1321 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | 356 | my $abs = File::Spec->rel2abs($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 1323 | 356 | ▶ | my $sep = $^O =~ /^MSWin/ ? "\\" : "/"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1324 | 356 | $abs =~ s{(?:\Q$sep\E)?$}{$sep}; # Should end with path-separator. | |||||||||||||||||||||||||||||||||||||||||
| 1325 | 356 | $_[0] = $abs; | |||||||||||||||||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1331 | 45 | ▶ | Entity site_prefix => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | my MY $self = $SYS; | |||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | $self->{site_prefix}; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | 45 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||
| 1338 | 45 | 1; | |||||||||||||||||||||||||||||||||||||||||