lib/eris/role/plugin.pm

filter: Statementstmt 63.1% 12 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod n/a totaltotal 58.3% 14 / 24 CC 1 SCAR 4.7
CC
1
Cov
63%
_build_name
2.0
_build_priority
2.0
_build_enabled
2.0
CRAP 1.6
« script/eris-field-lookup.pl ↑ Summary lib/eris/dictionary/eris/debug.pm »
1 package eris::role::plugin;
2 # ABSTRACT: Common interface for implementing an eris plugin
3  
4 25 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use Types::Standard qw(Bool Int Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 25 our $VERSION = '0.008'; # VERSION
8  
9  
10  
11  
12 25 has name => (
13 is => 'lazy',
14 isa => Str,
15 );
16  
17 sub _build_name {
18 0 ▶ my ($self) = @_;
Subroutine _build_name: not called CC=1 SCAR=6.9
19 0 my ($class) = ref $self;
20 0 my ($namespace) = $self->namespace;
21 # Trim Name Space
22 0 my $name = $class =~ s/^${namespace}:://r;
23  
24 # Replace colons with underscores
25 0 return $name =~ s/::/_/gr;
26 }
27  
28  
29 25 has 'priority' => (
30 is => 'lazy',
31 isa => Int,
32 );
33 0 ▶sub _build_priority { 50 }
Subroutine _build_priority: not called CC=1 SCAR=6.9
34  
35  
36 25 has 'enabled' => (
37 is => 'lazy',
38 isa => Bool,
39 );
40 0 ▶sub _build_enabled { 1 }
Subroutine _build_enabled: not called CC=1 SCAR=6.9
41  
42  
43 25 has 'namespace' => (
44 is => 'ro',
45 isa => Str,
46 required => 1,
47 );
48  
49  
50 25 1;
51  
52 __END__
53  
54 =pod
55  
56 =encoding UTF-8
57  
58 =head1 NAME
59  
60 eris::role::plugin - Common interface for implementing an eris plugin
61  
62 =head1 VERSION
63  
64 version 0.008
65  
66 =head1 SYNOPSIS
67  
68 Sprinkled into other plugins in the eris project to set
69 expectations for the plugin loaders
70  
71 package eris::role::context;
72  
73 use Moo::Role;
74 with qw( eris::role::plugin );
75  
76 =head1 ATTRIBUTES
77  
78 =head2 name
79  
80 The name of the plugin. Defaults to stripping the plugin namespace from the
81 object's class name and replacing '::' within an underscore.
82  
83 =head2 priority
84  
85 An integer representing the priority ordering of the plugin in loading, lower
86 priority will appear in the beginning of the plugins list. Defaults to 50.
87  
88 =head2 enabled
89  
90 Boolean indicating if the plugin is enabled by default. Defaults
91 to true. The L<eris::dictionary::eris::debug> uses this set to false
92 to prevent it's data from accidentally entering the default schemas.
93  
94 =head2 namespace
95  
96 The primary namespace for these plugins. This is used to auto_trim it from the
97 plugin's name for simpler config templates.
98  
99 This is a B<required> parameter.
100  
101 =head1 SEE ALSO
102  
103 L<eris::role::pluggable>, L<eris::role::context>, L<eris::role::decoder>, L<eris::role::dictionary>
104 L<eris::role::schema>
105  
106 =head1 AUTHOR
107  
108 Brad Lhotsky <brad@divisionbyzero.net>
109  
110 =head1 COPYRIGHT AND LICENSE
111  
112 This software is Copyright (c) 2015 by Brad Lhotsky.
113  
114 This is free software, licensed under:
115  
116 The (three-clause) BSD License
117  
118 =cut
« script/eris-field-lookup.pl ↑ Summary lib/eris/dictionary/eris/debug.pm »