| 1 | package CGI::Ex::App::Constants; | ||||||||||||
| 2 | |||||||||||||
| 3 | =head1 NAME | ||||||||||||
| 4 | |||||||||||||
| 5 | CGI::Ex::App::Constants - Easier access to magic App values | ||||||||||||
| 6 | |||||||||||||
| 7 | =head1 VERSION | ||||||||||||
| 8 | |||||||||||||
| 9 | version 2.54 | ||||||||||||
| 10 | |||||||||||||
| 11 | =cut | ||||||||||||
| 12 | |||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 2 | ▶ | use Exporter qw(import); # allow for goto from CGI::Ex::App | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | |||||||||||||
| 17 | 2 | our $VERSION = '2.54'; # VERSION | |||||||||||
| 18 | 2 | our %constants; | |||||||||||
| 19 | 2 | our @EXPORT; | |||||||||||
| 20 | 2 | our @EXPORT_OK; | |||||||||||
| 21 | 2 | our %EXPORT_TAGS; | |||||||||||
| 22 | |||||||||||||
| 23 | BEGIN { | ||||||||||||
| 24 | 2 | ▶ | my $all = { | ||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=16.1
| |||||||||||||
| 25 | App__allow_morph__allow_reblessing => '1 - This will allow changing MyApp to MyApp::MyStep when on step my_step', | ||||||||||||
| 26 | App__allow_morph__force_reblessing => '2 - This will force changing MyApp to MyApp::MyStep when on step my_step', | ||||||||||||
| 27 | App__allow_morph__no_auto_reblessing => '0 - We will not look for another package to bless into', | ||||||||||||
| 28 | App__auth_args => 'should return a hashref of args to pass to auth_obj', | ||||||||||||
| 29 | App__auth_obj => 'should return a auth_obj - used when require_auth is true', | ||||||||||||
| 30 | App__file_print => 'should file path, or be a scalar reference to the template to print', | ||||||||||||
| 31 | App__file_val => 'should return a file path or a hash_validation hashref (default is {})', | ||||||||||||
| 32 | App__fill_args => 'should return a hashref of args to pass to CGI::Ex::Fill::fill (default {})', | ||||||||||||
| 33 | App__fill_template => 'void context - uses hashes to fill the template', | ||||||||||||
| 34 | App__finalize__failed_and_show_page => '0 - additional processing failed so show the page', | ||||||||||||
| 35 | App__finalize__finished_and_move_to_next_step => '1 - default', | ||||||||||||
| 36 | App__finalize__finished_but_show_page => '', | ||||||||||||
| 37 | App__form_name => 'must return a name', | ||||||||||||
| 38 | App__generate_form => 'return coderef to form that can generate the form based on hash_validation', | ||||||||||||
| 39 | App__get_valid_auth => 'needs to return a CGI::Ex::Auth::Data object (which can be either true or false)', | ||||||||||||
| 40 | App__hash_base => 'should return a hashref', | ||||||||||||
| 41 | App__hash_common => 'should return a hashref', | ||||||||||||
| 42 | App__hash_errors => 'should return a hashref of errors that occurred on the page (normally populated via add_error)', | ||||||||||||
| 43 | App__hash_fill => 'should return a hashref of things to get filled in forms in the template', | ||||||||||||
| 44 | App__hash_form => 'should return a hashref - default is $self->form - normally not overridden', | ||||||||||||
| 45 | App__hash_swap => 'should return a hashref of things to process in the template', | ||||||||||||
| 46 | App__hash_validation => 'should return a CGI::Ex::Validate compatible hashref or {} (default empty hashref means all submitted information is always ok to finalize)', | ||||||||||||
| 47 | App__info_complete__fail_and_show_page => '0 - we were not ready to finalize the data either because there was not any, or it failed validation', | ||||||||||||
| 48 | App__info_complete__succeed_and_run_finalize => '1 - occurs because data is ready and is good or because there was no hash_validation to test against', | ||||||||||||
| 49 | App__js_validation => 'return coderef to form that will generate javascript based validation based on hash_validation', | ||||||||||||
| 50 | App__morph => 'void context - used to rebless into other package', | ||||||||||||
| 51 | App__morph_package => 'return package name derivative for use when allow_morph is true (see perldoc on morph, morph_package, morph_base)', | ||||||||||||
| 52 | App__name_module => 'return name of application - used when mapping to file_system (see file_print, file_val, conf_file)', | ||||||||||||
| 53 | App__name_step => 'return step of current request (default is $current_step) - used for mapping to file_system', | ||||||||||||
| 54 | App__path_info_map => 'return arrayref of matching arrayrefs - first one matching is used - others abort (only applies to current step)', | ||||||||||||
| 55 | App__path_info_map_base => 'return arrayref of matching arrayrefs - first one matching is used - others abort (ran before nav_loop)', | ||||||||||||
| 56 | App__post_loop__do_not_recurse => '1 - can be used to abort navigation if the loop is about to recurse to default step - no additional headers will be sent', | ||||||||||||
| 57 | App__post_loop__recurse_loop => 0, | ||||||||||||
| 58 | App__post_navigate => 'void context - called at the end of navigation unless $self->{_no_post_navigate} is true', | ||||||||||||
| 59 | App__post_print => 'void context - run code after page is diplayed to user', | ||||||||||||
| 60 | App__post_step__abort_navigation_flow => '1 - no additional headers will be sent', | ||||||||||||
| 61 | App__post_step__move_to_next_step => 0, | ||||||||||||
| 62 | App__pre_loop__begin_loop => 0, | ||||||||||||
| 63 | App__pre_loop__do_not_loop => '1 - can be used to abort the nav_loop call early on - no additional headers will be sent', | ||||||||||||
| 64 | App__pre_navigate__continue => '0 - go ahead and navigate the request', | ||||||||||||
| 65 | App__pre_navigate__stop => '1 - can be used to abort the navigate call early on - no additional headers will be sent', | ||||||||||||
| 66 | App__pre_step__abort_navigation_flow => '1 - no additional headers will be sent', | ||||||||||||
| 67 | App__pre_step__continue_current_step => 0, | ||||||||||||
| 68 | App__prepare__fail_and_show_page => 0, | ||||||||||||
| 69 | App__prepare__ok_move_to_info_complete => '1 - default', | ||||||||||||
| 70 | App__prepared_print => 'void context - gathers hashes - then calls print', | ||||||||||||
| 71 | App__print => 'void context - uses hashes to swap and fill file_print, then calls print_out', | ||||||||||||
| 72 | App__print_out => 'void context - prints headers and prepared content', | ||||||||||||
| 73 | App__ready_validate__data_not_ready_show_page => '0 - either validate_when_data was alse and it was a GET', | ||||||||||||
| 74 | App__ready_validate__ready_to_validate_data => '1 - either validate_when_data was true or we received a POST', | ||||||||||||
| 75 | App__refine_path => 'void context - manipulates the path after a step. set_ready_validate(0) if next_step is true', | ||||||||||||
| 76 | App__require_auth__needs_authentication => 1, | ||||||||||||
| 77 | App__require_auth__no_authentication_needed => 0, | ||||||||||||
| 78 | App__run_step__move_to_next_step => 0, | ||||||||||||
| 79 | App__run_step__request_completed => '1 - no additional headers will be sent', | ||||||||||||
| 80 | App__set_ready_validate => 'void context - sets ready_validate to true (fakes REQUEST_METHOD to POST OR GET)', | ||||||||||||
| 81 | App__skip__continue_current_step => 0, | ||||||||||||
| 82 | App__skip__move_to_next_step => '1 - make sure the path has a next step or it will default to main', | ||||||||||||
| 83 | App__swap_template => 'should return swapped template (passed $step, $file, $swap)', | ||||||||||||
| 84 | App__template_args => 'should return a hashref to pass to template_obj', | ||||||||||||
| 85 | App__template_obj => 'should return a Template::Alloy type object for swapping the template (passed template_args)', | ||||||||||||
| 86 | App__unmorph => 'void context - re-reblesses back to the original class before morph', | ||||||||||||
| 87 | App__val_args => 'should return a hashref to pass to val_obj', | ||||||||||||
| 88 | App__val_obj => 'should return a CGI::Ex::Validate type object for validating the data', | ||||||||||||
| 89 | App__validate__data_was_ok => '1 - request data either passed hash_validation or hash_validation was empty - make info_complete succeed', | ||||||||||||
| 90 | App__validate__failed_validation => 0, | ||||||||||||
| 91 | App__validate_when_data__succeed_if_data => '1 - will be true if there is no hash_validation, or a key from hash_validation was in the form', | ||||||||||||
| 92 | App__validate_when_data__use_ready_validate => 0, | ||||||||||||
| 93 | }; | ||||||||||||
| 94 | |||||||||||||
| 95 | 2 | require constant; | |||||||||||
| 96 | 2 | ▶ | while (my ($method, $val) = each %$all) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 97 | 136 | my ($prefix, $tag, $name) = split /__/, $method; | |||||||||||
| 98 | 136 | ▶ | if (! $name) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 99 | 72 | $constants{$tag} = $val; | |||||||||||
| 100 | 72 | next; | |||||||||||
| 101 | } | ||||||||||||
| 102 | 64 | $constants{$tag}->{$name} = $val; | |||||||||||
| 103 | |||||||||||||
| 104 | 64 | ▶ | my $tags = $EXPORT_TAGS{"App__${tag}"} ||= []; | ||||||||||
|
Condition100%2/2
$CGI::Ex::App::Constants::EXPORT_TAGS{"App__$tag"} ||= []
MC/DC100%1/1
$CGI::Ex::App::Constants::EXPORT_TAGS{"App__$tag"} ||= []
$CGI::Ex::App::Constants::EXPORT_TAGS{"App__$tag"}
Truth table100%2/2
A
A= $CGI::Ex::App::Constants::EXPORT_TAGS{"App__$tag"}
| |||||||||||||
| 105 | 64 | push @{ $EXPORT_TAGS{"App"} }, $method; | |||||||||||
| 106 | 64 | push @$tags, $method; | |||||||||||
| 107 | 64 | push @EXPORT, $method; | |||||||||||
| 108 | 64 | push @EXPORT_OK, $method; | |||||||||||
| 109 | |||||||||||||
| 110 | 64 | $val =~ s/\s+-.*//; | |||||||||||
| 111 | 64 | ▶ | $val *= 1 if $val =~ /^\d+$/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 112 | 64 | import constant $method => $val; | |||||||||||
| 113 | } | ||||||||||||
| 114 | |||||||||||||
| 115 | }; # end of BEGIN | ||||||||||||
| 116 | |||||||||||||
| 117 | sub constants { | ||||||||||||
| 118 | 0 | ▶ | print __PACKAGE__."\n---------------------\n"; | ||||||||||
|
Subroutine
constants: not called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||
| 119 | 2 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 120 | 0 | for (sort @EXPORT_OK) { | |||||||||||
| 121 | 0 | print "$_ (".$_->().")\n"; | |||||||||||
| 122 | } | ||||||||||||
| 123 | } | ||||||||||||
| 124 | |||||||||||||
| 125 | sub tags { | ||||||||||||
| 126 | 0 | ▶ | print __PACKAGE__." Tags\n---------------------\n"; | ||||||||||
|
Subroutine
tags: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 127 | 0 | print "$_\n" for sort keys %EXPORT_TAGS; | |||||||||||
| 128 | } | ||||||||||||
| 129 | |||||||||||||
| 130 | sub details { | ||||||||||||
| 131 | 0 | ▶ | require Data::Dumper; | ||||||||||
|
Subroutine
details: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 132 | 0 | local $Data::Dumper::SortKeys = 1; | |||||||||||
| 133 | 0 | print Data::Dumper::Dumper(\%constants); | |||||||||||
| 134 | } | ||||||||||||
| 135 | |||||||||||||
| 136 | 2 | 1; | |||||||||||
| 137 | |||||||||||||
| 138 | __END__ | ||||||||||||