| 1 | package Articulate::FrameworkAdapter::Dancer1; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | with 'Articulate::Role::Component'; | |||||||||
| 7 | 1 | ▶ | use Dancer qw(:syntax !after !before !session !status !send_file !content_type !upload); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use IO::All (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Articulate::FramwworkAdapter::Dancer1 - Access Dancer1 features though a common interface | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | # declare it in your config | ||||||||||
| 17 | plugins: | ||||||||||
| 18 | Articulate: | ||||||||||
| 19 | components: | ||||||||||
| 20 | framework: Articulate::FramwworkAdapter::Dancer1 | ||||||||||
| 21 | |||||||||||
| 22 | # then use it in your other components | ||||||||||
| 23 | my $appdir = $component->framework->appdir | ||||||||||
| 24 | |||||||||||
| 25 | =head1 METHODS | ||||||||||
| 26 | |||||||||||
| 27 | The following methods are implemented: | ||||||||||
| 28 | |||||||||||
| 29 | =head3 user_id | ||||||||||
| 30 | |||||||||||
| 31 | =head3 appdir | ||||||||||
| 32 | |||||||||||
| 33 | =head3 session | ||||||||||
| 34 | |||||||||||
| 35 | =head3 status | ||||||||||
| 36 | |||||||||||
| 37 | =head3 template_process | ||||||||||
| 38 | |||||||||||
| 39 | =head3 declare_route | ||||||||||
| 40 | |||||||||||
| 41 | =head1 SEE ALSO | ||||||||||
| 42 | |||||||||||
| 43 | =over | ||||||||||
| 44 | |||||||||||
| 45 | =item * L<Dancer::Plugin::Articulate> | ||||||||||
| 46 | |||||||||||
| 47 | =item * L<Dancer::Plugins> | ||||||||||
| 48 | |||||||||||
| 49 | =item * L<Dancer::Config> | ||||||||||
| 50 | |||||||||||
| 51 | =item * L<Articulate::FrameworkAdapter::Dancer2> | ||||||||||
| 52 | |||||||||||
| 53 | =back | ||||||||||
| 54 | |||||||||||
| 55 | =cut | ||||||||||
| 56 | |||||||||||
| 57 | sub user_id { | ||||||||||
| 58 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
user_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | 0 | Dancer::session ('user_id', @_); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | sub appdir { | ||||||||||
| 63 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
appdir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 64 | 0 | config->{appdir}; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | sub session { | ||||||||||
| 68 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 69 | 0 | Dancer::session(@_); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | sub upload { | ||||||||||
| 73 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
upload: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 74 | return (map { | ||||||||||
| 75 | 0 | $_->file_handle->binmode(':raw'); | |||||||||
| 76 | 0 | Articulate::File->new ( { | |||||||||
| 77 | content_type => $_->type, | ||||||||||
| 78 | headers => $_->headers, | ||||||||||
| 79 | filename => $_->filename, | ||||||||||
| 80 | io => $_->file_handle, | ||||||||||
| 81 | } ) | ||||||||||
| 82 | } Dancer::upload(@_))[0]; | ||||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | sub set_content_type { | ||||||||||
| 86 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
set_content_type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 87 | 0 | Dancer::content_type(@_); | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | sub send_file { | ||||||||||
| 91 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
send_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 92 | 0 | Dancer::send_file(@_); | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | sub status { | ||||||||||
| 96 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 97 | 0 | Dancer::status(@_); | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | sub template_process { | ||||||||||
| 101 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
template_process: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 102 | 0 | my $view = shift . '.tt'; | |||||||||
| 103 | 0 | template ( $view, @_ ); | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | sub declare_route { | ||||||||||
| 107 | 0 | ▶ | my ($self, $verb, $path, $code) = @_; | ||||||||
|
Subroutine
declare_route: not called CC=2 SCAR=12.6
Pod
documented
| |||||||||||
| 108 | 0 | ▶ | if ($verb =~ s/^(get|put|post|patch|del|any|options)$/'Dancer::'.lc $1;/ge) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | { | ||||||||||
| 110 | 1 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||
| 111 | 0 | &$verb($path, $code); | |||||||||
| 112 | } | ||||||||||
| 113 | } | ||||||||||
| 114 | else { | ||||||||||
| 115 | 0 | die ('Unknown HTTP verb '.$verb); | |||||||||
| 116 | } | ||||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 1 | 1; | |||||||||