File Coverage

blib/lib/Web/Machine/Resource.pm
Criterion Covered Total %
statement 51 59 86.4
branch 2 4 50.0
condition 4 12 33.3
subroutine 38 46 82.6
pod 39 40 97.5
total 134 161 83.2


line stmt bran cond sub pod time code
1             package Web::Machine::Resource;
2             BEGIN {
3 12     12   14480 $Web::Machine::Resource::AUTHORITY = 'cpan:STEVAN';
4             }
5             # ABSTRACT: A base resource class
6             $Web::Machine::Resource::VERSION = '0.15';
7 12     12   91 use strict;
  12         26  
  12         378  
8 12     12   62 use warnings;
  12         29  
  12         430  
9              
10 12     12   62 use Carp qw[ confess ];
  12         25  
  12         778  
11 12     12   72 use Scalar::Util qw[ blessed ];
  12         27  
  12         9539  
12              
13             sub new {
14 123     123 0 183035 my ($class, %args) = @_;
15              
16 123 50 33     2437 (exists $args{'request'} && blessed $args{'request'} && $args{'request'}->isa('Plack::Request'))
      33        
17             || confess "You must supply a request and it must be a Plack::Request";
18              
19 123 50 33     1601 (exists $args{'response'} && blessed $args{'response'} && $args{'response'}->isa('Plack::Response'))
      33        
20             || confess "You must supply a response and it must be a Plack::Response";
21              
22 123         696 my $self = bless {
23             request => $args{'request'},
24             response => $args{'response'},
25             } => $class;
26              
27 123         952 $self->init( \%args );
28 123         467 $self;
29             }
30              
31 123     123 1 210 sub init {}
32              
33 327     327 1 1778 sub request { (shift)->{'request'} }
34 255     255 1 865 sub response { (shift)->{'response'} }
35              
36             # NOTE:
37             # this is where we deviate from
38             # the Erlang/Ruby versions
39             # - SL
40 9     9 1 56 sub create_path_after_handler { 0 }
41              
42 58     58 1 369 sub resource_exists { 1 }
43 121     121 1 775 sub service_available { 1 }
44 112     112 1 4655 sub is_authorized { 1 }
45 111     111 1 657 sub forbidden { 0 }
46 0     0 1 0 sub allow_missing_post { 0 }
47 117     117 1 658 sub malformed_request { 0 }
48 119     119 1 94969 sub uri_too_long { 0 }
49 109     109 1 1560 sub known_content_type { 1 }
50 110     110 1 910 sub valid_content_headers { 1 }
51 108     108 1 1637 sub valid_entity_length { 1 }
52 0     0 1 0 sub options { +{} }
53 54     54 1 271 sub allowed_methods { [qw[ GET HEAD ]] }
54 118     118 1 760 sub known_methods { [qw[ GET HEAD POST PUT DELETE TRACE CONNECT OPTIONS ]]}
55 0     0 1 0 sub delete_resource { 0 }
56 0     0 1 0 sub delete_completed { 1 }
57 1     1 1 1141 sub post_is_create { 0 }
58 0     0 1 0 sub create_path { undef }
59 3     3 1 24 sub base_uri { undef }
60 0     0 1 0 sub process_post { 0 }
61 0     0 1 0 sub content_types_provided { [] }
62 0     0 1 0 sub content_types_accepted { [] }
63 44     44 1 241 sub charsets_provided { [] }
64 88     88 1 400 sub default_charset {}
65 37     37 1 181 sub languages_provided { [] }
66 131     131 1 708 sub encodings_provided { { 'identity' => sub { $_[1] } } }
  150     150   1180  
67 93     93 1 330 sub variances { [] }
68 7     7 1 34 sub is_conflict { 0 }
69 38     38 1 183 sub multiple_choices { 0 }
70 2     2 1 11 sub previously_existed { 0 }
71 24     24 1 101 sub moved_permanently { 0 }
72 16     16 1 83 sub moved_temporarily { 0 }
73 36     36 1 220 sub last_modified { undef }
74 43     43 1 200 sub expires { undef }
75 37     37 1 158 sub generate_etag { undef }
76 119     119 1 314 sub finish_request {}
77              
78             1;
79              
80             __END__