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 6 9 66.6
total 30 69 43.4


line stmt bran cond sub pod time code
1             package Articulate::FrameworkAdapter::Dancer1;
2 1     1   997 use strict;
  1         1  
  1         35  
3 1     1   4 use warnings;
  1         1  
  1         22  
4              
5 1     1   4 use Moo;
  1         1  
  1         5  
6             with 'Articulate::Role::Component';
7 1     1   1541 use Dancer qw(:syntax !after !before !session !status !send_file !content_type !upload);
  1         234198  
  1         6  
8 1     1   992 use IO::All ();
  1         8119  
  1         317  
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
46              
47             =item * L
48              
49             =item * L
50              
51             =item * L
52              
53             =back
54              
55             =cut
56              
57             sub user_id {
58 0     0 1   my $self = shift;
59 0           Dancer::session ('user_id', @_);
60             }
61              
62             sub appdir {
63 0     0 1   my $self = shift;
64 0           config->{appdir};
65             }
66              
67             sub session {
68 0     0 1   my $self = shift;
69 0           Dancer::session(@_);
70             }
71              
72             sub upload {
73 0     0 0   my $self = shift;
74 0           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     0 0   my $self = shift;
87 0           Dancer::content_type(@_);
88             }
89              
90             sub send_file {
91 0     0 0   my $self = shift;
92 0           Dancer::send_file(@_);
93             }
94              
95             sub status {
96 0     0 1   my $self = shift;
97 0           Dancer::status(@_);
98             }
99              
100             sub template_process {
101 0     0 1   my $self = shift;
102 0           my $view = shift . '.tt';
103 0           template ( $view, @_ );
104             }
105              
106             sub declare_route {
107 0     0 1   my ($self, $verb, $path, $code) = @_;
108 0 0         if ($verb =~ s/^(get|put|post|patch|del|any|options)$/'Dancer::'.lc $1;/ge) {
  0            
109             {
110 1     1   9 no strict 'refs';
  1         2  
  1         60  
  0            
111 0           &$verb($path, $code);
112             }
113             }
114             else {
115 0           die ('Unknown HTTP verb '.$verb);
116             }
117             }
118              
119             1;