lib/Mojolicious/Plugin/Fondation/API.pm

filter: Statementstmt 56.0% 14 / 25 Branchbran 16.6% 2 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 3 totaltotal 37.0% 20 / 54 CC 11 SCAR 43.0
CC
11
Cov
37%
find_template_source
110.0
plugin
2.0
BEGIN
1.0
CRAP 73.8
« blib/lib/Mojolicious/Plugin/Fondation/Schema/Result/Base.pm ↑ Summary lib/Mojolicious/Plugin/Fondation/Command/fondation.pm »
1 package Mojolicious::Plugin::Fondation::API;
2 16 $Mojolicious::Plugin::Fondation::API::VERSION = '0.08';
3 # ABSTRACT: Stable public contract for Fondation plugins -- read-only access
4  
5 16 ▶use Mojo::Base -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 has 'registry';
8 16 has 'load_order';
9  
10 # ---------------------------------------------------------------------------
11 # plugin($name) -- returns a specific plugin's merged config hashref
12 #
13 # $name can be a short name ('Fondation::User') or a long name
14 # ('Mojolicious::Plugin::Fondation::User').
15 # Returns undef if the plugin is not in the registry.
16 # ---------------------------------------------------------------------------
17 6 ▶sub plugin ($self, $name) {
Subroutine plugin: called CC=2 SCAR=6.9
Pod undocumented
18 6 my $long = $self->_resolve_long($name);
19 6 my $entry = $self->registry->{$long};
20 6 ▶ return unless $entry;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry 1 5 6
21 5 return $entry->{config};
22 }
23  
24 # ---------------------------------------------------------------------------
25 # config($name) -- alias for plugin(), returns merged config
26 # ---------------------------------------------------------------------------
27 3 ▶sub config ($self, $name) {
Subroutine config: called CC=1 SCAR=0.0
Pod undocumented
28 3 return $self->plugin($name);
29 }
30  
31 # ---------------------------------------------------------------------------
32 # _resolve_long -- normalizes a name to its long form
33 # ---------------------------------------------------------------------------
34 6 ▶sub _resolve_long ($self, $name) {
Subroutine _resolve_long: called CC=1 SCAR=0.0
35 6 require Mojolicious::Plugin::Fondation::Utils;
36 6 return Mojolicious::Plugin::Fondation::Utils::long_name($name);
37 }
38  
39 0 ▶sub find_template_source ($self, $name = '') {
Subroutine find_template_source: not called CC=10 SCAR=47.0
Pod undocumented
40 0 ▶ return undef unless $name && $self->registry && $self->load_order;
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $self->registry and $self->load_order 0 0 0
Condition0%0/6
$name and $self->registry and $self->load_order
!ll&&!rl&&r
000
$name and $self->registry
!ll&&!rl&&r
000
MC/DC0%0/3
$name and $self->registry and $self->load_order
$name $self->registry $self->load_order
Truth table0%0/4
A and B and C
A= $nameB= $self->registryC= $self->load_order
ABCresult
0XX0
10X0
1100
1111
41  
42 # Normalize to .html.ep format
43 0 my $normalized = $name;
44 0 ▶ $normalized .= '.html.ep' unless $normalized =~ /\.html\.ep$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $normalized =~ /\.html\.ep$/iu 0 0 0
45  
46 0 for my $long (@{$self->load_order}) {
47 0 ▶ my $entry = $self->registry->{$long} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $entry = $self->registry->{$long} or next 0 0 0
48 0 ▶ next unless $entry->{templates};
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->{"templates"} 0 0 0
49  
50 0 ▶ if (exists $entry->{templates}{$normalized}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $entry->{"templates"}{$normalized}) 0 0 0
51 0 return $entry->{short_name};
52 }
53 }
54 0 return undef;
55 }
56  
57 16 1;
58  
59 __END__
« blib/lib/Mojolicious/Plugin/Fondation/Schema/Result/Base.pm ↑ Summary lib/Mojolicious/Plugin/Fondation/Command/fondation.pm »