| 1 | # ABSTRACT: Dancer2's Domain Specific Language (DSL) | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package Dancer2::Core::DSL; | ||||||||||||||||||
| 4 | 162 | $Dancer2::Core::DSL::VERSION = '2.3.0'; | |||||||||||||||||
| 5 | 162 | ▶ | use Moo; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 162 | ▶ | use Carp; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 162 | ▶ | use Path::Tiny (); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 162 | ▶ | use Module::Runtime 'require_module'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 162 | ▶ | use Ref::Util qw< is_arrayref is_hashref >; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | 162 | ▶ | use Dancer2::Core::Hook; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 162 | ▶ | use Dancer2::Core::Response::Delayed; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 162 | with 'Dancer2::Core::Role::DSL'; | |||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | 0 | ▶ | sub hook_aliases { +{} } | ||||||||||||||||
|
Subroutine
hook_aliases: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 16 | 0 | ▶ | sub supported_hooks { () } | ||||||||||||||||
|
Subroutine
supported_hooks: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | 0 | ▶ | sub _add_postponed_plugin_hooks { | ||||||||||||||||
|
Subroutine
_add_postponed_plugin_hooks: not called CC=5 SCAR=34.0
| |||||||||||||||||||
| 19 | 0 | my ( $self, $postponed_hooks) = @_; | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 0 | $postponed_hooks = $postponed_hooks->{'plugin'}; | |||||||||||||||||
| 22 | 0 | ▶ | return unless defined $postponed_hooks; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 0 | for my $plugin ( keys %{$postponed_hooks} ) { | |||||||||||||||||
| 25 | 0 | for my $name ( keys %{$postponed_hooks->{$plugin} } ) { | |||||||||||||||||
| 26 | 0 | my $hook = $postponed_hooks->{$plugin}{$name}{hook}; | |||||||||||||||||
| 27 | 0 | my $caller = $postponed_hooks->{$plugin}{$name}{caller}; | |||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | $self->has_hook($name) | ||||||||||||||||||
| 30 | or croak "plugin $plugin does not support the hook `$name'. (" | ||||||||||||||||||
| 31 | 0 | ▶ | . join( ", ", @{$caller} ) . ")"; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | 0 | $self->add_hook($hook); | |||||||||||||||||
| 34 | } | ||||||||||||||||||
| 35 | } | ||||||||||||||||||
| 36 | } | ||||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | 311 | ▶ | sub dsl_keywords { | ||||||||||||||||
|
Subroutine
dsl_keywords: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | # the flag means : 1 = is global, 0 = is not global. global means can be | ||||||||||||||||||
| 41 | # called from anywhere. not global means must be called from within a route | ||||||||||||||||||
| 42 | # handler | ||||||||||||||||||
| 43 | 311 | { any => { is_global => 1 }, | |||||||||||||||||
| 44 | app => { is_global => 1 }, | ||||||||||||||||||
| 45 | captures => { is_global => 0 }, | ||||||||||||||||||
| 46 | config => { is_global => 1 }, | ||||||||||||||||||
| 47 | content => { is_global => 0 }, | ||||||||||||||||||
| 48 | content_type => { is_global => 0 }, | ||||||||||||||||||
| 49 | context => { is_global => 0 }, | ||||||||||||||||||
| 50 | cookie => { is_global => 0 }, | ||||||||||||||||||
| 51 | cookies => { is_global => 0 }, | ||||||||||||||||||
| 52 | dance => { is_global => 1 }, | ||||||||||||||||||
| 53 | dancer_app => { is_global => 1 }, | ||||||||||||||||||
| 54 | dancer_version => { is_global => 1 }, | ||||||||||||||||||
| 55 | dancer_major_version => { is_global => 1 }, | ||||||||||||||||||
| 56 | debug => { is_global => 1 }, | ||||||||||||||||||
| 57 | decode_json => { is_global => 1 }, | ||||||||||||||||||
| 58 | del => { is_global => 1 }, | ||||||||||||||||||
| 59 | delayed => { | ||||||||||||||||||
| 60 | is_global => 0, prototype => '&@', | ||||||||||||||||||
| 61 | }, | ||||||||||||||||||
| 62 | dirname => { is_global => 1 }, | ||||||||||||||||||
| 63 | done => { is_global => 0 }, | ||||||||||||||||||
| 64 | dsl => { is_global => 1 }, | ||||||||||||||||||
| 65 | encode_json => { is_global => 1 }, | ||||||||||||||||||
| 66 | engine => { is_global => 1 }, | ||||||||||||||||||
| 67 | error => { is_global => 1 }, | ||||||||||||||||||
| 68 | false => { is_global => 1 }, | ||||||||||||||||||
| 69 | flush => { is_global => 0 }, | ||||||||||||||||||
| 70 | forward => { is_global => 0 }, | ||||||||||||||||||
| 71 | from_json => { is_global => 1 }, | ||||||||||||||||||
| 72 | from_yaml => { is_global => 1 }, | ||||||||||||||||||
| 73 | get => { is_global => 1 }, | ||||||||||||||||||
| 74 | halt => { is_global => 0 }, | ||||||||||||||||||
| 75 | header => { is_global => 0 }, | ||||||||||||||||||
| 76 | headers => { is_global => 0 }, | ||||||||||||||||||
| 77 | hook => { is_global => 1 }, | ||||||||||||||||||
| 78 | info => { is_global => 1 }, | ||||||||||||||||||
| 79 | log => { is_global => 1 }, | ||||||||||||||||||
| 80 | mime => { is_global => 1 }, | ||||||||||||||||||
| 81 | options => { is_global => 1 }, | ||||||||||||||||||
| 82 | param => { is_global => 0 }, | ||||||||||||||||||
| 83 | params => { is_global => 0 }, | ||||||||||||||||||
| 84 | query_parameters => { is_global => 0 }, | ||||||||||||||||||
| 85 | body_parameters => { is_global => 0 }, | ||||||||||||||||||
| 86 | route_parameters => { is_global => 0 }, | ||||||||||||||||||
| 87 | pass => { is_global => 0 }, | ||||||||||||||||||
| 88 | patch => { is_global => 1 }, | ||||||||||||||||||
| 89 | path => { is_global => 1 }, | ||||||||||||||||||
| 90 | post => { is_global => 1 }, | ||||||||||||||||||
| 91 | prefix => { is_global => 1 }, | ||||||||||||||||||
| 92 | query => { is_global => 1 }, | ||||||||||||||||||
| 93 | prepare_app => { | ||||||||||||||||||
| 94 | is_global => 1, prototype => '&', | ||||||||||||||||||
| 95 | }, | ||||||||||||||||||
| 96 | psgi_app => { is_global => 1 }, | ||||||||||||||||||
| 97 | push_header => { is_global => 0 }, | ||||||||||||||||||
| 98 | push_response_header => { is_global => 0 }, | ||||||||||||||||||
| 99 | put => { is_global => 1 }, | ||||||||||||||||||
| 100 | redirect => { is_global => 0 }, | ||||||||||||||||||
| 101 | request => { is_global => 0 }, | ||||||||||||||||||
| 102 | request_data => { is_global => 0 }, | ||||||||||||||||||
| 103 | request_header => { is_global => 0 }, | ||||||||||||||||||
| 104 | response => { is_global => 0 }, | ||||||||||||||||||
| 105 | response_header => { is_global => 0 }, | ||||||||||||||||||
| 106 | response_headers => { is_global => 0 }, | ||||||||||||||||||
| 107 | runner => { is_global => 1 }, | ||||||||||||||||||
| 108 | send_as => { is_global => 0 }, | ||||||||||||||||||
| 109 | send_error => { is_global => 0 }, | ||||||||||||||||||
| 110 | send_file => { is_global => 0 }, | ||||||||||||||||||
| 111 | session => { is_global => 0 }, | ||||||||||||||||||
| 112 | set => { is_global => 1 }, | ||||||||||||||||||
| 113 | setting => { is_global => 1 }, | ||||||||||||||||||
| 114 | splat => { is_global => 0 }, | ||||||||||||||||||
| 115 | start => { is_global => 1 }, | ||||||||||||||||||
| 116 | status => { is_global => 0 }, | ||||||||||||||||||
| 117 | template => { is_global => 1 }, | ||||||||||||||||||
| 118 | to_app => { is_global => 1 }, | ||||||||||||||||||
| 119 | to_json => { is_global => 1 }, | ||||||||||||||||||
| 120 | to_yaml => { is_global => 1 }, | ||||||||||||||||||
| 121 | true => { is_global => 1 }, | ||||||||||||||||||
| 122 | upload => { is_global => 0 }, | ||||||||||||||||||
| 123 | uri_for => { is_global => 0 }, | ||||||||||||||||||
| 124 | uri_for_route => { is_global => 0 }, | ||||||||||||||||||
| 125 | var => { is_global => 0 }, | ||||||||||||||||||
| 126 | vars => { is_global => 0 }, | ||||||||||||||||||
| 127 | warning => { is_global => 1 }, | ||||||||||||||||||
| 128 | }; | ||||||||||||||||||
| 129 | } | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | 15 | ▶ | sub dancer_app { shift->app } | ||||||||||||||||
|
Subroutine
dancer_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 132 | 1 | ▶ | sub dancer_version { Dancer2->VERSION } | ||||||||||||||||
|
Subroutine
dancer_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 133 | |||||||||||||||||||
| 134 | 0 | ▶ | sub dancer_major_version { | ||||||||||||||||
|
Subroutine
dancer_major_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 135 | 0 | return ( split /\./, dancer_version )[0]; | |||||||||||||||||
| 136 | } | ||||||||||||||||||
| 137 | |||||||||||||||||||
| 138 | 0 | ▶ | sub log { shift->app->log( @_ ) } | ||||||||||||||||
|
Subroutine
log: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 139 | 3 | ▶ | sub debug { shift->app->log( debug => @_ ) } | ||||||||||||||||
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 140 | 2 | ▶ | sub info { shift->app->log( info => @_ ) } | ||||||||||||||||
|
Subroutine
info: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 141 | 5 | ▶ | sub warning { shift->app->log( warning => @_ ) } | ||||||||||||||||
|
Subroutine
warning: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 142 | 2 | ▶ | sub error { shift->app->log( error => @_ ) } | ||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 143 | |||||||||||||||||||
| 144 | 3 | ▶ | sub true {1} | ||||||||||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 145 | 0 | ▶ | sub false {0} | ||||||||||||||||
|
Subroutine
false: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 146 | |||||||||||||||||||
| 147 | 3 | ▶ | sub _path_obj { Path::Tiny::path(@_) } | ||||||||||||||||
|
Subroutine
_path_obj: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 148 | 1 | ▶ | sub dirname { shift and _path_obj(@_)->parent->stringify } | ||||||||||||||||
|
Subroutine
dirname: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||
| 149 | 2 | ▶ | sub path { shift and _path_obj(@_)->stringify } | ||||||||||||||||
|
Subroutine
path: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||
| 150 | |||||||||||||||||||
| 151 | 4 | ▶ | sub config { shift->app->settings } | ||||||||||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 152 | |||||||||||||||||||
| 153 | 10 | ▶ | sub engine { shift->app->engine(@_) } | ||||||||||||||||
|
Subroutine
engine: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 154 | |||||||||||||||||||
| 155 | 232 | ▶ | sub setting { shift->app->setting(@_) } | ||||||||||||||||
|
Subroutine
setting: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 156 | |||||||||||||||||||
| 157 | 216 | ▶ | sub set { shift->setting(@_) } | ||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 158 | |||||||||||||||||||
| 159 | 39 | ▶ | sub template { shift->app->template(@_) } | ||||||||||||||||
|
Subroutine
template: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 160 | |||||||||||||||||||
| 161 | 162 | ▶ | sub session { | ||||||||||||||||
|
Subroutine
session: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||
| 162 | 162 | my ( $self, $key, $value ) = @_; | |||||||||||||||||
| 163 | |||||||||||||||||||
| 164 | # shortcut reads if no session exists, so we don't | ||||||||||||||||||
| 165 | # instantiate sessions for no reason | ||||||||||||||||||
| 166 | 162 | ▶ | if ( @_ == 2 ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 167 | 71 | ▶ | return unless $self->app->has_session; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 168 | } | ||||||||||||||||||
| 169 | |||||||||||||||||||
| 170 | 147 | ▶ | my $session = $self->app->session | ||||||||||||||||
|
Condition50%1/2
$self->app->session || croak('No session available, a session engine needs to be set')
MC/DC0%0/1
$self->app->session || croak('No session available, a session engine needs to be set')
$self->app->session
Truth table50%1/2
A
A= $self->app->session
| |||||||||||||||||||
| 171 | || croak "No session available, a session engine needs to be set"; | ||||||||||||||||||
| 172 | |||||||||||||||||||
| 173 | 147 | $self->app->setup_session; | |||||||||||||||||
| 174 | |||||||||||||||||||
| 175 | # return the session object if no key | ||||||||||||||||||
| 176 | 147 | ▶ | @_ == 1 and return $session; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 177 | |||||||||||||||||||
| 178 | # read if a key is provided | ||||||||||||||||||
| 179 | 129 | ▶ | @_ == 2 and return $session->read($key); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 180 | |||||||||||||||||||
| 181 | |||||||||||||||||||
| 182 | # write to the session or delete if value is undef | ||||||||||||||||||
| 183 | 73 | ▶ | if ( defined $value ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 184 | 64 | $session->write( $key => $value ); | |||||||||||||||||
| 185 | } | ||||||||||||||||||
| 186 | else { | ||||||||||||||||||
| 187 | 9 | $session->delete($key); | |||||||||||||||||
| 188 | } | ||||||||||||||||||
| 189 | } | ||||||||||||||||||
| 190 | |||||||||||||||||||
| 191 | 11 | ▶ | sub send_as { shift->app->send_as(@_) } | ||||||||||||||||
|
Subroutine
send_as: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 192 | |||||||||||||||||||
| 193 | 20 | ▶ | sub send_error { shift->app->send_error(@_) } | ||||||||||||||||
|
Subroutine
send_error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 194 | |||||||||||||||||||
| 195 | 24 | ▶ | sub send_file { shift->app->send_file(@_) } | ||||||||||||||||
|
Subroutine
send_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 196 | |||||||||||||||||||
| 197 | # | ||||||||||||||||||
| 198 | # route handlers & friends | ||||||||||||||||||
| 199 | # | ||||||||||||||||||
| 200 | |||||||||||||||||||
| 201 | 104 | ▶ | sub hook { | ||||||||||||||||
|
Subroutine
hook: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 202 | 104 | my ( $self, $name, $code ) = @_; | |||||||||||||||||
| 203 | 104 | $self->app->add_hook( | |||||||||||||||||
| 204 | Dancer2::Core::Hook->new( name => $name, code => $code ) ); | ||||||||||||||||||
| 205 | } | ||||||||||||||||||
| 206 | |||||||||||||||||||
| 207 | 4 | ▶ | sub prefix { | ||||||||||||||||
|
Subroutine
prefix: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 208 | 4 | my $app = shift->app; | |||||||||||||||||
| 209 | 4 | ▶ | @_ == 1 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 210 | ? $app->prefix(@_) | ||||||||||||||||||
| 211 | : $app->lexical_prefix(@_); | ||||||||||||||||||
| 212 | } | ||||||||||||||||||
| 213 | |||||||||||||||||||
| 214 | 9 | ▶ | sub halt { shift->app->halt(@_) } | ||||||||||||||||
|
Subroutine
halt: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 215 | |||||||||||||||||||
| 216 | 2 | ▶ | sub del { shift->_normalize_route( [qw/delete /], @_ ) } | ||||||||||||||||
|
Subroutine
del: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 217 | 385 | ▶ | sub get { shift->_normalize_route( [qw/get head/], @_ ) } | ||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 218 | 1 | ▶ | sub options { shift->_normalize_route( [qw/options /], @_ ) } | ||||||||||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 219 | 3 | ▶ | sub patch { shift->_normalize_route( [qw/patch /], @_ ) } | ||||||||||||||||
|
Subroutine
patch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 220 | 43 | ▶ | sub post { shift->_normalize_route( [qw/post /], @_ ) } | ||||||||||||||||
|
Subroutine
post: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 221 | 6 | ▶ | sub query { shift->_normalize_route( [qw/query /], @_ ) } | ||||||||||||||||
|
Subroutine
query: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 222 | 4 | ▶ | sub put { shift->_normalize_route( [qw/put /], @_ ) } | ||||||||||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 223 | |||||||||||||||||||
| 224 | 2 | ▶ | sub prepare_app { push @{ shift->app->prep_apps }, @_ } | ||||||||||||||||
|
Subroutine
prepare_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 225 | |||||||||||||||||||
| 226 | 8 | ▶ | sub any { | ||||||||||||||||
|
Subroutine
any: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||
| 227 | 8 | my $self = shift; | |||||||||||||||||
| 228 | |||||||||||||||||||
| 229 | # If they've supplied their own list of methods, | ||||||||||||||||||
| 230 | # expand del, otherwise give them the default list. | ||||||||||||||||||
| 231 | 8 | ▶ | if ( is_arrayref($_[0]) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 232 | 3 | s/^del$/delete/ for @{ $_[0] }; | |||||||||||||||||
| 233 | } | ||||||||||||||||||
| 234 | else { | ||||||||||||||||||
| 235 | 5 | unshift @_, [qw/delete get head options patch post put query/]; | |||||||||||||||||
| 236 | } | ||||||||||||||||||
| 237 | |||||||||||||||||||
| 238 | 8 | $self->_normalize_route(@_); | |||||||||||||||||
| 239 | } | ||||||||||||||||||
| 240 | |||||||||||||||||||
| 241 | 452 | ▶ | sub _normalize_route { | ||||||||||||||||
|
Subroutine
_normalize_route: called CC=5 SCAR=16.3
| |||||||||||||||||||
| 242 | 452 | my $app = shift->app; | |||||||||||||||||
| 243 | 452 | my $methods = shift; | |||||||||||||||||
| 244 | 452 | my %args; | |||||||||||||||||
| 245 | |||||||||||||||||||
| 246 | # Options are optional, try to deduce their presence from arg length. | ||||||||||||||||||
| 247 | 452 | ▶ | if ( @_ == 4 ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 248 | # @_ = ( NAME, REGEXP, OPTIONS, CODE ) | ||||||||||||||||||
| 249 | # get 'foo', '/foo', { 'user_agent' => '...' }, sub {...} | ||||||||||||||||||
| 250 | 3 | @args{qw<name regexp options code>} = @_; | |||||||||||||||||
| 251 | } elsif ( @_ == 2 ) { | ||||||||||||||||||
| 252 | # @_ = ( REGEXP, CODE ) | ||||||||||||||||||
| 253 | # get '/foo', sub {...} | ||||||||||||||||||
| 254 | 438 | @args{qw<regexp code>} = @_; | |||||||||||||||||
| 255 | } elsif ( @_ == 3 ) { | ||||||||||||||||||
| 256 | # @_ = ( REGEXP, OPTIONS, CODE ) | ||||||||||||||||||
| 257 | # get '/foo', { 'user_agent' => '...' }, sub {...} | ||||||||||||||||||
| 258 | # @_ = ( NAME, REGEXP, CODE ) | ||||||||||||||||||
| 259 | # get 'foo', '/foo',sub {...} | ||||||||||||||||||
| 260 | 11 | ▶ | if ( is_hashref( $_[1] ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 261 | 0 | @args{qw<regexp options code>} = @_; | |||||||||||||||||
| 262 | } else { | ||||||||||||||||||
| 263 | 11 | @args{qw<name regexp code>} = @_; | |||||||||||||||||
| 264 | } | ||||||||||||||||||
| 265 | } | ||||||||||||||||||
| 266 | |||||||||||||||||||
| 267 | 452 | return map $app->add_route( %args, method => $_ ), @{$methods}; | |||||||||||||||||
| 268 | } | ||||||||||||||||||
| 269 | |||||||||||||||||||
| 270 | # | ||||||||||||||||||
| 271 | # Server startup | ||||||||||||||||||
| 272 | # | ||||||||||||||||||
| 273 | |||||||||||||||||||
| 274 | # access to the runner singleton | ||||||||||||||||||
| 275 | # will be populated on-the-fly when needed | ||||||||||||||||||
| 276 | # this singleton contains anything needed to start the application server | ||||||||||||||||||
| 277 | 1 | ▶ | sub runner { Dancer2->runner } | ||||||||||||||||
|
Subroutine
runner: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 278 | |||||||||||||||||||
| 279 | # start the server | ||||||||||||||||||
| 280 | 0 | ▶ | sub start { shift->runner->start } | ||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 281 | |||||||||||||||||||
| 282 | 0 | ▶ | sub dance { shift->start(@_) } | ||||||||||||||||
|
Subroutine
dance: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 283 | |||||||||||||||||||
| 284 | 2 | ▶ | sub psgi_app { | ||||||||||||||||
|
Subroutine
psgi_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 285 | 2 | my $self = shift; | |||||||||||||||||
| 286 | |||||||||||||||||||
| 287 | 2 | $self->app->to_app; | |||||||||||||||||
| 288 | } | ||||||||||||||||||
| 289 | |||||||||||||||||||
| 290 | 201 | ▶ | sub to_app { shift->app->to_app } | ||||||||||||||||
|
Subroutine
to_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 291 | |||||||||||||||||||
| 292 | # | ||||||||||||||||||
| 293 | # Response alterations | ||||||||||||||||||
| 294 | # | ||||||||||||||||||
| 295 | |||||||||||||||||||
| 296 | 9 | ▶ | sub status { | ||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 297 | 9 | $Dancer2::Core::Route::RESPONSE->status( $_[1] ); | |||||||||||||||||
| 298 | } | ||||||||||||||||||
| 299 | |||||||||||||||||||
| 300 | 0 | ▶ | sub push_header { | ||||||||||||||||
|
Subroutine
push_header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 301 | 0 | Carp::croak "DEPRECATED: push_header keyword. Please use the 'push_response_header' keyword instead of 'push_header'"; | |||||||||||||||||
| 302 | } | ||||||||||||||||||
| 303 | |||||||||||||||||||
| 304 | 0 | ▶ | sub push_response_header { | ||||||||||||||||
|
Subroutine
push_response_header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 305 | 0 | shift; | |||||||||||||||||
| 306 | 0 | $Dancer2::Core::Route::RESPONSE->push_header(@_); | |||||||||||||||||
| 307 | } | ||||||||||||||||||
| 308 | |||||||||||||||||||
| 309 | 0 | ▶ | sub header { | ||||||||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 310 | 0 | Carp::croak "DEPRECATED: header keyword. Please use the 'response_header' keyword instead of 'header'"; | |||||||||||||||||
| 311 | } | ||||||||||||||||||
| 312 | |||||||||||||||||||
| 313 | 4 | ▶ | sub response_header { | ||||||||||||||||
|
Subroutine
response_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 314 | 4 | shift; | |||||||||||||||||
| 315 | 4 | $Dancer2::Core::Route::RESPONSE->header(@_); | |||||||||||||||||
| 316 | } | ||||||||||||||||||
| 317 | |||||||||||||||||||
| 318 | 0 | ▶ | sub headers { | ||||||||||||||||
|
Subroutine
headers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 319 | 0 | Carp::croak "DEPRECATED: headers keyword. Please use the 'response_headers' keyword instead of 'headers'"; | |||||||||||||||||
| 320 | } | ||||||||||||||||||
| 321 | |||||||||||||||||||
| 322 | 0 | ▶ | sub response_headers { | ||||||||||||||||
|
Subroutine
response_headers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 323 | 0 | shift; | |||||||||||||||||
| 324 | 0 | $Dancer2::Core::Route::RESPONSE->header(@_); | |||||||||||||||||
| 325 | } | ||||||||||||||||||
| 326 | |||||||||||||||||||
| 327 | 1 | ▶ | sub content { | ||||||||||||||||
|
Subroutine
content: called CC=6 SCAR=33.1
Pod
undocumented
| |||||||||||||||||||
| 328 | 1 | my $dsl = shift; | |||||||||||||||||
| 329 | |||||||||||||||||||
| 330 | # simple synchronous response | ||||||||||||||||||
| 331 | 1 | ▶ | my $responder = $Dancer2::Core::Route::RESPONDER | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 332 | or croak 'Cannot use content keyword outside delayed response'; | ||||||||||||||||||
| 333 | |||||||||||||||||||
| 334 | # flush if wasn't flushed before | ||||||||||||||||||
| 335 | 0 | ▶ | if ( !$Dancer2::Core::Route::WRITER ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 336 | 0 | $Dancer2::Core::Route::WRITER = $responder->([ | |||||||||||||||||
| 337 | $Dancer2::Core::Route::RESPONSE->status, | ||||||||||||||||||
| 338 | $Dancer2::Core::Route::RESPONSE->headers_to_array, | ||||||||||||||||||
| 339 | ]); | ||||||||||||||||||
| 340 | } | ||||||||||||||||||
| 341 | |||||||||||||||||||
| 342 | eval { | ||||||||||||||||||
| 343 | 0 | $Dancer2::Core::Route::WRITER->write(@_); | |||||||||||||||||
| 344 | 0 | 1; | |||||||||||||||||
| 345 | 0 | ▶ | } or do { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 346 | 0 | ▶ | my $error = $@ || 'Zombie Error'; | ||||||||||||||||
|
Condition0%0/2
$@ || 'Zombie Error'
MC/DC0%0/1
$@ || 'Zombie Error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||
| 347 | 0 | ▶ | $Dancer2::Core::Route::ERROR_HANDLER | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 348 | ? $Dancer2::Core::Route::ERROR_HANDLER->($error) | ||||||||||||||||||
| 349 | : $dsl->app->logger_engine->log( | ||||||||||||||||||
| 350 | warning => "Error in delayed response: $error" | ||||||||||||||||||
| 351 | ); | ||||||||||||||||||
| 352 | }; | ||||||||||||||||||
| 353 | } | ||||||||||||||||||
| 354 | |||||||||||||||||||
| 355 | 0 | ▶ | sub content_type { | ||||||||||||||||
|
Subroutine
content_type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 356 | 0 | shift; | |||||||||||||||||
| 357 | 0 | $Dancer2::Core::Route::RESPONSE->content_type(@_); | |||||||||||||||||
| 358 | } | ||||||||||||||||||
| 359 | |||||||||||||||||||
| 360 | 1 | ▶ | sub delayed { | ||||||||||||||||
|
Subroutine
delayed: called CC=3 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||
| 361 | 1 | my ( $dsl, $cb, @args ) = @_; | |||||||||||||||||
| 362 | |||||||||||||||||||
| 363 | 1 | ▶ | @args % 2 == 0 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 364 | or croak 'Arguments to delayed() keyword must be key/value pairs'; | ||||||||||||||||||
| 365 | |||||||||||||||||||
| 366 | # first time, responder doesn't exist yet | ||||||||||||||||||
| 367 | 1 | my %opts = @args; | |||||||||||||||||
| 368 | $Dancer2::Core::Route::RESPONDER | ||||||||||||||||||
| 369 | or return Dancer2::Core::Response::Delayed->new( | ||||||||||||||||||
| 370 | cb => $cb, | ||||||||||||||||||
| 371 | request => $Dancer2::Core::Route::REQUEST, | ||||||||||||||||||
| 372 | response => $Dancer2::Core::Route::RESPONSE, | ||||||||||||||||||
| 373 | |||||||||||||||||||
| 374 | 1 | ▶ | ( error_cb => $opts{'on_error'} )x!! $opts{'on_error'}, | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 375 | ); | ||||||||||||||||||
| 376 | |||||||||||||||||||
| 377 | # we're in an async request process | ||||||||||||||||||
| 378 | 0 | my $request = $Dancer2::Core::Route::REQUEST; | |||||||||||||||||
| 379 | 0 | my $response = $Dancer2::Core::Route::RESPONSE; | |||||||||||||||||
| 380 | 0 | my $responder = $Dancer2::Core::Route::RESPONDER; | |||||||||||||||||
| 381 | 0 | my $writer = $Dancer2::Core::Route::WRITER; | |||||||||||||||||
| 382 | 0 | my $handler = $Dancer2::Core::Route::ERROR_HANDLER; | |||||||||||||||||
| 383 | |||||||||||||||||||
| 384 | 0 | ▶ | return sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 385 | 0 | local $Dancer2::Core::Route::REQUEST = $request; | |||||||||||||||||
| 386 | 0 | local $Dancer2::Core::Route::RESPONSE = $response; | |||||||||||||||||
| 387 | 0 | local $Dancer2::Core::Route::RESPONDER = $responder; | |||||||||||||||||
| 388 | 0 | local $Dancer2::Core::Route::WRITER = $writer; | |||||||||||||||||
| 389 | 0 | local $Dancer2::Core::Route::ERROR_HANDLER = $handler; | |||||||||||||||||
| 390 | |||||||||||||||||||
| 391 | 0 | $cb->(@_); | |||||||||||||||||
| 392 | 0 | }; | |||||||||||||||||
| 393 | } | ||||||||||||||||||
| 394 | |||||||||||||||||||
| 395 | 0 | ▶ | sub flush { | ||||||||||||||||
|
Subroutine
flush: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||
| 396 | 0 | ▶ | my $responder = $Dancer2::Core::Route::RESPONDER | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 397 | or croak 'flush() called outside streaming response'; | ||||||||||||||||||
| 398 | |||||||||||||||||||
| 399 | 0 | my $response = $Dancer2::Core::Route::RESPONSE; | |||||||||||||||||
| 400 | 0 | $Dancer2::Core::Route::WRITER = $responder->([ | |||||||||||||||||
| 401 | $response->status, $response->headers_to_array, | ||||||||||||||||||
| 402 | ]); | ||||||||||||||||||
| 403 | } | ||||||||||||||||||
| 404 | |||||||||||||||||||
| 405 | 0 | ▶ | sub done { | ||||||||||||||||
|
Subroutine
done: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||
| 406 | 0 | ▶ | my $writer = $Dancer2::Core::Route::WRITER | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 407 | or croak 'done() called outside streaming response'; | ||||||||||||||||||
| 408 | |||||||||||||||||||
| 409 | 0 | $writer->close; | |||||||||||||||||
| 410 | } | ||||||||||||||||||
| 411 | |||||||||||||||||||
| 412 | 3 | ▶ | sub pass { shift->app->pass } | ||||||||||||||||
|
Subroutine
pass: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 413 | |||||||||||||||||||
| 414 | # | ||||||||||||||||||
| 415 | # Route handler helpers | ||||||||||||||||||
| 416 | # | ||||||||||||||||||
| 417 | |||||||||||||||||||
| 418 | 0 | ▶ | sub context { | ||||||||||||||||
|
Subroutine
context: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 419 | 0 | Carp::croak "DEPRECATED: context keyword. Please use the 'app' keyword instead of 'context'"; | |||||||||||||||||
| 420 | } | ||||||||||||||||||
| 421 | |||||||||||||||||||
| 422 | 131 | ▶ | sub request { $Dancer2::Core::Route::REQUEST } | ||||||||||||||||
|
Subroutine
request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 423 | |||||||||||||||||||
| 424 | 1 | ▶ | sub request_header { shift; $Dancer2::Core::Route::REQUEST->headers->header(@_) } | ||||||||||||||||
|
Subroutine
request_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 425 | |||||||||||||||||||
| 426 | 12 | ▶ | sub response { $Dancer2::Core::Route::RESPONSE } | ||||||||||||||||
|
Subroutine
response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 427 | |||||||||||||||||||
| 428 | 2 | ▶ | sub upload { shift; $Dancer2::Core::Route::REQUEST->upload(@_); } | ||||||||||||||||
|
Subroutine
upload: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 429 | |||||||||||||||||||
| 430 | 2 | ▶ | sub captures { $Dancer2::Core::Route::REQUEST->captures } | ||||||||||||||||
|
Subroutine
captures: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 431 | |||||||||||||||||||
| 432 | 5 | ▶ | sub uri_for { shift; $Dancer2::Core::Route::REQUEST->uri_for(@_); } | ||||||||||||||||
|
Subroutine
uri_for: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 433 | |||||||||||||||||||
| 434 | 26 | ▶ | sub uri_for_route { shift->app->uri_for_route(@_); } | ||||||||||||||||
|
Subroutine
uri_for_route: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 435 | |||||||||||||||||||
| 436 | 32 | ▶ | sub splat { $Dancer2::Core::Route::REQUEST->splat } | ||||||||||||||||
|
Subroutine
splat: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 437 | |||||||||||||||||||
| 438 | 49 | ▶ | sub params { shift; $Dancer2::Core::Route::REQUEST->params(@_); } | ||||||||||||||||
|
Subroutine
params: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 439 | |||||||||||||||||||
| 440 | 6 | ▶ | sub param { shift; $Dancer2::Core::Route::REQUEST->param(@_); } | ||||||||||||||||
|
Subroutine
param: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 441 | |||||||||||||||||||
| 442 | 6 | ▶ | sub query_parameters { shift; $Dancer2::Core::Route::REQUEST->query_parameters(@_); } | ||||||||||||||||
|
Subroutine
query_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 443 | 19 | ▶ | sub body_parameters { shift; $Dancer2::Core::Route::REQUEST->body_parameters(@_); } | ||||||||||||||||
|
Subroutine
body_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 444 | 15 | ▶ | sub route_parameters { shift; $Dancer2::Core::Route::REQUEST->route_parameters(@_); } | ||||||||||||||||
|
Subroutine
route_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 445 | |||||||||||||||||||
| 446 | 2 | ▶ | sub request_data { shift; $Dancer2::Core::Route::REQUEST->body_data(@_); } | ||||||||||||||||
|
Subroutine
request_data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 447 | |||||||||||||||||||
| 448 | 30 | ▶ | sub redirect { shift->app->redirect(@_) } | ||||||||||||||||
|
Subroutine
redirect: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 449 | |||||||||||||||||||
| 450 | 50 | ▶ | sub forward { shift->app->forward(@_) } | ||||||||||||||||
|
Subroutine
forward: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 451 | |||||||||||||||||||
| 452 | 12 | ▶ | sub vars { $Dancer2::Core::Route::REQUEST->vars } | ||||||||||||||||
|
Subroutine
vars: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 453 | |||||||||||||||||||
| 454 | 9 | ▶ | sub var { shift; $Dancer2::Core::Route::REQUEST->var(@_); } | ||||||||||||||||
|
Subroutine
var: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 455 | |||||||||||||||||||
| 456 | 0 | ▶ | sub cookies { $Dancer2::Core::Route::REQUEST->cookies } | ||||||||||||||||
|
Subroutine
cookies: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 457 | 0 | ▶ | sub cookie { shift->app->cookie(@_) } | ||||||||||||||||
|
Subroutine
cookie: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 458 | |||||||||||||||||||
| 459 | 2 | ▶ | sub mime { | ||||||||||||||||
|
Subroutine
mime: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||
| 460 | 2 | my $self = shift; | |||||||||||||||||
| 461 | 2 | ▶ | if ( $self->app ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 462 | 2 | return $self->app->mime_type; | |||||||||||||||||
| 463 | } | ||||||||||||||||||
| 464 | else { | ||||||||||||||||||
| 465 | 0 | my $runner = $self->runner; | |||||||||||||||||
| 466 | 0 | $runner->mime_type->reset_to_default; | |||||||||||||||||
| 467 | 0 | return $runner->mime_type; | |||||||||||||||||
| 468 | } | ||||||||||||||||||
| 469 | } | ||||||||||||||||||
| 470 | |||||||||||||||||||
| 471 | # | ||||||||||||||||||
| 472 | # engines | ||||||||||||||||||
| 473 | # | ||||||||||||||||||
| 474 | |||||||||||||||||||
| 475 | 10 | ▶ | sub from_json { | ||||||||||||||||
|
Subroutine
from_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 476 | 10 | shift; # remove first element | |||||||||||||||||
| 477 | 10 | require_module('Dancer2::Serializer::JSON'); | |||||||||||||||||
| 478 | 10 | Dancer2::Serializer::JSON::from_json(@_); | |||||||||||||||||
| 479 | } | ||||||||||||||||||
| 480 | |||||||||||||||||||
| 481 | 34 | ▶ | sub to_json { | ||||||||||||||||
|
Subroutine
to_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 482 | 34 | shift; # remove first element | |||||||||||||||||
| 483 | 34 | require_module('Dancer2::Serializer::JSON'); | |||||||||||||||||
| 484 | 34 | Dancer2::Serializer::JSON::to_json(@_); | |||||||||||||||||
| 485 | } | ||||||||||||||||||
| 486 | |||||||||||||||||||
| 487 | 1 | ▶ | sub decode_json { | ||||||||||||||||
|
Subroutine
decode_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 488 | 1 | shift; # remove first element | |||||||||||||||||
| 489 | 1 | require_module('Dancer2::Serializer::JSON'); | |||||||||||||||||
| 490 | 1 | Dancer2::Serializer::JSON::decode_json(@_); | |||||||||||||||||
| 491 | } | ||||||||||||||||||
| 492 | |||||||||||||||||||
| 493 | 2 | ▶ | sub encode_json { | ||||||||||||||||
|
Subroutine
encode_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 494 | 2 | shift; # remove first element | |||||||||||||||||
| 495 | 2 | require_module('Dancer2::Serializer::JSON'); | |||||||||||||||||
| 496 | 2 | Dancer2::Serializer::JSON::encode_json(@_); | |||||||||||||||||
| 497 | } | ||||||||||||||||||
| 498 | |||||||||||||||||||
| 499 | 9 | ▶ | sub from_yaml { | ||||||||||||||||
|
Subroutine
from_yaml: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 500 | 9 | shift; # remove first element | |||||||||||||||||
| 501 | 9 | require_module('Dancer2::Serializer::YAML'); | |||||||||||||||||
| 502 | 9 | Dancer2::Serializer::YAML::from_yaml(@_); | |||||||||||||||||
| 503 | } | ||||||||||||||||||
| 504 | |||||||||||||||||||
| 505 | 19 | ▶ | sub to_yaml { | ||||||||||||||||
|
Subroutine
to_yaml: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 506 | 19 | shift; # remove first element | |||||||||||||||||
| 507 | 19 | require_module('Dancer2::Serializer::YAML'); | |||||||||||||||||
| 508 | 19 | Dancer2::Serializer::YAML::to_yaml(@_); | |||||||||||||||||
| 509 | } | ||||||||||||||||||
| 510 | |||||||||||||||||||
| 511 | 162 | 1; | |||||||||||||||||
| 512 | |||||||||||||||||||
| 513 | __END__ | ||||||||||||||||||