blib/lib/X11/Muralis/Backend.pm

filter: Statementstmt 30.5% 11 / 36 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 100% 5 / 5 totaltotal 31.6% 19 / 60 CC 6 SCAR 17.8
CC
6
Cov
24%
active
12.0
new
6.0
name
6.0
CRAP 5.9
« blib/lib/X11/Muralis/Backend/Feh.pm ↑ Summary Build »
1 package X11::Muralis::Backend;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 2 our $VERSION = '0.1001';
16  
17 =head1 SYNOPSIS
18  
19 muralis --use I<backend>
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 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 ▶ my $class = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
53 0 my %parameters = @_;
54 0 ▶ my $self = bless ({%parameters}, ref ($class) || $class);
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
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 ▶ my $class = shift;
Subroutine name: not called CC=2 SCAR=17.9
Pod documented
71
72 0 ▶ my $fullname = (ref ($class) ? ref ($class) : $class);
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
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 ▶ my $self = shift;
Subroutine active: not called CC=3 SCAR=24.8
Pod documented
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 ▶ if (-f $file)
Branch: 1 branch
BranchTrueFalseTotal
if (-f $file) 0 0 0
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 ▶ my $self = shift;
Subroutine provides: not called CC=2 SCAR=17.9
Pod documented
111  
112 0 my %prov = ();
113 0 ▶ if (defined $self->{can_do})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"can_do"}) 0 0 0
114 {
115 0 %prov = %{$self->{can_do}};
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 ▶ my $self = shift;
Subroutine display: not called CC=1 SCAR=6.9
Pod documented
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 2 1; # End of X11::Muralis::Backend
200 __END__
« blib/lib/X11/Muralis/Backend/Feh.pm ↑ Summary Build »