PDL.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 90 CC 4 SCAR 11.8
CC
4
Cov
0%
plugin_enable
6.0
editor_enable
6.0
editor_changed
6.0
CRAP 3.3
1 package Padre::Plugin::PDL;
2  
3 use 5.008;
4 use strict;
5 use warnings;
6 use Padre::Plugin ();
7  
8 our $VERSION = '0.05';
9  
10 our @ISA = 'Padre::Plugin';
11  
12 # Child modules we need to unload when disabled
13 use constant CHILDREN => qw{
14 Padre::Plugin::PDL
15 Padre::Plugin::PDL::Document
16 Padre::Plugin::PDL::Help
17 Padre::Plugin::PDL::Util
18 };
19  
20 # Called when Padre wants to check what package versions this
21 # plugin needs
22 sub padre_interfaces {
23 return
24 'Padre::Plugin' => 0.94,
25 'Padre::Document' => 0.94,
26 'Padre::Wx::Main' => 0.94,
27 'Padre::Wx::Role::Main' => 0.94,
28 'Padre::Help' => 0.94,
29 ;
30 }
31  
32 # Called when Padre wants to knows what documents this Plugin supports
33 sub registered_documents {
34 return 'application/x-perl' => 'Padre::Plugin::PDL::Document',;
35 }
36  
37 # Called when Padre wants a name for the plugin
38 sub plugin_name {
39 Wx::gettext('PDL');
40 }
41  
42 # Called when the plugin is enabled by Padre
43 sub plugin_enable {
44 my $self = shift;
45  
46 # Read the plugin configuration, and
47 my $config = $self->config_read;
48 unless ( defined $config ) {
49  
50 # No configuration, let us create it
51 $config = {};
52 }
53  
54 #TODO initialize your configuration here
55  
56 # Write the plugin's configuration
57 $self->config_write($config);
58  
59 # Update configuration attribute
60 $self->{config} = $config;
61  
62 # Generate missing Padre's events
63 # TODO remove once Padre 0.96 is released
64 require Padre::Plugin::PDL::Role::NeedsPluginEvent;
65 Padre::Plugin::PDL::Role::NeedsPluginEvent->meta->apply( $self->main );
66  
67 # Highlight the current editor. This is needed when a plugin is enabled
68 # for the first time
69 $self->editor_changed;
70  
71 return 1;
72 }
73  
74 # Called when the plugin is disabled by Padre
75 sub plugin_disable {
76 my $self = shift;
77  
78 # TODO: Switch to Padre::Unload once Padre 0.96 is released
79 for my $package (CHILDREN) {
80 require Padre::Unload;
81 Padre::Unload->unload($package);
82 }
83 }
84  
85 # Called when Padre wants to display plugin menu items
86 #sub menu_plugins {
87 # my $self = shift;
88 # my $main = $self->main;
89 # my $menu_item = Wx::MenuItem->new( undef, -1, Wx::gettext('PDL') );
90 #
91 #
92 # Wx::Event::EVT_MENU(
93 # $main,
94 # $menu_item,
95 # sub {
96 # },
97 # );
98 #
99 # return $menu_item;
100 #}
101  
102 # Called when an editor is opened
103 sub editor_enable {
104 my $self = shift;
105 my $editor = shift;
106 my $document = shift;
107  
108 # Only on Perl documents
109 return unless $document->isa('Padre::Document::Perl');
110  
111 require Padre::Plugin::PDL::Util;
112 Padre::Plugin::PDL::Util::add_pdl_keywords_highlighting( $document, $editor );
113 }
114  
115 # Called when an editor is changed
116 sub editor_changed {
117 my $self = shift;
118 my $document = $self->current->document or return;
119 my $editor = $self->current->editor or return;
120  
121 # Only on Perl documents
122 return unless $document->isa('Padre::Document::Perl');
123  
124 require Padre::Plugin::PDL::Util;
125 Padre::Plugin::PDL::Util::add_pdl_keywords_highlighting( $document, $editor );
126 }
127  
128  
129 1;
130  
131 __END__