Ext/Plugin.pm

filter: Statementstmt 51.3% 57 / 111 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 52.9% 18 / 34 Podpod 100% 11 / 11 totaltotal 46.4% 86 / 185 CC 9 SCAR 12.3
CC
9
Cov
44%
_add_autocmd
12.9
_add_command
7.4
_add_function
7.4
CRAP 3.4
« Ext/Common.pm ↑ Summary Ext/Window.pm »
1 package Neovim::Ext::Plugin;
2 1 $Neovim::Ext::Plugin::VERSION = '0.01';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw/Class::Accessor/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Attribute::Handlers;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 Neovim::Ext::Plugin->mk_accessors (qw/nvim host/);
8  
9 sub register
10 {
11 0 ▶ require Neovim::Ext::Plugin::Host;
Subroutine register: not called CC=1 SCAR=6.9
Pod documented
12 0 Neovim::Ext::Plugin::Host->register (shift);
13 }
14  
15  
16 # attributes (decorators)
17 sub nvim_command :ATTR(CODE,BEGIN)
18 {
19 0 ▶ my ($package, $symbol, $sub, $attr, $data) = @_;
Subroutine nvim_command: not called CC=1 SCAR=6.9
Pod documented
20 0 $package->_add_command ($sub, @$data);
21 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 sub nvim_autocmd :ATTR(CODE,BEGIN)
24 {
25 0 ▶ my ($package, $symbol, $sub, $attr, $data) = @_;
Subroutine nvim_autocmd: not called CC=1 SCAR=6.9
Pod documented
26 0 $package->_add_autocmd ($sub, @$data);
27 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 sub nvim_function :ATTR(CODE,BEGIN)
30 {
31 0 ▶ my ($package, $symbol, $sub, $attr, $data) = @_;
Subroutine nvim_function: not called CC=1 SCAR=6.9
Pod documented
32 0 $package->_add_function ($sub, @$data);
33 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 sub nvim_shutdown_hook :ATTR(CODE,BEGIN)
36 {
37 0 ▶ my ($package, $symbol, $sub, $attr, $data) = @_;
Subroutine nvim_shutdown_hook: not called CC=1 SCAR=6.9
Pod documented
38 0 $package->_add_shutdown_hook ($sub, @$data);
39 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41  
42  
43 sub get_specs
44 {
45 0 ▶ my ($package) = @_;
Subroutine get_specs: not called CC=1 SCAR=1.2
Pod documented
46 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
47 0 return \@{$package.'::specs'};
48 }
49  
50  
51  
52 sub _add_spec
53 {
54 0 ▶ my ($package, $spec) = @_;
Subroutine _add_spec: not called CC=1 SCAR=1.2
55 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
56 0 push @{$package.'::specs'}, $spec;
57 }
58  
59  
60  
61 sub _add_command
62 {
63 0 ▶ my ($package, $symbol, $name, %options) = @_;
Subroutine _add_command: not called CC=3 SCAR=20.0
64  
65 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
66 0 push @{$package.'::commands'},
67 {
68 type => 'command',
69 name => $name,
70 symbol => $symbol,
71 options => \%options,
72 };
73  
74 0 ▶ if (!$options{sync} && delete $options{allow_nested})
Branch: 1 branch
BranchTrueFalseTotal
if (not $options{"sync"} and delete $options{"allow_nested"}) 0 0 0
Condition0%0/3
not $options{"sync"} and delete $options{"allow_nested"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $options{"sync"} and delete $options{"allow_nested"}
not $options{"sync"} delete $options{"allow_nested"}
Truth table0%0/3
not(A) and B
A= not $options{"sync"}B= delete $options{"allow_nested"}
ABresult
0X0
100
111
75 {
76 0 $options{sync} = 'urgent';
77 }
78  
79 $package->_add_spec
80 (
81 {
82 type => 'command',
83 name => $name,
84 sync => !!$options{sync},
85 0 opts => \%options,
86 }
87 );
88 }
89  
90  
91  
92 sub get_commands
93 {
94 0 ▶ my ($package) = @_;
Subroutine get_commands: not called CC=1 SCAR=1.2
Pod documented
95 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
96 0 return @{$package.'::commands'};
97 }
98  
99  
100  
101 sub _add_autocmd
102 {
103 0 ▶ my ($package, $symbol, $name, %options) = @_;
Subroutine _add_autocmd: not called CC=4 SCAR=25.6
104  
105 0 ▶ $options{pattern} //= '*';
Condition0%0/2
$options{"pattern"} //= "*"
l!l
00
MC/DC0%0/1
$options{"pattern"} //= "*"
$options{"pattern"}
Truth table0%0/2
A
A= $options{"pattern"}
Aresult
11
00
106  
107 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
108 0 push @{$package.'::autocmds'},
109 {
110 type => 'autocmd',
111 name => $name,
112 symbol => $symbol,
113 options => \%options,
114 };
115  
116 0 ▶ if (!$options{sync} && delete $options{allow_nested})
Branch: 1 branch
BranchTrueFalseTotal
if (not $options{"sync"} and delete $options{"allow_nested"}) 0 0 0
Condition0%0/3
not $options{"sync"} and delete $options{"allow_nested"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $options{"sync"} and delete $options{"allow_nested"}
not $options{"sync"} delete $options{"allow_nested"}
Truth table0%0/3
not(A) and B
A= not $options{"sync"}B= delete $options{"allow_nested"}
ABresult
0X0
100
111
117 {
118 0 $options{sync} = 'urgent';
119 }
120  
121 $package->_add_spec
122 (
123 {
124 type => 'autocmd',
125 name => $name,
126 sync => !!$options{sync},
127 0 opts => \%options,
128 }
129 );
130 }
131  
132  
133  
134 sub get_autocmds
135 {
136 0 ▶ my ($package) = @_;
Subroutine get_autocmds: not called CC=1 SCAR=1.2
Pod documented
137 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
138 0 return @{$package.'::autocmds'};
139 }
140  
141  
142  
143 sub _add_function
144 {
145 0 ▶ my ($package, $symbol, $name, %options) = @_;
Subroutine _add_function: not called CC=3 SCAR=20.0
146  
147 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
148 0 push @{$package.'::functions'},
149 {
150 type => 'function',
151 name => $name,
152 symbol => $symbol,
153 options => \%options,
154 };
155  
156 0 ▶ if (!$options{sync} && delete $options{allow_nested})
Branch: 1 branch
BranchTrueFalseTotal
if (not $options{"sync"} and delete $options{"allow_nested"}) 0 0 0
Condition0%0/3
not $options{"sync"} and delete $options{"allow_nested"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $options{"sync"} and delete $options{"allow_nested"}
not $options{"sync"} delete $options{"allow_nested"}
Truth table0%0/3
not(A) and B
A= not $options{"sync"}B= delete $options{"allow_nested"}
ABresult
0X0
100
111
157 {
158 0 $options{sync} = 'urgent';
159 }
160  
161 $package->_add_spec
162 (
163 {
164 type => 'function',
165 name => $name,
166 sync => !!$options{sync},
167 0 opts => \%options,
168 }
169 );
170 }
171  
172  
173  
174 sub get_functions
175 {
176 0 ▶ my ($package) = @_;
Subroutine get_functions: not called CC=1 SCAR=1.2
Pod documented
177 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
178 0 return @{$package.'::functions'};
179 }
180  
181  
182  
183 sub _add_shutdown_hook
184 {
185 0 ▶ my ($package, $symbol) = @_;
Subroutine _add_shutdown_hook: not called CC=1 SCAR=1.2
186  
187 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
188 0 push @{$package.'::shutdown_hooks'}, $symbol;
189 }
190  
191  
192  
193 sub get_shutdown_hooks
194 {
195 0 ▶ my ($package) = @_;
Subroutine get_shutdown_hooks: not called CC=1 SCAR=1.2
Pod documented
196 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
197 0 return @{$package.'::shutdown_hooks'};
198 }
199  
200  
201  
202 sub new
203 {
204 0 ▶ my ($this, $nvim, $host) = @_;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
205  
206 0 ▶ my $class = ref ($this) || $this;
Condition0%0/3
ref $this || $this
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table0%0/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
207 0 my $self =
208 {
209 nvim => $nvim,
210 host => $host,
211 };
212  
213 0 return bless $self, $class;
214 }
215  
216 =head1 NAME
217  
218 Neovim::Ext::Plugin - Neovim Plugin class
219  
220 =head1 VERSION
221  
222 version 0.01
223  
224 =head1 SYNOPSIS
225  
226 use Neovim::Ext;
227  
228 =head1 METHODS
229  
230 =head2 new( $nvim )
231  
232 Create a new plugin instance.
233  
234 =head2 register( )
235  
236 Register the plugin. This should be called as soon as possible.
237  
238 =head2 nvim_command( )
239  
240 Subroutine attribute to export a subroutine as a Vim command.
241  
242 =head2 nvim_autocmd( )
243  
244 Subroutine attribute to export a subroutine as a Vim autocmd.
245  
246 =head2 nvim_function( )
247  
248 Subroutine attribute to export a subroutine as a Vim function.
249  
250 =head2 nvim_shutdown_hook( )
251  
252 Subroutine attribute to export a subroutine as a shutdown hook.
253  
254 =head2 get_commands( )
255  
256 Get all exported commands for the plugin.
257  
258 =head2 get_functions( )
259  
260 Get all exported functions for the plugin.
261  
262 =head2 get_autocmds( )
263  
264 Get all exported autocmds for the plugin.
265  
266 =head2 get_shutdown_hooks( )
267  
268 Get all shutdown hooks for the plugin.
269  
270 =head2 get_specs( )
271  
272 Get all specs for the plugin.
273  
274 =cut
275  
276 1 1;
« Ext/Common.pm ↑ Summary Ext/Window.pm »