File Coverage

blib/lib/Tickit/Widgets.pm
Criterion Covered Total %
statement 8 13 61.5
branch 0 2 0.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 18 61.1


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2012 -- leonerd@leonerd.org.uk
5              
6             package Tickit::Widgets;
7              
8 1     1   506 use strict;
  1         2  
  1         26  
9 1     1   3 use warnings;
  1         2  
  1         126  
10              
11             our $VERSION = '0.25';
12              
13             =head1 NAME
14              
15             C - load several L classes at once
16              
17             =head1 SYNOPSIS
18              
19             use Tickit::Widgets qw( Static VBox HBox );
20              
21             Equivalent to
22              
23             use Tickit::Widget::Static;
24             use Tickit::Widget::VBox;
25             use Tickit::Widget::HBox;
26              
27             =head1 DESCRIPTION
28              
29             This module provides an C utility to simplify code that uses many
30             different L subclasses. Instead of a C line per module,
31             you can simply C this module and pass it the base name of each class.
32             It will C each of the modules.
33              
34             Note that because each Widget module should be a pure object class with no
35             exports, this utility does not run the C method of the used classes.
36              
37             =cut
38              
39             sub import
40             {
41 1     1   7 shift; # class
42              
43             # Only need to 'require' the modules because they're all clean object
44             # classes, no need to import any of them
45 1         7 foreach ( @_ ) {
46 0           my $class = $_; # $_ is alias to read-only values;
47 0           local $_; # placate bug in Tickit::RenderContext 0.06
48              
49 0 0         $class = "Tickit::Widget::$class" unless $class =~ m/::/;
50              
51 0           ( my $file = "$class.pm" ) =~ s{::}{/}g;
52              
53 0           require $file;
54             }
55             }
56              
57             =head1 AUTHOR
58              
59             Paul Evans
60              
61             =cut
62              
63             0x55AA;