blib/lib/App/Info/Lib/OSSPUUID.pm

filter: Statementstmt 83.2% 139 / 167 Branchbran 54.6% 47 / 86 Conditioncond 22.2% 4 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 80.5% 29 / 36 Podpod 95.0% 19 / 20 totaltotal 70.6% 238 / 337 CC 50 SCAR 17.0
CC
50
Cov
70%
__ANON__
20.0
__ANON__
14.7
version
9.3
CRAP 5.5
« lib/App/Info/RDBMS/PostgreSQL.pm ↑ Summary blib/lib/App/Info/HTTPD/Apache.pm »
1 package App::Info::Lib::OSSPUUID;
2  
3 =head1 NAME
4  
5 App::Info::Lib::OSSPUUID - Information about the OSSP UUID library
6  
7 =head1 SYNOPSIS
8  
9 use App::Info::Lib::OSSPUUID;
10  
11 my $uuid = App::Info::Lib::OSSPUUID->new;
12  
13 if ($uuid->installed) {
14 print "App name: ", $uuid->name, "\n";
15 print "Version: ", $uuid->version, "\n";
16 print "Bin dir: ", $uuid->bin_dir, "\n";
17 } else {
18 print "Expat is not installed. :-(\n";
19 }
20  
21 =head1 DESCRIPTION
22  
23 App::Info::Lib::OSSPUUID supplies information about the OSSP UUID library
24 installed on the local system. It implements all of the methods defined by
25 App::Info::Lib. Methods that trigger events will trigger them only the first
26 time they're called (See L<App::Info|App::Info> for documentation on handling
27 events). To start over (after, say, someone has installed the OSSP UUID
28 library) construct a new App::Info::Lib::OSSPUUID object to aggregate new
29 meta data.
30  
31 Some of the methods trigger the same events. This is due to cross-calling of
32 shared subroutines. However, any one event should be triggered no more than
33 once. For example, although the info event "Executing `uuid-config --version`"
34 is documented for the methods C<name()> C<version()>, C<major_version()>,
35 C<minor_version()>, and C<patch_version()>, rest assured that it will only be
36 triggered once, by whichever of those four methods is called first.
37  
38 =cut
39  
40 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 2 ▶use App::Info::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 2 ▶use App::Info::Lib;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 2 ▶use File::Spec::Functions 'catfile';
Subroutine BEGIN: called CC=1 SCAR=0.0
44 2 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
45 2 @ISA = qw(App::Info::Lib);
46 2 $VERSION = '0.57';
47 2 ▶use constant WIN32 => $^O eq 'MSWin32';
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 2 my $u = App::Info::Util->new;
50  
51 ##############################################################################
52  
53 =head1 INTERFACE
54  
55 =head2 Constructor
56  
57 =head3 new
58  
59 my $expat = App::Info::Lib::OSSPUUID->new(@params);
60  
61 Returns an App::Info::Lib::OSSPUUID object. See L<App::Info|App::Info> for a
62 complete description of argument parameters.
63  
64 When called, C<new()> searches all of the paths returned by the
65 C<search_lib_dirs()> method for one of the files returned by the
66 C<search_lib_names()> method. If any of is found, then the OSSP UUID library
67 is assumed to be installed. Otherwise, most of the object methods will return
68 C<undef>.
69  
70 B<Events:>
71  
72 =over 4
73  
74 =item info
75  
76 Looking for uuid-config
77  
78 =item confirm
79  
80 Path to uuid-config?
81  
82 =item unknown
83  
84 Path to uuid-config?
85  
86 =back
87  
88 =cut
89  
90 2 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
91 # Construct the object.
92 2 my $self = shift->SUPER::new(@_);
93  
94 # Find uuid-config.
95 2 $self->info("Looking for uuid-config");
96  
97 2 my @paths = $self->search_bin_dirs;
98 2 my @exes = $self->search_exe_names;
99  
100 2 ▶ if (my $cfg = $u->first_cat_exe(\@exes, @paths)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cfg = $u->first_cat_exe(\@exes, @paths)) { } 1 1 2
101 # We found it. Confirm.
102 $self->{uuid_config} = $self->confirm(
103 key => 'path to uuid-config',
104 prompt => "Path to uuid-config?",
105 value => $cfg,
106 0 ▶ callback => sub { -x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
107 1 error => 'Not an executable'
108 );
109 } else {
110 # Handle an unknown value.
111 $self->{uuid_config} = $self->unknown(
112 key => 'path to uuid-config',
113 prompt => "Path to uuid-config?",
114 0 ▶ callback => sub { -x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
115 1 error => 'Not an executable'
116 );
117 }
118  
119 # Set up search defaults.
120 2 ▶ if (exists $self->{search_uuid_names}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'search_uuid_names'}) { } 1 1 2
121 $self->{search_uuid_names} = [$self->{search_uuid_names}]
122 1 ▶ unless ref $self->{search_uuid_names} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"search_uuid_names"} eq "ARRAY" 1 0 1
123 } else {
124 1 $self->{search_uuid_names} = [];
125 }
126  
127 2 return $self;
128 }
129  
130 # We'll use this code reference as a common way of collecting data.
131 6 ▶my $get_data = sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
132 6 ▶ return unless $_[0]->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]{"uuid_config"} 0 6 6
133 6 $_[0]->info(qq{Executing `"$_[0]->{uuid_config}" $_[1]`});
134 6 my $info = `"$_[0]->{uuid_config}" $_[1]`;
135 6 chomp $info;
136 6 return $info;
137 2 };
138  
139  
140 ##############################################################################
141  
142 =head2 Class Method
143  
144 =head3 key_name
145  
146 my $key_name = App::Info::Lib::OSSPUUID->key_name;
147  
148 Returns the unique key name that describes this class. The value returned is
149 the string "OSSP UUID".
150  
151 =cut
152  
153 1 ▶sub key_name { 'OSSP UUID' }
Subroutine key_name: called CC=1 SCAR=0.0
Pod documented
154  
155 ##############################################################################
156  
157 =head2 Object Methods
158  
159 =head3 installed
160  
161 print "UUID is ", ($uuid->installed ? '' : 'not '), "installed.\n";
162  
163 Returns true if the OSSP UUID library is installed, and false if it is not.
164 App::Info::Lib::OSSPUUID determines whether the library is installed based on
165 the presence or absence on the file system of the C<uuid-config> application,
166 searched for when C<new()> constructed the object. If the OSSP UUID library
167 does not appear to be installed, then most of the other object methods will
168 return empty values.
169  
170 =cut
171  
172 2 ▶sub installed { $_[0]->{uuid_config} ? 1 : undef }
Subroutine installed: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'uuid_config'} ? : 1 1 2
173  
174 ##############################################################################
175  
176 =head3 name
177  
178 my $name = $uuid->name;
179  
180 Returns the name of the library. App::Info::Lib::OSSPUUID parses the name from
181 the system call C<`uuid-config --version`>.
182  
183 B<Events:>
184  
185 =over 4
186  
187 =item info
188  
189 Executing `uuid-config --version`
190  
191 =item error
192  
193 Failed to find OSSP UUID version with `uuid-config --version`
194  
195 Unable to parse name from string
196  
197 Unable to parse version from string
198  
199 Failed to parse OSSP UUID version parts from string
200  
201 =item unknown
202  
203 Enter a valid OSSP UUID version number
204  
205 =back
206  
207 =cut
208  
209 1 ▶my $get_version = sub {
Subroutine __ANON__: called CC=8 SCAR=26.9
210 1 my $self = shift;
211 1 $self->{'--version'} = 1;
212 1 my $data = $get_data->($self, '--version');
213 1 ▶ unless ($data) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data) 0 1 1
214 0 $self->error("Failed to find OSSP UUID version with ".
215 "`$self->{uuid_config} --version`");
216 0 return;
217 }
218  
219 # Parse the verison out of the data.
220 1 chomp $data;
221 1 my ($name, $version, $date) = $data =~ /(\D+)\s+([\d.]+)\s+\(([^)]+)\)/;
222  
223 # Check for and assign the name.
224 $name
225 1 ▶ ? $self->{name} = $name
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 1 0 1
226 : $self->error("Unable to parse name from string '$data'");
227  
228 # Parse the version number.
229 1 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) { } 1 0 1
230 1 my ($x, $y, $z) = $version =~ /(\d+)\.(\d+).(\d+)/;
231 1 ▶ if (defined $x and defined $y and defined $z) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $x and defined $y and defined $z) { } 1 0 1
elsif ($version =~ /(\d+)\.(\d+)/) { } 0 0 0
Condition33%2/6
defined $x and defined $y and defined $z
!ll&&!rl&&r
001
defined $x and defined $y
!ll&&!rl&&r
001
MC/DC0%0/3
defined $x and defined $y and defined $z
defined $x defined $y defined $z
Truth table25%1/4
A and B and C
A= defined $xB= defined $yC= defined $z
ABCresult
0XX0
10X0
1100
1111
232 # Beta/devel/release candidates are treated as patch level "0"
233 1 @{$self}{qw(version major minor patch)} =
234 ($version, $x, $y, $z);
235 } elsif ($version =~ /(\d+)\.(\d+)/) {
236 # New versions, such as "7.4", are treated as patch level "0"
237 0 @{$self}{qw(version major minor patch)} =
238 ($version, $1, $2, 0);
239 } else {
240 0 $self->error("Failed to parse OSSP UUID version parts from " .
241 "string '$version'");
242 }
243 } else {
244 0 $self->error("Unable to parse version from string '$data'");
245 }
246 2 };
247  
248 1 ▶sub name {
Subroutine name: called CC=4 SCAR=15.2
Pod documented
249 1 my $self = shift;
250 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
251  
252 # Load data.
253 1 ▶ $get_version->($self) unless $self->{'--version'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"--version"} 1 0 1
254  
255 # Handle an unknown name.
256 1 ▶ $self->{name} ||= $self->unknown( key => 'OSSP UUID name' );
Condition33%1/3
$self->{"name"} ||= $self->unknown("key", "OSSP UUID name")
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->{"name"} ||= $self->unknown("key", "OSSP UUID name")
$self->{"name"} $self->unknown("key", "OSSP UUID name")
Truth table33%1/3
A ||= B
A= $self->{"name"}B= $self->unknown("key", "OSSP UUID name")
ABresult
1X1
011
000
257  
258 # Return the name.
259 1 return $self->{name};
260 }
261  
262 ##############################################################################
263  
264 =head3 version
265  
266 my $version = $uuid->version;
267  
268 Returns the OSSP UUID version number. App::Info::Lib::OSSPUUID parses the
269 version number from the system call C<`uuid-config --version`>.
270  
271 B<Events:>
272  
273 =over 4
274  
275 =item info
276  
277 Executing `uuid-config --version`
278  
279 =item error
280  
281 Failed to find OSSP UUID version with `uuid-config --version`
282  
283 Unable to parse name from string
284  
285 Unable to parse version from string
286  
287 Failed to parse OSSP UUID version parts from string
288  
289 =item unknown
290  
291 Enter a valid OSSP UUID version number
292  
293 =back
294  
295 =cut
296  
297 1 ▶sub version {
Subroutine version: called CC=4 SCAR=22.3
Pod documented
298 1 my $self = shift;
299 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
300  
301 # Load data.
302 1 ▶ $get_version->($self) unless $self->{'--version'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"--version"} 0 1 1
303  
304 # Handle an unknown value.
305 1 ▶ unless ($self->{version}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"version"}) 0 1 1
306 # Create a validation code reference.
307 0 ▶ my $chk_version = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
308 # Try to get the version number parts.
309 0 my ($x, $y, $z) = /^(\d+)\.(\d+).(\d+)$/;
310 # Return false if we didn't get all three.
311 0 ▶ return unless $x and defined $y and defined $z;
Branch: 1 branch
BranchTrueFalseTotal
unless $x and defined $y and defined $z 0 0 0
Condition0%0/6
$x and defined $y and defined $z
!ll&&!rl&&r
000
$x and defined $y
!ll&&!rl&&r
000
MC/DC0%0/3
$x and defined $y and defined $z
$x defined $y defined $z
Truth table0%0/4
A and B and C
A= $xB= defined $yC= defined $z
ABCresult
0XX0
10X0
1100
1111
312 # Save all three parts.
313 0 @{$self}{qw(major minor patch)} = ($x, $y, $z);
314 # Return true.
315 0 return 1;
316 0 };
317 0 $self->{version} = $self->unknown(
318 key => 'OSSP UUID version number',
319 callback => $chk_version
320 );
321 }
322  
323 1 return $self->{version};
324 }
325  
326 ##############################################################################
327  
328 =head3 major version
329  
330 my $major_version = $uuid->major_version;
331  
332 Returns the OSSP UUID library major version number. App::Info::Lib::OSSPUUID
333 parses the major version number from the system call C<`uuid-config
334 --version`>. For example, if C<version()> returns "1.3.0", then this method
335 returns "1".
336  
337 B<Events:>
338  
339 =over 4
340  
341 =item info
342  
343 Executing `uuid-config --version`
344  
345 =item error
346  
347 Failed to find OSSP UUID version with `uuid-config --version`
348  
349 Unable to parse name from string
350  
351 Unable to parse version from string
352  
353 Failed to parse OSSP UUID version parts from string
354  
355 =item unknown
356  
357 Enter a valid OSSP UUID major version number
358  
359 =back
360  
361 =cut
362  
363 # This code reference is used by major_version(), minor_version(), and
364 # patch_version() to validate a version number entered by a user.
365 0 ▶my $is_int = sub { /^\d+$/ };
Subroutine __ANON__: not called CC=1 SCAR=1.2
366  
367 1 ▶sub major_version {
Subroutine major_version: called CC=4 SCAR=14.6
Pod documented
368 1 my $self = shift;
369 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
370 # Load data.
371 1 ▶ $get_version->($self) unless exists $self->{'--version'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"--version"} 0 1 1
372 # Handle an unknown value.
373 $self->{major} = $self->unknown(
374 key => 'OSSP UUID major version number',
375 callback => $is_int
376 1 ▶ ) unless $self->{major};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"major"} 0 1 1
377 1 return $self->{major};
378 }
379  
380 ##############################################################################
381  
382 =head3 minor version
383  
384 my $minor_version = $uuid->minor_version;
385  
386 Returns the OSSP UUID library minor version number. App::Info::Lib::OSSPUUID
387 parses the minor version number from the system call C<`uuid-config
388 --version`>. For example, if C<version()> returns "1.3.0", then this method
389 returns "3".
390  
391 B<Events:>
392  
393 =over 4
394  
395 =item info
396  
397 Executing `uuid-config --version`
398  
399 =item error
400  
401 Failed to find OSSP UUID version with `uuid-config --version`
402  
403 Unable to parse name from string
404  
405 Unable to parse version from string
406  
407 Failed to parse OSSP UUID version parts from string
408  
409 =item unknown
410  
411 Enter a valid OSSP UUID minor version number
412  
413 =back
414  
415 =cut
416  
417 1 ▶sub minor_version {
Subroutine minor_version: called CC=4 SCAR=14.6
Pod documented
418 1 my $self = shift;
419 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
420 # Load data.
421 1 ▶ $get_version->($self) unless exists $self->{'--version'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"--version"} 0 1 1
422 # Handle an unknown value.
423 $self->{minor} = $self->unknown(
424 key => 'OSSP UUID minor version number',
425 callback => $is_int
426 1 ▶ ) unless defined $self->{minor};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"minor"} 0 1 1
427 1 return $self->{minor};
428 }
429  
430 ##############################################################################
431  
432 =head3 patch version
433  
434 my $patch_version = $uuid->patch_version;
435  
436 Returns the OSSP UUID library patch version number. App::Info::Lib::OSSPUUID
437 parses the patch version number from the system call C<`uuid-config
438 --version`>. For example, if C<version()> returns "1.3.0", then this method
439 returns "0".
440  
441 B<Events:>
442  
443 =over 4
444  
445 =item info
446  
447 Executing `uuid-config --version`
448  
449 =item error
450  
451 Failed to find OSSP UUID version with `uuid-config --version`
452  
453 Unable to parse name from string
454  
455 Unable to parse version from string
456  
457 Failed to parse OSSP UUID version parts from string
458  
459 =item unknown
460  
461 Enter a valid OSSP UUID minor version number
462  
463 =back
464  
465 =cut
466  
467 1 ▶sub patch_version {
Subroutine patch_version: called CC=4 SCAR=14.6
Pod documented
468 1 my $self = shift;
469 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
470 # Load data.
471 1 ▶ $get_version->($self) unless exists $self->{'--version'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"--version"} 0 1 1
472 # Handle an unknown value.
473 $self->{patch} = $self->unknown(
474 key => 'OSSP UUID patch version number',
475 callback => $is_int
476 1 ▶ ) unless defined $self->{patch};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"patch"} 0 1 1
477 1 return $self->{patch};
478 }
479  
480 ##############################################################################
481  
482 =head3 executable
483  
484 my $exe = $uuid->executable;
485  
486 Returns the full path to the OSSP UUID executable, which is named F<uuid>.
487 This method does not use the executable names returned by
488 C<search_exe_names()>; those executable names are used to search for
489 F<uuid-config> only (in C<new()>).
490  
491 When it called, C<executable()> checks for an executable named F<uuid> in the
492 directory returned by C<bin_dir()>.
493  
494 Note that C<executable()> is simply an alias for C<uuid()>.
495  
496 B<Events:>
497  
498 =over 4
499  
500 =item info
501  
502 Looking for uuid executable
503  
504 =item confirm
505  
506 Path to uuid executable?
507  
508 =item unknown
509  
510 Path to uuid executable?
511  
512 =back
513  
514 =cut
515  
516  
517 2 ▶sub executable {
Subroutine executable: called CC=4 SCAR=14.8
Pod documented
518 2 my $self = shift;
519 2 my $key = 'uuid';
520  
521 # Find executable.
522 2 $self->info("Looking for $key");
523  
524 2 ▶ unless ($self->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{$key}) 1 1 2
525 1 ▶ my $bin = $self->bin_dir or return;
Branch: 1 branch
BranchTrueFalseTotal
my $bin = $self->bin_dir or return 1 0 1
526 1 ▶ if (my $exe = $u->first_cat_exe([$self->search_uuid_names], $bin)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $exe = $u->first_cat_exe([$self->search_uuid_names], $bin)) { } 1 0 1
527 # We found it. Confirm.
528 $self->{$key} = $self->confirm(
529 key => "path to $key",
530 prompt => "Path to $key executable?",
531 value => $exe,
532 0 ▶ callback => sub { -x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
533 1 error => 'Not an executable'
534 );
535 } else {
536 # Handle an unknown value.
537 $self->{$key} = $self->unknown(
538 key => "path to $key",
539 prompt => "Path to $key executable?",
540 0 ▶ callback => sub { -x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
541 0 error => 'Not an executable'
542 );
543 }
544 }
545  
546 2 return $self->{$key};
547 };
548  
549 2 *uuid = \&executable;
550  
551 ##############################################################################
552  
553 =head3 bin_dir
554  
555 my $bin_dir = $uuid->bin_dir;
556  
557 Returns the OSSP UUID binary directory path. App::Info::Lib::OSSPUUID gathers
558 the path from the system call C<`uuid-config --bindir`>.
559  
560 B<Events:>
561  
562 =over 4
563  
564 =item info
565  
566 Executing `uuid-config --bindir`
567  
568 =item error
569  
570 Cannot find bin directory
571  
572 =item unknown
573  
574 Enter a valid OSSP UUID bin directory
575  
576 =back
577  
578 =cut
579  
580 # This code reference is used by bin_dir(), lib_dir(), and so_lib_dir() to
581 # validate a directory entered by the user.
582 0 ▶my $is_dir = sub { -d };
Subroutine __ANON__: not called CC=1 SCAR=1.2
583  
584 2 ▶sub bin_dir {
Subroutine bin_dir: called CC=4 SCAR=14.8
Pod documented
585 2 my $self = shift;
586 2 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 2 2
587 2 ▶ unless (exists $self->{bin_dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"bin_dir"}) 1 1 2
588 1 ▶ if (my $dir = $get_data->($self, '--bindir')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = &$get_data($self, '--bindir')) { } 1 0 1
589 1 $self->{bin_dir} = $dir;
590 } else {
591 # Handle an unknown value.
592 0 $self->error("Cannot find bin directory");
593 0 $self->{bin_dir} = $self->unknown(
594 key => 'OSSP UUID bin dir',
595 callback => $is_dir
596 );
597 }
598 }
599  
600 2 return $self->{bin_dir};
601 }
602  
603 ##############################################################################
604  
605 =head3 inc_dir
606  
607 my $inc_dir = $uuid->inc_dir;
608  
609 Returns the OSSP UUID include directory path. App::Info::Lib::OSSPUUID gathers
610 the path from the system call C<`uuid-config --includedir`>.
611  
612 B<Events:>
613  
614 =over 4
615  
616 =item info
617  
618 Executing `uuid-config --includedir`
619  
620 =item error
621  
622 Cannot find include directory
623  
624 =item unknown
625  
626 Enter a valid OSSP UUID include directory
627  
628 =back
629  
630 =cut
631  
632 1 ▶sub inc_dir {
Subroutine inc_dir: called CC=4 SCAR=15.5
Pod documented
633 1 my $self = shift;
634 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
635 1 ▶ unless (exists $self->{inc_dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"inc_dir"}) 1 0 1
636 1 ▶ if (my $dir = $get_data->($self, '--includedir')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = &$get_data($self, '--includedir')) { } 1 0 1
637 1 $self->{inc_dir} = $dir;
638 } else {
639 # Handle an unknown value.
640 0 $self->error("Cannot find include directory");
641 0 $self->{inc_dir} = $self->unknown(
642 key => 'OSSP UUID include dir',
643 callback => $is_dir
644 );
645 }
646 }
647  
648 1 return $self->{inc_dir};
649 }
650  
651 ##############################################################################
652  
653 =head3 lib_dir
654  
655 my $lib_dir = $uuid->lib_dir;
656  
657 Returns the OSSP UUID library directory path. App::Info::Lib::OSSPUUID gathers
658 the path from the system call C<`uuid-config --libdir`>.
659  
660 B<Events:>
661  
662 =over 4
663  
664 =item info
665  
666 Executing `uuid-config --libdir`
667  
668 =item error
669  
670 Cannot find library directory
671  
672 =item unknown
673  
674 Enter a valid OSSP UUID library directory
675  
676 =back
677  
678 =cut
679  
680 2 ▶sub lib_dir {
Subroutine lib_dir: called CC=4 SCAR=14.8
Pod documented
681 2 my $self = shift;
682 2 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 2 2
683 2 ▶ unless (exists $self->{lib_dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"lib_dir"}) 1 1 2
684 1 ▶ if (my $dir = $get_data->($self, '--libdir')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = &$get_data($self, '--libdir')) { } 1 0 1
685 1 $self->{lib_dir} = $dir;
686 } else {
687 # Handle an unknown value.
688 0 $self->error("Cannot find library directory");
689 0 $self->{lib_dir} = $self->unknown(
690 key => 'OSSP UUID library dir',
691 callback => $is_dir
692 );
693 }
694 }
695  
696 2 return $self->{lib_dir};
697 }
698  
699 ##############################################################################
700  
701 =head3 so_lib_dir
702  
703 my $so_lib_dir = $uuid->so_lib_dir;
704  
705 Returns the OSSP UUID shared object library directory path. This is actually
706 just an alias for C<lib_dir()>.
707  
708 B<Events:>
709  
710 =over 4
711  
712 =item info
713  
714 Executing `uuid-config --libdir`
715  
716 =item error
717  
718 Cannot find library directory
719  
720 =item unknown
721  
722 Enter a valid OSSP UUID library directory
723  
724 =back
725  
726 =cut
727  
728 2 *so_lib_dir = \&lib_dir;
729  
730 ##############################################################################
731  
732 =head3 cflags
733  
734 my $configure = $uuid->cflags;
735  
736 Returns the C flags used when compiling the OSSP UUID library.
737 App::Info::Lib::OSSPUUID gathers the configure data from the system call
738 C<`uuid-config --cflags`>.
739  
740 B<Events:>
741  
742 =over 4
743  
744 =item info
745  
746 Executing `uuid-config --configure`
747  
748 =item error
749  
750 Cannot find configure information
751  
752 =item unknown
753  
754 Enter OSSP UUID configuration options
755  
756 =back
757  
758 =cut
759  
760 1 ▶sub cflags {
Subroutine cflags: called CC=4 SCAR=15.0
Pod documented
761 1 my $self = shift;
762 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
763 1 ▶ unless (exists $self->{cflags} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"cflags"}) 1 0 1
764 1 ▶ if (my $conf = $get_data->($self, '--cflags')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $conf = &$get_data($self, '--cflags')) { } 1 0 1
765 1 $self->{cflags} = $conf;
766 } else {
767 # Cflags can be empty, so just make sure it exists and is
768 # defined. Don't prompt.
769 0 $self->{cflags} = '';
770 }
771 }
772  
773 1 return $self->{cflags};
774 }
775  
776 ##############################################################################
777  
778 =head3 ldflags
779  
780 my $configure = $uuid->ldflags;
781  
782 Returns the LD flags used when compiling the OSSP UUID library.
783 App::Info::Lib::OSSPUUID gathers the configure data from the system call
784 C<`uuid-config --ldflags`>.
785  
786 B<Events:>
787  
788 =over 4
789  
790 =item info
791  
792 Executing `uuid-config --configure`
793  
794 =item error
795  
796 Cannot find configure information
797  
798 =item unknown
799  
800 Enter OSSP UUID configuration options
801  
802 =back
803  
804 =cut
805  
806 1 ▶sub ldflags {
Subroutine ldflags: called CC=4 SCAR=15.0
Pod documented
807 1 my $self = shift;
808 1 ▶ return unless $self->{uuid_config};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"uuid_config"} 0 1 1
809 1 ▶ unless (exists $self->{ldflags} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"ldflags"}) 1 0 1
810 1 ▶ if (my $conf = $get_data->($self, '--ldflags')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $conf = &$get_data($self, '--ldflags')) { } 1 0 1
811 1 $self->{ldflags} = $conf;
812 } else {
813 # Ldflags can be empty, so just make sure it exists and is
814 # defined. Don't prompt.
815 0 $self->{ldflags} = '';
816 }
817 }
818  
819 1 return $self->{ldflags};
820 }
821  
822 ##############################################################################
823  
824 =head3 perl_module
825  
826 my $bool = $uuid->perl_module;
827  
828 Return true if C<OSSP::uuid> is installed and can be loaded, and false if not.
829 C<OSSP::uuid> must be able to be loaded by the currently running instance of
830 the Perl interpreter.
831  
832 B<Events:>
833  
834 =over 4
835  
836 =item info
837  
838 Loading OSSP::uuid
839  
840 =back
841  
842 =cut
843  
844 1 ▶sub perl_module {
Subroutine perl_module: called CC=2 SCAR=7.0
Pod documented
845 1 my $self = shift;
846 1 $self->info('Loading OSSP::uuuid');
847 1 ▶ $self->{perl_module} ||= do {
Condition33%1/3
$self->{"perl_module"} ||= do { eval "use OSSP::uuid"; $INC{catfile(("OSSP", "uuid.pm"))} }
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"perl_module"} ||= do { eval "use OSSP::uuid"; $INC{catfile(("OSSP", "uuid.pm"))} }
$self->{"perl_module"} do { eval "use OSSP::uuid"; $INC{catfile(("OSSP", "uuid.pm"))} }
Truth table33%1/3
A ||= B
A= $self->{"perl_module"}B= do { eval "use OSSP::uuid"; $INC{catfile(("OSSP", "uuid.pm"))} }
ABresult
1X1
011
000
848 1 ▶ eval 'use OSSP::uuid';
Subroutine BEGIN: called CC=1 SCAR=0.0
849 1 $INC{catfile qw(OSSP uuid.pm)};
850 };
851 1 return $self->{perl_module};
852 }
853  
854 ##############################################################################
855  
856 =head3 home_url
857  
858 my $home_url = $uuid->home_url;
859  
860 Returns the OSSP UUID home page URL.
861  
862 =cut
863  
864 1 ▶sub home_url { 'http://www.ossp.org/pkg/lib/uuid/' }
Subroutine home_url: called CC=1 SCAR=0.0
Pod documented
865  
866 ##############################################################################
867  
868 =head3 download_url
869  
870 my $download_url = $uuid->download_url;
871  
872 Returns the OSSP UUID download URL.
873  
874 =cut
875  
876 1 ▶sub download_url { 'http://www.ossp.org/pkg/lib/uuid/' }
Subroutine download_url: called CC=1 SCAR=0.0
Pod documented
877  
878 ##############################################################################
879  
880 =head3 search_exe_names
881  
882 my @search_exe_names = $app->search_exe_names;
883  
884 Returns a list of possible names for F<uuid-config> executable. By default, only
885 F<uuid-config> is returned (or F<uuid-config.exe> on Win32).
886  
887 Note that this method is not used to search for the OSSP UUID server
888 executable, only F<uuid-config>.
889  
890 =cut
891  
892 2 ▶sub search_exe_names {
Subroutine search_exe_names: called CC=1 SCAR=0.0
Pod documented
893 2 my $self = shift;
894 2 my $exe = 'uuid-config';
895 2 $exe .= '.exe' if WIN32;
896 2 return ($self->SUPER::search_exe_names, $exe);
897 }
898  
899 ##############################################################################
900  
901 =head3 search_bin_dirs
902  
903 my @search_bin_dirs = $app->search_bin_dirs;
904  
905 Returns a list of possible directories in which to search an executable. Used
906 by the C<new()> constructor to find an executable to execute and collect
907 application info. The found directory will also be returned by the C<bin_dir>
908 method.
909  
910 The list of directories by default consists of the path as defined by
911 C<< File::Spec->path >>, as well as the following directories:
912  
913 =over 4
914  
915 =item /usr/local/bin
916  
917 =item /usr/local/sbin
918  
919 =item /usr/bin
920  
921 =item /usr/sbin
922  
923 =item /bin
924  
925 =item C:\Program Files\uid\bin
926  
927 =back
928  
929 =cut
930  
931 2 ▶sub search_bin_dirs {
Subroutine search_bin_dirs: called CC=1 SCAR=0.0
Pod documented
932 return shift->SUPER::search_bin_dirs,
933 2 $u->path,
934 qw(/usr/local/bin
935 /usr/local/sbin
936 /usr/bin
937 /usr/sbin
938 /bin),
939 'C:\Program Files\uid\bin';
940 }
941  
942 ##############################################################################
943  
944 =head2 Other Executable Methods
945  
946 These methods function just like the C<executable()> method, except that they
947 return different executables. OSSP UUID comes with a fair number of them; we
948 provide these methods to provide a path to a subset of them. Each method, when
949 called, checks for an executable in the directory returned by C<bin_dir()>.
950 The name of the executable must be one of the names returned by the
951 corresponding C<search_*_names> method.
952  
953 The available executable methods are:
954  
955 =over
956  
957 =item uuid
958  
959 =item uuid_config
960  
961 =back
962  
963 And the corresponding search names methods are:
964  
965 =over
966  
967 =item search_postgres_names
968  
969 =item search_createdb_names
970  
971 =back
972  
973 B<Events:>
974  
975 =over 4
976  
977 =item info
978  
979 Looking for executable
980  
981 =item confirm
982  
983 Path to executable?
984  
985 =item unknown
986  
987 Path to executable?
988  
989 =back
990  
991 =cut
992  
993 1 ▶sub search_uuid_names { @{ shift->{search_uuid_names} } }
Subroutine search_uuid_names: called CC=1 SCAR=0.0
Pod undocumented
994  
995 2 1;
996 __END__
« lib/App/Info/RDBMS/PostgreSQL.pm ↑ Summary blib/lib/App/Info/HTTPD/Apache.pm »