« 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$name and $self->registry and $self->load_order
$name and $self->registry
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | for my $long (@{$self->load_order}) { | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $entry = $self->registry->{$long} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | next unless $entry->{templates}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if (exists $entry->{templates}{$normalized}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $entry->{short_name}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||||||||||||||||