File Coverage

blib/lib/IPerl.pm
Criterion Covered Total %
statement 32 32 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 1 3 33.3
total 43 46 93.4


line stmt bran cond sub pod time code
1             package # hide from PAUSE
2             IPerl;
3              
4 2     2   136875 use strict;
  2         12  
  2         50  
5 2     2   8 use warnings;
  2         3  
  2         39  
6 2     2   476 use Moo;
  2         10251  
  2         9  
7             with qw( MooX::Singleton );
8              
9             our $REPL;
10             our $current_msg;
11              
12             has helpers => ( is => 'rw', default => sub { +{} } );
13              
14             my ($class, $name, $cb) = @_;
15 18     18 1 36 my $self = $class->instance;
16 18         38 warn (qq{Helper "$name" already exists, replacing.})
17             if exists $self->helpers->{$name};
18 18 50       146 $self->add_helper($name => $cb);
19 18         29 }
20              
21             my ($self, $name, $cb) = @_;
22             $self->helpers->{$name} = $cb;
23 18     18 0 28 {
24 18         37 no strict 'refs';
25             no warnings 'redefine';
26 2     2   1896 *{"IPerl::$name"} = $cb;
  2         4  
  2         71  
  18         19  
27 2     2   12 }
  2         2  
  2         167  
28 18         18 }
  18         96  
29              
30             my ($class, $plugin_name) = @_;
31             my $plugin_package = "Devel::IPerl::Plugin::$plugin_name";
32             { no strict; eval "require $plugin_package"; }
33 5     5 0 2275 $plugin_package->register( $class );
34 5         14 }
35 2     2   11  
  2         4  
  2         145  
  5         8  
  5         316  
36 5         49 1;
37              
38              
39             =pod
40              
41             =encoding UTF-8
42              
43             =head1 NAME
44              
45             IPerl
46              
47             =head1 VERSION
48              
49             version 0.012
50              
51             =head1 METHODS
52              
53             =head2 helper
54              
55             IPerl->helper( $name, $coderef )
56              
57             Register helper callback.
58              
59             =head1 AUTHOR
60              
61             Zakariyya Mughal <zmughal@cpan.org>
62              
63             =head1 COPYRIGHT AND LICENSE
64              
65             This software is copyright (c) 2014 by Zakariyya Mughal.
66              
67             This is free software; you can redistribute it and/or modify it under
68             the same terms as the Perl 5 programming language system itself.
69              
70             =cut