| 1 | package Catalyst::Controller::Atompub::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Atompub::DateTime qw(datetime); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Atompub::MediaType qw(media_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Catalyst::Controller::Atompub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use HTTP::Status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use NEXT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use base qw(Catalyst::Controller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | __PACKAGE__->mk_accessors(qw(info)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | my($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | my $self = $class->NEXT::new(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | $self->info( Catalyst::Controller::Atompub::Info->instance($self) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my($self, $c, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | return if ! is_success $c->res->status && $c->res->body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &is_success(scalar $c->res->status) and $c->res->body
MC/DC0%0/2
not &is_success(scalar $c->res->status) and $c->res->body
not &is_success(scalar $c->res->status)
$c->res->body
Truth table0%0/3
not(A) and B
A= not &is_success(scalar $c->res->status)B= $c->res->body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my($status, $message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/6
@args == 1 and $args[0] =~ /^([1-5]\d\d)\s*(.*)/
@args == 1 and $args[0] =~ /^(.*)/
MC/DC0%0/2
@args == 1 and $args[0] =~ /^([1-5]\d\d)\s*(.*)/
@args == 1
$args[0] =~ /^([1-5]\d\d)\s*(.*)/
MC/DC0%0/2
@args == 1 and $args[0] =~ /^(.*)/
@args == 1
$args[0] =~ /^(.*)/
Truth table0%0/3
A and B
A= @args == 1B= $args[0] =~ /^([1-5]\d\d)\s*(.*)/
Truth table0%0/3
A and B
A= @args == 1B= $args[0] =~ /^(.*)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | = @args > 1 ? @args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | : @args == 1 && $args[0] =~ /^([1-5]\d\d)\s*(.*)/ ? ($1, $2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | : @args == 1 && $args[0] =~ /^(.*)/ ? ($2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $status ||= RC_INTERNAL_SERVER_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status ||= 500
MC/DC0%0/1
$status ||= 500
$status
Truth table0%0/2
A
A= $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $c->res->status($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $message ||= status_message($status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$message ||= &status_message($status)
MC/DC0%0/2
$message ||= &status_message($status)
$message
&status_message($status)
Truth table0%0/3
A ||= B
A= $messageB= &status_message($status)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $report = "$status $message"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $entry = XML::Atom::Entry->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $link = XML::Atom::Link->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $link->rel('related'); # XXX via? | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $link->href($c->req->uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $entry->add_link($link); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $entry->updated(datetime->w3c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $entry->title($report); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $entry->content($report); # XXX @type=text is better | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $c->res->body($entry->as_xml); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $c->res->content_type(media_type('entry')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $c->log->error($report); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | package Catalyst::Controller::Atompub::Info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | use Catalyst::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | use XML::Atom::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | __PACKAGE__->mk_accessors(qw(appclass)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | my $Info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 6 | ▶ | sub instance { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instance: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 6 | my($class, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6 | ▶ | $Info ||= bless { appclass => Catalyst::Utils::class2appclass($arg) }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$Info ||= bless({"appclass", Catalyst::Utils::class2appclass($arg)}, $class)
MC/DC100%1/1
$Info ||= bless({"appclass", Catalyst::Utils::class2appclass($arg)}, $class)
$Info
Truth table100%2/2
A
A= $Info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | $Info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | my($self, $c, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | ▶ | return unless $class = $self->_fullclass($c, $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 6 | ▶ | return unless $self->_is_collection($c, $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | my $collection = $self->{info}{$class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | ▶ | unless ($collection) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | my $suffix = Catalyst::Utils::class2classsuffix($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | my $config = $c->config->{$suffix}{collection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | $collection = XML::Atom::Collection->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | $collection->title($config->{title} || $class =~ /Controller::(.+)/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$config->{'title'} || $class =~ /Controller::(.+)/
MC/DC0%0/2
$config->{'title'} || $class =~ /Controller::(.+)/
$config->{'title'}
$class =~ /Controller::(.+)/
Truth table66%2/3
A || B
A= $config->{'title'}B= $class =~ /Controller::(.+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $collection->accept(@{ $config->{accept} }) if $config->{accept}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $collection->add_categories($self->_make_categories($c, $_)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | for @{ $config->{categories} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | $collection->href($class->make_collection_uri($c)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 4 | $collection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 6 | ▶ | sub _fullclass { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fullclass: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | my($self, $c, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 6 | ▶ | $class = ref $class || $class || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
ref $class || $class || (return)
ref $class or $class
MC/DC0%0/2
ref $class || $class || (return)
ref $class
$class
Truth table66%2/3
A or B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 6 | my $appclass = $self->appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | ▶ | $class =~ /^$appclass\::/ ? $class : join('::', $appclass, $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | ▶ | sub _is_collection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_collection: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 6 | my($self, $c, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 6 | UNIVERSAL::isa $class, 'Catalyst::Controller::Atompub::Collection'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub _make_categories { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_categories: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my($self, $c, $config) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | my $cats = XML::Atom::Categories->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | $cats->href($config->{href}) if $config->{href}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | $cats->fixed($config->{fixed}) if $config->{fixed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | $cats->scheme($config->{scheme}) if $config->{scheme}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | my @cat = map { my $cat = XML::Atom::Category->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | $cat->term($_->{term}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | $cat->scheme($_->{scheme}) if $_->{scheme}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | $cat->label($_->{label}) if $_->{label}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | $cat } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | @{ $config->{category} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $cats->category(@cat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | $cats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||