File Coverage

blib/lib/X11/Muralis/Backend.pm
Criterion Covered Total %
statement 9 34 26.4
branch 0 6 0.0
condition 0 3 0.0
subroutine 3 8 37.5
pod 5 5 100.0
total 17 56 30.3


line stmt bran cond sub pod time code
1             package X11::Muralis::Backend;
2 1     1   5 use strict;
  1         2  
  1         26  
3 1     1   5 use warnings;
  1         2  
  1         45  
4              
5             =head1 NAME
6              
7             X11::Muralis::Backend - display backend for X11::Muralis
8              
9             =head1 VERSION
10              
11             This describes version B<0.1001> of X11::Muralis::Backend.
12              
13             =cut
14              
15             our $VERSION = '0.1001';
16              
17             =head1 SYNOPSIS
18              
19             muralis --use I
20              
21             =head1 DESCRIPTION
22              
23             This is the base class for backend modules for X11::Muralis.
24             Generally speaking, the only methods that backends need to override
25             are "new" and "display".
26              
27             =cut
28              
29 1     1   5 use File::Spec;
  1         1  
  1         393  
30              
31             =head1 METHODS
32              
33             =head2 new
34              
35             There are two parameters that need to be set in "new";
36              
37             =over
38              
39             =item prog
40              
41             The name of the program which is used as the backend.
42              
43             =item can_do
44              
45             A hash containing the features that the backend provides.
46              
47             =back
48              
49             =cut
50              
51             sub new {
52 0     0 1   my $class = shift;
53 0           my %parameters = @_;
54 0   0       my $self = bless ({%parameters}, ref ($class) || $class);
55 0           return ($self);
56             } # new
57              
58             =head2 name
59              
60             The name of the backend; this is basically the last component
61             of the module name. This works as either a class function or a method.
62              
63             $name = $self->name();
64              
65             $name = X11::Muralis::Backend::name($class);
66              
67             =cut
68              
69             sub name {
70 0     0 1   my $class = shift;
71            
72 0 0         my $fullname = (ref ($class) ? ref ($class) : $class);
73              
74 0           my @bits = split('::', $fullname);
75 0           return pop @bits;
76             } # name
77              
78             =head2 active
79              
80             Returns true if the backend program is available to run.
81             This is checked by searching the PATH environment variable and checking
82             for the existence of $self->{prog}
83              
84             =cut
85              
86             sub active {
87 0     0 1   my $self = shift;
88              
89 0           my @path = split(':', $ENV{PATH});
90 0           my $found = 0;
91 0           foreach my $dir (@path)
92             {
93 0           my $file = File::Spec->catfile($dir, $self->{prog});
94 0 0         if (-f $file)
95             {
96 0           $found = 1;
97 0           last;
98             }
99             }
100 0           return $found;
101             } # active
102              
103             =head2 provides
104              
105             Returns a hash of the features the backend has enabled.
106              
107             =cut
108              
109             sub provides {
110 0     0 1   my $self = shift;
111              
112 0           my %prov = ();
113 0 0         if (defined $self->{can_do})
114             {
115 0           %prov = %{$self->{can_do}};
  0            
116             }
117 0           return %prov;
118             } # provides
119              
120             =head2 display
121              
122             Display the file, with the given options.
123             THis must be overridden by the specific backend class.
124              
125             =cut
126              
127             sub display {
128 0     0 1   my $self = shift;
129              
130 0           return 0;
131             } # display
132              
133             =head1 REQUIRES
134              
135             File::Spec
136              
137             =head1 INSTALLATION
138              
139             To install this module, run the following commands:
140              
141             perl Build.PL
142             ./Build
143             ./Build test
144             ./Build install
145              
146             Or, if you're on a platform (like DOS or Windows) that doesn't like the
147             "./" notation, you can do this:
148              
149             perl Build.PL
150             perl Build
151             perl Build test
152             perl Build install
153              
154             In order to install somewhere other than the default, such as
155             in a directory under your home directory, like "/home/fred/perl"
156             go
157              
158             perl Build.PL --install_base /home/fred/perl
159              
160             as the first step instead.
161              
162             This will install the files underneath /home/fred/perl.
163              
164             You will then need to make sure that you alter the PERL5LIB variable to
165             find the modules, and the PATH variable to find the script.
166              
167             Therefore you will need to change:
168             your path, to include /home/fred/perl/script (where the script will be)
169              
170             PATH=/home/fred/perl/script:${PATH}
171              
172             the PERL5LIB variable to add /home/fred/perl/lib
173              
174             PERL5LIB=/home/fred/perl/lib:${PERL5LIB}
175              
176             =head1 SEE ALSO
177              
178             perl(1).
179              
180             =head1 BUGS
181              
182             Please report any bugs or feature requests to the author.
183              
184             =head1 AUTHOR
185              
186             Kathryn Andersen RUBYKAT
187             perlkat AT katspace DOT org
188             www.katspace.org
189              
190             =head1 COPYRIGHT AND LICENCE
191              
192             Copyright (c) 2008 by Kathryn Andersen
193              
194             This program is free software; you can redistribute it and/or modify it
195             under the same terms as Perl itself.
196              
197             =cut
198              
199             1; # End of X11::Muralis::Backend
200             __END__