File Coverage

blib/lib/Articulate/FrameworkAdapter/Dancer1.pm
Criterion Covered Total %
statement 18 43 41.8
branch 0 2 0.0
condition n/a
subroutine 6 15 40.0
pod n/a
total 24 60 40.0


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